"GOT", but the "O" is a cute, smiling pufferfish. Index | Thread | Search

From:
Omar Polo <op@omarpolo.com>
Subject:
fix grouping in commit traversal
To:
gameoftrees@openbsd.org
Date:
Fri, 12 Jul 2024 21:14:14 +0200

Download raw body.

Thread
I managed to hit this after bumping the struct got_object_id and trying
to blame a file with lots of history.

(gdb) p ncommits
$5 = 455
(gdb) p sizeof(struct got_imsg_traversed_commits) + ncommits * sizeof(*commit_ids)
$6 = 16388
(gdb) p max_datalen
$7 = 16368

Not sure why we've never hit this so far since it doesn't depend on my
sha256 work.  Anyway, I guess that the indent was to group as much as
much ids as possible in a single go.  ok?

diff -s /home/op/w/got
commit - ba4166c282c6a1f42adb1fb4cf6c353ddee246dc
path + /home/op/w/got (staged changes)
blob - 9dceafae49c221323cef8b373af45c21de3d6bc3
blob + 5e1ec6efa75876a9ed9e5f0aea1a6975639cbbfc
--- libexec/got-read-pack/got-read-pack.c
+++ libexec/got-read-pack/got-read-pack.c
@@ -697,7 +697,7 @@ commit_traversal_request(struct imsg *imsg, struct ims
 		}
 
 		if (sizeof(struct got_imsg_traversed_commits) +
-		    ncommits * sizeof(commit_ids[0]) >= max_datalen) {
+		    (ncommits + 1) * sizeof(commit_ids[0]) >= max_datalen) {
 			err = send_traversed_commits(commit_ids, ncommits,
 			    ibuf);
 			if (err)