Commit 8425d693 authored by Xi Wang's avatar Xi Wang Committed by Luca Barbato

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: 's avatarXi Wang <xi.wang@gmail.com>
Signed-off-by: 's avatarLuca Barbato <lu_zero@gentoo.org>
parent eba1ff31
...@@ -279,11 +279,9 @@ static int flac_read_header(AVFormatContext *s) ...@@ -279,11 +279,9 @@ static int flac_read_header(AVFormatContext *s)
static int flac_probe(AVProbeData *p) static int flac_probe(AVProbeData *p)
{ {
uint8_t *bufptr = p->buf; if (p->buf_size < 4 || memcmp(p->buf, "fLaC", 4))
uint8_t *end = p->buf + p->buf_size; return 0;
return AVPROBE_SCORE_MAX/2;
if(bufptr > end-4 || memcmp(bufptr, "fLaC", 4)) return 0;
else return AVPROBE_SCORE_MAX/2;
} }
AVInputFormat ff_flac_demuxer = { AVInputFormat ff_flac_demuxer = {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment