check patch_delta bounds more carefully
Let's avoid going south with invalid delta data. Signed-off-by: Nicolas Pitre <nico@cam.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
This commit is contained in:
committed by
Junio C Hamano
parent
7d6c447145
commit
8960844a78
5
delta.h
5
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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user