diff options
author | Michael Niedermayer <michael@niedermayer.cc> | 2019-08-01 22:20:48 +0200 |
---|---|---|
committer | Michael Niedermayer <michael@niedermayer.cc> | 2019-08-23 22:26:50 +0200 |
commit | 34f6d1a7d7859310914d7f34e8cc3b68d6254003 (patch) | |
tree | 33cf26053087f215e57a121f4ac9c4985ccddaa6 /libavcodec/pnm_parser.c | |
parent | 8a24d2cc304c7f0807bc472dfc39d247040d71c2 (diff) | |
download | ffmpeg-34f6d1a7d7859310914d7f34e8cc3b68d6254003.tar.gz |
avcodec/pnm_parser: Use memmove() to handle "overread"
This is significantly faster
Fixes: Timeout (1sec after this and the previous commit)
Fixes: 15558/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_PPM_fuzzer-5705273643106304
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/pnm_parser.c')
-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..94777d2cca 100644 --- a/libavcodec/pnm_parser.c +++ b/libavcodec/pnm_parser.c @@ -41,8 +41,11 @@ static int pnm_parse(AVCodecParserContext *s, AVCodecContext *avctx, int next = END_NOT_FOUND; int skip = 0; - for (; pc->overread > 0; pc->overread--) { - pc->buffer[pc->index++]= pc->buffer[pc->overread_index++]; + if (pc->overread > 0) { + memmove(pc->buffer + pc->index, pc->buffer + pc->overread_index, pc->overread); + pc->index += pc->overread; + pc->overread_index += pc->overread; + pc->overread = 0; } if (pnmpc->remaining_bytes) { |