diff options
author | Justin Ruggles <justin.ruggles@gmail.com> | 2011-09-13 15:13:44 -0400 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2011-10-01 20:33:34 +0200 |
commit | 20047f77b9592da17e8bc56e54d3b2e2ca6959a9 (patch) | |
tree | ffda1ab26301829348dc074a579f7f5eb24053b9 | |
parent | 7e362df304121003fda7705917d5e797b48a0920 (diff) | |
download | ffmpeg-20047f77b9592da17e8bc56e54d3b2e2ca6959a9.tar.gz |
flacdec: fix buffer size checking in get_metadata_size()
Adds an additional check before reading the next block header and avoids a
potential integer overflow when checking the metadata size against the
remaining buffer size.
(cherry picked from commit 4c5e7b27d57dd2be777780e840eef9be63242158)
-rw-r--r-- | libavcodec/flacdec.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/libavcodec/flacdec.c b/libavcodec/flacdec.c index ece095cf09..011c75faae 100644 --- a/libavcodec/flacdec.c +++ b/libavcodec/flacdec.c @@ -228,9 +228,11 @@ static int get_metadata_size(const uint8_t *buf, int buf_size) buf += 4; do { + if (buf_end - buf < 4) + return 0; ff_flac_parse_block_header(buf, &metadata_last, NULL, &metadata_size); buf += 4; - if (buf + metadata_size > buf_end) { + if (buf_end - buf < metadata_size) { /* need more data in order to read the complete header */ return 0; } |