Skip to content

Commit

Permalink
[PATCH] Fix count-delta overcounting
Browse files Browse the repository at this point in the history
The count-delta routine sometimes overcounted the copied source
material which resulted in unsigned int wraparound.

Signed-off-by: Junio C Hamano <junkio@cox.net>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
  • Loading branch information
Junio C Hamano authored and Linus Torvalds committed May 29, 2005
1 parent 844e6e4 commit 8b7d510
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions count-delta.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

0 comments on commit 8b7d510

Please sign in to comment.