aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec
diff options
context:
space:
mode:
authorMichael Niedermayer <michael@niedermayer.cc>2019-04-06 13:11:10 +0200
committerMichael Niedermayer <michael@niedermayer.cc>2019-04-10 22:26:30 +0200
commit7f3d39b21f893145dcfd33abf6f6a2c994b246ec (patch)
treef66f7addf932510a68eb1b936cd4bb5fd3a0eb72 /libavcodec
parent2be7c388db67a0ba7fe480e95a3455b1adc992ce (diff)
downloadffmpeg-7f3d39b21f893145dcfd33abf6f6a2c994b246ec.tar.gz
avcodec/pnm_parser: Support concatenated ASCII images
Fixes: Timeout (8sec -> 0.1sec) Fixes: 13864/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_PAM_fuzzer-5737860621139968 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
Diffstat (limited to 'libavcodec')
-rw-r--r--libavcodec/pnm_parser.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/libavcodec/pnm_parser.c b/libavcodec/pnm_parser.c
index 9bf1fdcece..e3bfa3c490 100644
--- a/libavcodec/pnm_parser.c
+++ b/libavcodec/pnm_parser.c
@@ -60,7 +60,22 @@ retry:
}
next = END_NOT_FOUND;
} else if (pnmctx.type < 4) {
+ uint8_t *bs = pnmctx.bytestream;
+ const uint8_t *end = pnmctx.bytestream_end;
+
next = END_NOT_FOUND;
+ while (bs < end) {
+ int c = *bs++;
+ if (c == '#') {
+ while (c != '\n' && bs < end)
+ c = *bs++;
+ } else if (c == 'P') {
+ next = bs - pnmctx.bytestream_start + skip - 1;
+ if (pnmctx.bytestream_start != buf + skip)
+ next -= pc->index;
+ break;
+ }
+ }
} else {
next = pnmctx.bytestream - pnmctx.bytestream_start + skip
+ av_image_get_buffer_size(avctx->pix_fmt, avctx->width, avctx->height, 1);