summaryrefslogtreecommitdiff
path: root/libavformat
diff options
context:
space:
mode:
authorReynaldo H. Verdejo Pinochet <r.verdejo@sisa.samsung.com>2014-01-23 15:43:07 -0300
committerReynaldo H. Verdejo Pinochet <r.verdejo@sisa.samsung.com>2014-01-23 17:40:58 -0300
commit30f4c58f6f92765b3d06b0950392e5264630bce0 (patch)
tree3c2dd4c37c2b6d56b2b57e5bf409a96365c08dc0 /libavformat
parentbf23642dcc86890fa2e32697c3b930b3f1ac0d88 (diff)
libavformat/mtv: Check for min header size first
Abort immediately if we are not getting enough data to extract the required fields. Signed-off-by: Reynaldo H. Verdejo Pinochet <r.verdejo@sisa.samsung.com>
Diffstat (limited to 'libavformat')
-rw-r--r--libavformat/mtv.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/libavformat/mtv.c b/libavformat/mtv.c
index 0517dd2d83..5e638cacec 100644
--- a/libavformat/mtv.c
+++ b/libavformat/mtv.c
@@ -52,12 +52,18 @@ typedef struct MTVDemuxContext {
static int mtv_probe(AVProbeData *p)
{
+ /* we need at least 57 bytes from the header
+ * to try parsing all required fields
+ */
+ if (p->buf_size < 57)
+ return 0;
+
/* Magic is 'AMV' */
if (*p->buf != 'A' || *(p->buf + 1) != 'M' || *(p->buf + 2) != 'V')
return 0;
/* Check for nonzero in bpp and (width|height) header fields */
- if(p->buf_size < 57 || !(p->buf[51] && AV_RL16(&p->buf[52]) | AV_RL16(&p->buf[54])))
+ if(!(p->buf[51] && AV_RL16(&p->buf[52]) | AV_RL16(&p->buf[54])))
return 0;
/* If width or height are 0 then imagesize header field should not */