diff options
author | Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com> | 2015-11-06 21:04:34 +0100 |
---|---|---|
committer | Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com> | 2015-11-07 13:13:35 +0100 |
commit | db374790c75fa4ef947abcb5019fcf21d0b2de85 (patch) | |
tree | 48e4ed4cb962d7dab3bc63644d6452d7fbc60006 | |
parent | 7f7fa90f7b7fccecff98bb1cef307e093dac1d29 (diff) | |
download | ffmpeg-db374790c75fa4ef947abcb5019fcf21d0b2de85.tar.gz |
jvdec: avoid unsigned overflow in comparison
The return type of strlen is size_t, i.e. unsigned, so if pd->buf_size
is 3, the right side overflows leading to a wrong result of the
comparison and subsequently a heap buffer overflow.
Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
-rw-r--r-- | libavformat/jvdec.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/libavformat/jvdec.c b/libavformat/jvdec.c index 4d4f0c78c5..a31c7236ff 100644 --- a/libavformat/jvdec.c +++ b/libavformat/jvdec.c @@ -54,7 +54,7 @@ typedef struct JVDemuxContext { static int read_probe(AVProbeData *pd) { - if (pd->buf[0] == 'J' && pd->buf[1] == 'V' && strlen(MAGIC) <= pd->buf_size - 4 && + if (pd->buf[0] == 'J' && pd->buf[1] == 'V' && strlen(MAGIC) + 4 <= pd->buf_size && !memcmp(pd->buf + 4, MAGIC, strlen(MAGIC))) return AVPROBE_SCORE_MAX; return 0; |