Skip to content

Commit e3efa9c

Browse files
committed
Merge branch 'np/maint-huge-delta-generation'
* np/maint-huge-delta-generation: fix >4GiB source delta assertion failure
2 parents 2acf365 + 506049c commit e3efa9c

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

diff-delta.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,14 @@ struct delta_index * create_delta_index(const void *buf, unsigned long bufsize)
146146
/* Determine index hash size. Note that indexing skips the
147147
first byte to allow for optimizing the Rabin's polynomial
148148
initialization in create_delta(). */
149-
entries = (bufsize - 1) / RABIN_WINDOW;
149+
entries = (bufsize - 1) / RABIN_WINDOW;
150+
if (bufsize >= 0xffffffffUL) {
151+
/*
152+
* Current delta format can't encode offsets into
153+
* reference buffer with more than 32 bits.
154+
*/
155+
entries = 0xfffffffeU / RABIN_WINDOW;
156+
}
150157
hsize = entries / 4;
151158
for (i = 4; (1u << i) < hsize && i < 31; i++);
152159
hsize = 1 << i;

0 commit comments

Comments
 (0)