patch-delta: fix oob read
If `cmd` is in the range [0x01,0x7f] and `cmd > top-data`, the `memcpy(out, data, cmd)` can copy out-of-bounds data from after `delta_buf` into `dst_buf`. This is not an exploitable bug because triggering the bug increments the `data` pointer beyond `top`, causing the `data != top` sanity check after the loop to trigger and discard the destination buffer - which means that the result of the out-of-bounds read is never used for anything. Signed-off-by: Jann Horn <jannh@google.com> Signed-off-by: Jeff King <peff@peff.net> Reviewed-by: Nicolas Pitre <nico@fluxnic.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:

committed by
Junio C Hamano

parent
9caf0107a8
commit
21870efc4a
@ -56,7 +56,7 @@ void *patch_delta(const void *src_buf, unsigned long src_size,
|
||||
out += cp_size;
|
||||
size -= cp_size;
|
||||
} else if (cmd) {
|
||||
if (cmd > size)
|
||||
if (cmd > size || cmd > top - data)
|
||||
break;
|
||||
memcpy(out, data, cmd);
|
||||
out += cmd;
|
||||
|
Reference in New Issue
Block a user