aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Niedermayer <michael@niedermayer.cc>2020-03-19 22:05:42 +0100
committerMichael Niedermayer <michael@niedermayer.cc>2020-05-21 15:32:28 +0200
commit209b42916869e78fc67f386fdebbe903ca8dbd72 (patch)
treeabbad3735a307e493a100ca3c0c588684f5172cc
parentab9074c1c3fc5179f153743d869b33a7623d738b (diff)
downloadffmpeg-209b42916869e78fc67f386fdebbe903ca8dbd72.tar.gz
avcodec/cbs_jpeg: Fix infinite loop in cbs_jpeg_split_fragment()
Fixes: Timeout Fixes: 21104/clusterfuzz-testcase-minimized-ffmpeg_BSF_TRACE_HEADERS_fuzzer-5129580475318272 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc> (cherry picked from commit a3dc67c9840f6ba6cdf6233248897146e9171cc8) Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
-rw-r--r--libavcodec/cbs_jpeg.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/libavcodec/cbs_jpeg.c b/libavcodec/cbs_jpeg.c
index e26acdaff0..6e48b581f1 100644
--- a/libavcodec/cbs_jpeg.c
+++ b/libavcodec/cbs_jpeg.c
@@ -148,15 +148,14 @@ static int cbs_jpeg_split_fragment(CodedBitstreamContext *ctx,
if (marker == JPEG_MARKER_EOI) {
break;
} else if (marker == JPEG_MARKER_SOS) {
+ next_marker = -1;
for (i = start; i + 1 < frag->data_size; i++) {
if (frag->data[i] != 0xff)
continue;
end = i;
for (++i; i + 1 < frag->data_size &&
frag->data[i] == 0xff; i++);
- if (i + 1 >= frag->data_size) {
- next_marker = -1;
- } else {
+ if (i + 1 < frag->data_size) {
if (frag->data[i] == 0x00)
continue;
next_marker = frag->data[i];