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

From:
Omar Polo <op@omarpolo.com>
Subject:
use SHA1_DIGEST_LENGTH instead of sizeof(id)
To:
gameoftrees@openbsd.org
Date:
Sat, 18 Feb 2023 12:29:17 +0100

Download raw body.

Thread
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?

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)