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

From:
Stefan Sperling <stsp@stsp.name>
Subject:
Re: got send failure
To:
Christian Weisgerber <naddy@mips.inka.de>
Cc:
gameoftrees@openbsd.org
Date:
Sun, 29 Aug 2021 13:54:09 +0200

Download raw body.

Thread
On Sun, Aug 29, 2021 at 12:15:57AM +0200, Christian Weisgerber wrote:
> Stefan Sperling:
> 
> > Most likely the file contents weren't included in the pack properly.
> > This would cause their hashes to change.
> > 
> > I've attached the files I found in the pack file.
> > Can you please diff them against your files?
> 
> That is... bizarre.  Somehow parts were overwritten by a piece of
> commit.sh.

This fixes it. ok?

-----------------------------------------------
commit 270498ff4c65cb3d8662d16bd780c9735bb0efdf (stretchblk)
from: Stefan Sperling <stsp@stsp.name>
date: Sun Aug 29 11:53:10 2021 UTC
 
 fix seek to incorrect offset in the delta base when creating deltas
 
 The stretchblk() function needs to compare data located after the block
 which has just been matched. However, upon entry it was resetting the
 file pointer of the delta base to the beginning(!) of the block.
 The other file is correctly positioned after the block.
 In many cases the data won't match and stretchblk() will not stretch
 the matched block. But when the data did happen to match this resulted
 in a bogus delta, and wrong file contents when the delta was applied.
 Fix this by setting the delta base file pointer to end of the block.
 
 Problem reported by naddy after our server refused a pack file which
 was sent by 'got send'. I could reproduce the issue by running the
 'gotadmin pack' command on a copy of naddy's repository.
 
diff fbe1f60e57f5efce6775c0ff8e12dff54c4eadb9 b2ef032e466ca4e4508d4f2aa44eba71d057ade4
blob - 85c7390aa9b5addf2127aa4e831f5c9f9c77b61d
blob + 0ffffe0f4e30bc85094fda4bfba4fc745011ab8a
--- lib/deltify.c
+++ lib/deltify.c
@@ -325,7 +325,8 @@ stretchblk(FILE *basefile, off_t base_offset0, struct 
 	size_t base_r, r, i;
 	int buf_equal = 1;
 
-	if (fseeko(basefile, base_offset0 + block->offset, SEEK_SET) == -1)
+	if (fseeko(basefile, base_offset0 + block->offset + *blocklen,
+	    SEEK_SET) == -1)
 		return got_error_from_errno("fseeko");
 
 	while (buf_equal && *blocklen < (1 << 24) - 1) {