summaryrefslogtreecommitdiff
path: root/libavcodec/pnm.c
diff options
context:
space:
mode:
authorDaniel Kang <daniel.d.kang@gmail.com>2011-01-10 00:42:57 +0000
committerCarl Eugen Hoyos <cehoyos@rainbow.studorg.tuwien.ac.at>2011-01-10 00:42:57 +0000
commitebc3488300523dad3da41f420ecfcdddd1d8e9f3 (patch)
tree2949f6696d582336197984ff03dac9829b382e79 /libavcodec/pnm.c
parent39f4d329081732b24f5ad6ef222736f1453bbad2 (diff)
downloadffmpeg-ebc3488300523dad3da41f420ecfcdddd1d8e9f3.tar.gz
Check for invalid maxval in pgm decoder, fixes issue 2518.
Patch by Daniel Kang, daniel.d.kang at gmail Originally committed as revision 26292 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec/pnm.c')
-rw-r--r--libavcodec/pnm.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/libavcodec/pnm.c b/libavcodec/pnm.c
index 536b344923..43438b7cef 100644
--- a/libavcodec/pnm.c
+++ b/libavcodec/pnm.c
@@ -140,6 +140,10 @@ int ff_pnm_decode_header(AVCodecContext *avctx, PNMContext * const s)
if (avctx->pix_fmt != PIX_FMT_MONOWHITE) {
pnm_get(s, buf1, sizeof(buf1));
s->maxval = atoi(buf1);
+ if (s->maxval <= 0) {
+ av_log(avctx, AV_LOG_ERROR, "Invalid maxval: %d\n", s->maxval);
+ return -1;
+ }
if (s->maxval >= 256) {
if (avctx->pix_fmt == PIX_FMT_GRAY8) {
avctx->pix_fmt = PIX_FMT_GRAY16BE;