aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLuca Barbato <lu_zero@gentoo.org>2013-05-13 19:32:04 +0200
committerReinhard Tartler <siretart@tauware.de>2013-06-22 08:48:24 +0200
commit33492ad81000b326ba98fe20d6007d4b67cbbd3d (patch)
tree46ea8eddb80a2a7650498f09e7b2f748171a3b1c
parentda5cf7e45263d7e8c67d0705a403c6c88686c5bb (diff)
downloadffmpeg-33492ad81000b326ba98fe20d6007d4b67cbbd3d.tar.gz
mjpeg: Validate sampling factors
They must be non-zero. Reported-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind CC: libav-stable@libav.org (cherry picked from commit 8aa3500905fec6c4e657bb291b861d43c34d3de9) Signed-off-by: Reinhard Tartler <siretart@tauware.de> Conflicts: libavcodec/mjpegdec.c
-rw-r--r--libavcodec/mjpegdec.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/libavcodec/mjpegdec.c b/libavcodec/mjpegdec.c
index 7f1fa62ad1..47c98994fd 100644
--- a/libavcodec/mjpegdec.c
+++ b/libavcodec/mjpegdec.c
@@ -266,6 +266,13 @@ int ff_mjpeg_decode_sof(MJpegDecodeContext *s)
s->quant_index[i] = get_bits(&s->gb, 8);
if (s->quant_index[i] >= 4)
return -1;
+ if (!s->h_count[i] || !s->v_count[i]) {
+ av_log(s->avctx, AV_LOG_ERROR,
+ "Invalid sampling factor in component %d %d:%d\n",
+ i, s->h_count[i], s->v_count[i]);
+ return AVERROR_INVALIDDATA;
+ }
+
av_log(s->avctx, AV_LOG_DEBUG, "component %d %d:%d id: %d quant:%d\n",
i, s->h_count[i], s->v_count[i],
s->component_id[i], s->quant_index[i]);