Skip to content

Commit 8b7d510

Browse files
Junio C HamanoLinus Torvalds
authored andcommitted
[PATCH] Fix count-delta overcounting
The count-delta routine sometimes overcounted the copied source material which resulted in unsigned int wraparound. Signed-off-by: Junio C Hamano <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent 844e6e4 commit 8b7d510

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

count-delta.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,5 +88,8 @@ unsigned long count_delta(void *delta_buf, unsigned long delta_size)
8888
/* delete size is what was _not_ copied from source.
8989
* edit size is that and literal additions.
9090
*/
91+
if (src_size + added_literal < copied_from_source)
92+
/* we ended up overcounting and underflowed */
93+
return 0;
9194
return (src_size - copied_from_source) + added_literal;
9295
}

0 commit comments

Comments
 (0)