avcodec/iff: ensure that runs with insufficient input dont leave uninitialized bytes in the output

Fixes use of uninitialized memory
Fixes: msan_uninit-mem_7fa0dea15eae_8988_test.iff
Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
pull/50/head
Michael Niedermayer 11 years ago
parent 7340718d1c
commit 4843227b2c
  1. 8
      libavcodec/iff.c

@ -488,12 +488,12 @@ static int decode_byterun(uint8_t *dst, int dst_size,
unsigned length; unsigned length;
const int8_t value = *buf++; const int8_t value = *buf++;
if (value >= 0) { if (value >= 0) {
length = value + 1; length = FFMIN3(value + 1, dst_size - x, buf_end - buf);
memcpy(dst + x, buf, FFMIN3(length, dst_size - x, buf_end - buf)); memcpy(dst + x, buf, length);
buf += length; buf += length;
} else if (value > -128) { } else if (value > -128) {
length = -value + 1; length = FFMIN(-value + 1, dst_size - x);
memset(dst + x, *buf++, FFMIN(length, dst_size - x)); memset(dst + x, *buf++, length);
} else { // noop } else { // noop
continue; continue;
} }

Loading…
Cancel
Save