diff options
author | Xi Wang <xi.wang@gmail.com> | 2013-03-15 07:11:47 -0400 |
---|---|---|
committer | Luca Barbato <lu_zero@gentoo.org> | 2013-03-15 13:33:35 +0100 |
commit | d8010bda7a233fbfa05c3d7690d717a86102926c (patch) | |
tree | 7460c738d5a7a1a79ff6490b5d06b9ab367ddd09 | |
parent | 12d8ae297911c3020f4d3c1c34967a47b30fb8aa (diff) | |
download | ffmpeg-d8010bda7a233fbfa05c3d7690d717a86102926c.tar.gz |
flacdec: simplify bounds checking in flac_probe()
Simplify `p->buf > p->buf + p->buf_size - 4' as `p->buf_size < 4'.
Avoid a possible out-of-bounds pointer, which is undefined behavior
in C.
CC: libav-stable@libav.org
Signed-off-by: Xi Wang <xi.wang@gmail.com>
Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
(cherry picked from commit 8425d693eefbedbb41f91735614d41067695aa37)
-rw-r--r-- | libavformat/flacdec.c | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/libavformat/flacdec.c b/libavformat/flacdec.c index 9e083d116c..92957b67dd 100644 --- a/libavformat/flacdec.c +++ b/libavformat/flacdec.c @@ -143,11 +143,9 @@ static int flac_read_header(AVFormatContext *s, static int flac_probe(AVProbeData *p) { - uint8_t *bufptr = p->buf; - uint8_t *end = p->buf + p->buf_size; - - if(bufptr > end-4 || memcmp(bufptr, "fLaC", 4)) return 0; - else return AVPROBE_SCORE_MAX/2; + if (p->buf_size < 4 || memcmp(p->buf, "fLaC", 4)) + return 0; + return AVPROBE_SCORE_MAX/2; } AVInputFormat ff_flac_demuxer = { |