X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=delta.h;h=9464f3e9b08b959d11305688ce194867a4017817;hb=e88856b485cd73dfc1f3ef8d4c5b52a2f557e8c8;hp=a15350dabcd497d4cb21261721706eca072de034;hpb=3f6726e1f112d221bd2a919e9b1b2927aeef6150;p=git.git diff --git a/delta.h b/delta.h index a15350da..9464f3e9 100644 --- a/delta.h +++ b/delta.h @@ -16,7 +16,8 @@ extern void *patch_delta(void *src_buf, unsigned long src_size, * This must be called twice on the delta data buffer, first to get the * expected reference buffer size, and again to get the result buffer size. */ -static inline unsigned long get_delta_hdr_size(const unsigned char **datap) +static inline unsigned long get_delta_hdr_size(const unsigned char **datap, + const unsigned char *top) { const unsigned char *data = *datap; unsigned char cmd; @@ -26,7 +27,7 @@ static inline unsigned long get_delta_hdr_size(const unsigned char **datap) cmd = *data++; size |= (cmd & ~0x80) << i; i += 7; - } while (cmd & 0x80); + } while (cmd & 0x80 && data < top); *datap = data; return size; }