X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=count-delta.c;h=e10c832a758f49e9117a3456686d54f8b94ce10b;hb=8b7d510fb182ca40bd0f905bb2f5543b0d9549de;hp=dd81e9296591d463a7b06570bc24dc201a836b2e;hpb=85976974581060716311d6807b03a671cb71cbde;p=git.git diff --git a/count-delta.c b/count-delta.c index dd81e929..e10c832a 100644 --- a/count-delta.c +++ b/count-delta.c @@ -6,7 +6,6 @@ #include #include #include -#include "delta.h" #include "count-delta.h" static unsigned long get_hdr_size(const unsigned char **datap) @@ -89,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; }