mirror of
https://git.ffmpeg.org/ffmpeg.git
synced 2024-12-12 10:15:22 +00:00
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 8425d693ee
)
This commit is contained in:
parent
0b0e87bb54
commit
9d4355d90a
@ -278,11 +278,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 = {
|
||||
|
Loading…
Reference in New Issue
Block a user