From: Junio C Hamano Date: Sat, 28 May 2005 19:22:38 +0000 (-0700) Subject: [PATCH] Fix count-delta overcounting X-Git-Tag: v0.99~420 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=8b7d510fb182ca40bd0f905bb2f5543b0d9549de;p=git.git [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 Signed-off-by: Linus Torvalds --- diff --git a/count-delta.c b/count-delta.c index 3bcc205f5..e10c832a7 100644 --- a/count-delta.c +++ b/count-delta.c @@ -88,5 +88,8 @@ unsigned long count_delta(void *delta_buf, unsigned long delta_size) /* delete size is what was _not_ copied from source. * edit size is that and literal additions. */ + if (src_size + added_literal < copied_from_source) + /* we ended up overcounting and underflowed */ + return 0; return (src_size - copied_from_source) + added_literal; }