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

From:
Omar Polo <op@omarpolo.com>
Subject:
Re: use SHA1_DIGEST_LENGTH instead of sizeof(id)
To:
Stefan Sperling <stsp@stsp.name>
Cc:
gameoftrees@openbsd.org
Date:
Sat, 18 Feb 2023 13:00:35 +0100

Download raw body.

Thread
On 2023/02/18 12:39:39 +0100, Stefan Sperling <stsp@stsp.name> wrote:
> On Sat, Feb 18, 2023 at 12:29:17PM +0100, Omar Polo wrote:
> > Since it's used to find the offset in the mmap'ed area it should rely
> > on the size of the digest, not the size of our struct (which just
> > happens to be the same as of now ;-)
> > 
> > ok?
> 
> Yes, ok. In the future this size may have to be adjusted based on
> object ID type I guess.

yep.  in my wip branch i have an enum got_hash_algorithm and a
function got_hash_digest_length() that would be used here.  However, I
figured that it would be better to have this place fixed wrt the
'correct' length to make it easier to review future changes.

> > diff /home/op/w/gotd
> > commit - bf1c78e5100932aa445b8ef07ebf9b712500c67e
> > path + /home/op/w/gotd
> > blob - 68de5bf9f8523cf07c88e05955ce9b4c6abc451a
> > file + lib/pack.c
> > --- lib/pack.c
> > +++ lib/pack.c
> > @@ -1143,7 +1143,7 @@ resolve_ref_delta(struct got_delta_chain *deltas, stru
> >  	if (err)
> >  		return err;
> >  	if (pack->map) {
> > -		delta_data_offset = delta_offset + tslen + sizeof(id);
> > +		delta_data_offset = delta_offset + tslen + SHA1_DIGEST_LENGTH;
> >  	} else {
> >  		delta_data_offset = lseek(pack->fd, 0, SEEK_CUR);
> >  		if (delta_data_offset == -1)
> > 
> >