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

From:
Stefan Sperling <stsp@stsp.name>
Subject:
Re: fix grouping in commit traversal
To:
Omar Polo <op@omarpolo.com>
Cc:
gameoftrees@openbsd.org
Date:
Sat, 13 Jul 2024 05:46:51 +0200

Download raw body.

Thread
On Fri, Jul 12, 2024 at 09:14:14PM +0200, Omar Polo wrote:
> 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?

ok, nice catch.

> 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)
> 
>