diff options
author | Michael Niedermayer <michael@niedermayer.cc> | 2019-09-10 00:04:08 +0200 |
---|---|---|
committer | Michael Niedermayer <michael@niedermayer.cc> | 2019-12-31 19:51:55 +0100 |
commit | 48659851e2fc6bc342f53251191c7ef9b6f008ad (patch) | |
tree | 6020785ff5ed3c5b3cd813e0b4eb9ba9b579416e | |
parent | 69be8cc6e0cd38ac03263b1a96532769e0768993 (diff) | |
download | ffmpeg-48659851e2fc6bc342f53251191c7ef9b6f008ad.tar.gz |
avcodec/pnm_parser: Use memchr() in pnm_parse()
Fixes: Timeout (45sec -> 0.5sec)
Fixes: 16942/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_PPM_fuzzer-5085393073995776
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 10ea6c3116f95fc7f79d268ee2b839eea477337c)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
-rw-r--r-- | libavcodec/pnm_parser.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/libavcodec/pnm_parser.c b/libavcodec/pnm_parser.c index 5339bebde9..58c3cd2431 100644 --- a/libavcodec/pnm_parser.c +++ b/libavcodec/pnm_parser.c @@ -92,8 +92,11 @@ retry: sync = bs; c = *bs++; if (c == '#') { - while (c != '\n' && bs < end) - c = *bs++; + uint8_t *match = memchr(bs, '\n', end-bs); + if (match) + bs = match + 1; + else + break; } else if (c == 'P') { next = bs - pnmctx.bytestream_start + skip - 1; pnmpc->ascii_scan = 0; |