Skip to content

Commit

Permalink
avcodec/pnm_parser: Use memchr() in pnm_parse()
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
michaelni committed Sep 10, 2019
1 parent b794df4 commit 10ea6c3
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions libavcodec/pnm_parser.c
Expand Up @@ -95,8 +95,11 @@ static int pnm_parse(AVCodecParserContext *s, AVCodecContext *avctx,
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;
Expand Down

0 comments on commit 10ea6c3

Please sign in to comment.