[PATCH 1/7] avformat/vivo: Do not use the general expression evaluator for parsing a floating point value
Fixes: Timeout Fixes: 41564/clusterfuzz-testcase-minimized-ffmpeg_dem_VIVO_fuzzer-6309014024093696 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc> --- libavformat/vivo.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/libavformat/vivo.c b/libavformat/vivo.c index b2904cd25a7..8e819d910b7 100644 --- a/libavformat/vivo.c +++ b/libavformat/vivo.c @@ -206,11 +206,12 @@ static int vivo_read_header(AVFormatContext *s) return AVERROR_INVALIDDATA; value_used = 1; } else if (!strcmp(key, "FPS")) { - AVRational tmp; + double d; + if (sscanf(value, "%f", &d) != 1) + return AVERROR_INVALIDDATA; value_used = 1; - if (!av_parse_ratio(&tmp, value, 10000, AV_LOG_WARNING, s)) - fps = av_inv_q(tmp); + fps = av_d2q(1/d, 10000); } if (!value_used) -- 2.17.1
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc> --- tools/target_dem_fuzzer.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tools/target_dem_fuzzer.c b/tools/target_dem_fuzzer.c index 3c03c8d17c0..6ee793a28ba 100644 --- a/tools/target_dem_fuzzer.c +++ b/tools/target_dem_fuzzer.c @@ -34,6 +34,13 @@ typedef struct IOContext { int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size); +int64_t interrupt_counter; +static int interrupt_cb(void *ctx) +{ + interrupt_counter --; + return interrupt_counter < 0; +} + static void error(const char *err) { fprintf(stderr, "%s", err); @@ -160,6 +167,9 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { *strchr(extension, ',') = 0; av_strlcatf(filename, sizeof(filename), ".%s", extension); } + + interrupt_counter = bytestream2_get_le32(&gbc); + avfmt->interrupt_callback.callback = interrupt_cb; } if (!io_buffer_size || size / io_buffer_size > maxblocks) -- 2.17.1
On Sun, Dec 05, 2021 at 10:19:02PM +0100, Michael Niedermayer wrote:
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc> --- tools/target_dem_fuzzer.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
will apply [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB No human being will ever know the Truth, for even if they happen to say it by chance, they would not even known they had done so. -- Xenophanes
Fixes: Timeout Fixes: 41580/clusterfuzz-testcase-minimized-ffmpeg_dem_HLS_fuzzer-5059099224571904 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc> --- tools/target_dem_fuzzer.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tools/target_dem_fuzzer.c b/tools/target_dem_fuzzer.c index 6ee793a28ba..687989ccc89 100644 --- a/tools/target_dem_fuzzer.c +++ b/tools/target_dem_fuzzer.c @@ -172,6 +172,10 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { avfmt->interrupt_callback.callback = interrupt_cb; } + // HLS uses a loop with sleep, we thus must breakout or we timeout + if (!strcmp(fmt->name, "hls")) + interrupt_counter &= 31; + if (!io_buffer_size || size / io_buffer_size > maxblocks) io_buffer_size = size; -- 2.17.1
On Sun, Dec 05, 2021 at 10:19:03PM +0100, Michael Niedermayer wrote:
Fixes: Timeout Fixes: 41580/clusterfuzz-testcase-minimized-ffmpeg_dem_HLS_fuzzer-5059099224571904
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc> --- tools/target_dem_fuzzer.c | 4 ++++ 1 file changed, 4 insertions(+)
will apply [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB It is dangerous to be right in matters on which the established authorities are wrong. -- Voltaire
Fixes: OOM Fixes: 41595/clusterfuzz-testcase-minimized-ffmpeg_dem_FOURXM_fuzzer-6355979363549184 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc> --- libavformat/4xm.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libavformat/4xm.c b/libavformat/4xm.c index f918b1fc572..5cbae7053d8 100644 --- a/libavformat/4xm.c +++ b/libavformat/4xm.c @@ -137,7 +137,8 @@ static int parse_strk(AVFormatContext *s, return AVERROR_INVALIDDATA; track = AV_RL32(buf + 8); - if ((unsigned)track >= UINT_MAX / sizeof(AudioTrack) - 1) { + if ((unsigned)track >= UINT_MAX / sizeof(AudioTrack) - 1 || + s->max_streams && track >= s->max_streams) { av_log(s, AV_LOG_ERROR, "current_track too large\n"); return AVERROR_INVALIDDATA; } -- 2.17.1
Michael Niedermayer:
Fixes: OOM Fixes: 41595/clusterfuzz-testcase-minimized-ffmpeg_dem_FOURXM_fuzzer-6355979363549184
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc> --- libavformat/4xm.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/libavformat/4xm.c b/libavformat/4xm.c index f918b1fc572..5cbae7053d8 100644 --- a/libavformat/4xm.c +++ b/libavformat/4xm.c @@ -137,7 +137,8 @@ static int parse_strk(AVFormatContext *s, return AVERROR_INVALIDDATA;
track = AV_RL32(buf + 8); - if ((unsigned)track >= UINT_MAX / sizeof(AudioTrack) - 1) { + if ((unsigned)track >= UINT_MAX / sizeof(AudioTrack) - 1 || + s->max_streams && track >= s->max_streams) { av_log(s, AV_LOG_ERROR, "current_track too large\n"); return AVERROR_INVALIDDATA; }
Why do you treat s->max_streams == 0 as "no limit on the number of streams"? Neither the documentation nor avformat_new_stream() treat it as such. I think a better way to fix this is to stop allocating based upon track and rather allocate based upon the actual number of tracks seen (so AudioTrack needs to have a track field, but the stream_index field could be dropped). Also notice that this demuxer currently doesn't check that the track ids encountered are unique. As a result, there can be multiple AVStreams with the same id, only the last of which will return packets. Another way to limit allocations of this demuxer is to not read the whole file header into memory. - Andreas
On Mon, Dec 06, 2021 at 07:01:24PM +0100, Andreas Rheinhardt wrote:
Michael Niedermayer:
Fixes: OOM Fixes: 41595/clusterfuzz-testcase-minimized-ffmpeg_dem_FOURXM_fuzzer-6355979363549184
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc> --- libavformat/4xm.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/libavformat/4xm.c b/libavformat/4xm.c index f918b1fc572..5cbae7053d8 100644 --- a/libavformat/4xm.c +++ b/libavformat/4xm.c @@ -137,7 +137,8 @@ static int parse_strk(AVFormatContext *s, return AVERROR_INVALIDDATA;
track = AV_RL32(buf + 8); - if ((unsigned)track >= UINT_MAX / sizeof(AudioTrack) - 1) { + if ((unsigned)track >= UINT_MAX / sizeof(AudioTrack) - 1 || + s->max_streams && track >= s->max_streams) { av_log(s, AV_LOG_ERROR, "current_track too large\n"); return AVERROR_INVALIDDATA; }
Why do you treat s->max_streams == 0 as "no limit on the number of streams"? Neither the documentation nor avformat_new_stream() treat it as such.
0 was used as no limit in other cases, i did not check nor remembered that AVFormatContext.max_streams doesnt have 0 as a documented exception i will remove the 0 check
I think a better way to fix this is to stop allocating based upon track and rather allocate based upon the actual number of tracks seen (so AudioTrack needs to have a track field, but the stream_index field could be dropped).
Also notice that this demuxer currently doesn't check that the track ids
will add that
encountered are unique. As a result, there can be multiple AVStreams with the same id, only the last of which will return packets.
Another way to limit allocations of this demuxer is to not read the whole file header into memory.
Most of these files have 1 stream and an id of 0. I have found 1 file which has 7 streams, with id 0,1,2,3,4,5,6 in that order IIRC so it feels a bit overkillish to remap this around, but i surely see your argument behind this thx [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB In a rich man's house there is no place to spit but his face. -- Diogenes of Sinope
Fixes: memleak Fixes: 41596/clusterfuzz-testcase-minimized-ffmpeg_dem_MXF_fuzzer-6439060204290048 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc> --- libavformat/mxfdec.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c index c231c944c01..1d501982793 100644 --- a/libavformat/mxfdec.c +++ b/libavformat/mxfdec.c @@ -1111,6 +1111,9 @@ static int mxf_read_index_entry_array(AVIOContext *pb, MXFIndexTableSegment *seg { int i, length; + if (segment->temporal_offset_entries) + return AVERROR_INVALIDDATA; + segment->nb_index_entries = avio_rb32(pb); length = avio_rb32(pb); -- 2.17.1
sön 2021-12-05 klockan 22:19 +0100 skrev Michael Niedermayer:
Fixes: memleak Fixes: 41596/clusterfuzz-testcase-minimized-ffmpeg_dem_MXF_fuzzer- 6439060204290048
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc> --- libavformat/mxfdec.c | 3 +++ 1 file changed, 3 insertions(+)
diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c index c231c944c01..1d501982793 100644 --- a/libavformat/mxfdec.c +++ b/libavformat/mxfdec.c @@ -1111,6 +1111,9 @@ static int mxf_read_index_entry_array(AVIOContext *pb, MXFIndexTableSegment *seg { int i, length; + if (segment->temporal_offset_entries) + return AVERROR_INVALIDDATA; + segment->nb_index_entries = avio_rb32(pb); length = avio_rb32(pb);
Should be OK. Not sure if the spec allows multiple IndexEntryArrays per index table, but this at least shouldn't break anything since it wouldn't have been working correctly before either way. /Tomas
On Wed, Dec 08, 2021 at 12:41:43AM +0100, Tomas Härdin wrote:
sön 2021-12-05 klockan 22:19 +0100 skrev Michael Niedermayer:
Fixes: memleak Fixes: 41596/clusterfuzz-testcase-minimized-ffmpeg_dem_MXF_fuzzer- 6439060204290048
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc> --- libavformat/mxfdec.c | 3 +++ 1 file changed, 3 insertions(+)
diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c index c231c944c01..1d501982793 100644 --- a/libavformat/mxfdec.c +++ b/libavformat/mxfdec.c @@ -1111,6 +1111,9 @@ static int mxf_read_index_entry_array(AVIOContext *pb, MXFIndexTableSegment *seg { int i, length; + if (segment->temporal_offset_entries) + return AVERROR_INVALIDDATA; + segment->nb_index_entries = avio_rb32(pb); length = avio_rb32(pb);
Should be OK. Not sure if the spec allows multiple IndexEntryArrays per index table, but this at least shouldn't break anything since it wouldn't have been working correctly before either way.
will apply thx [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB If you drop bombs on a foreign country and kill a hundred thousand innocent people, expect your government to call the consequence "unprovoked inhuman terrorist attacks" and use it to justify dropping more bombs and killing more people. The technology changed, the idea is old.
Fixes: Timeout Fixes: 42035/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_GEM_fuzzer-5033604191748096 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc> --- tools/target_dec_fuzzer.c | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/target_dec_fuzzer.c b/tools/target_dec_fuzzer.c index b862d7a3a41..0c59242e3e4 100644 --- a/tools/target_dec_fuzzer.c +++ b/tools/target_dec_fuzzer.c @@ -166,6 +166,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { case AV_CODEC_ID_FLAC: maxsamples /= 1024; break; case AV_CODEC_ID_FLV1: maxpixels /= 1024; break; case AV_CODEC_ID_G2M: maxpixels /= 1024; break; + case AV_CODEC_ID_GEM: maxpixels /= 512; break; case AV_CODEC_ID_GDV: maxpixels /= 512; break; case AV_CODEC_ID_GIF: maxpixels /= 16; break; case AV_CODEC_ID_H264: maxpixels /= 256; break; -- 2.17.1
On Sun, Dec 05, 2021 at 10:19:06PM +0100, Michael Niedermayer wrote:
Fixes: Timeout Fixes: 42035/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_GEM_fuzzer-5033604191748096
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc> --- tools/target_dec_fuzzer.c | 1 + 1 file changed, 1 insertion(+)
will apply [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB If the United States is serious about tackling the national security threats related to an insecure 5G network, it needs to rethink the extent to which it values corporate profits and government espionage over security.-Bruce Schneier
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc> --- libavcodec/gemdec.c | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/libavcodec/gemdec.c b/libavcodec/gemdec.c index eee21a50d4b..fd14b22390c 100644 --- a/libavcodec/gemdec.c +++ b/libavcodec/gemdec.c @@ -157,10 +157,22 @@ static int gem_decode_frame(AVCodecContext *avctx, if (header_size >= 11) tag = bytestream2_peek_be32(&gb); - if (tag == AV_RB32("STTT") || tag == AV_RB32("TIMG") || tag == AV_RB32("XIMG") || - planes == 1 || planes == 2 || planes == 3 || planes == 4 || - planes == 8 || planes == 16 || planes == 24) { - } else { + if (tag == AV_RB32("STTT")) { + if (planes != 4) { + avpriv_request_sample(avctx, "STTT planes=%d", planes); + return AVERROR_PATCHWELCOME; + } + } else if (tag == AV_RB32("TIMG")) { + if (planes != 15) { + avpriv_request_sample(avctx, "TIMG planes=%d", planes); + return AVERROR_PATCHWELCOME; + } + } else if (tag == AV_RB32("XIMG")) { + if (planes != 1 && planes != 2 && planes != 4 && planes != 8 && planes != 16 && planes != 24 && planes != 32) { + avpriv_request_sample(avctx, "XIMG planes=%d", planes); + return AVERROR_PATCHWELCOME; + } + } else if (planes != 1 && planes != 2 && planes != 3 && planes != 4 && planes != 8 && planes != 16 && planes != 24) { avpriv_request_sample(avctx, "planes=%d", planes); return AVERROR_PATCHWELCOME; } @@ -184,14 +196,12 @@ static int gem_decode_frame(AVCodecContext *avctx, palette[i] = 0xFF000000 | r << 16 | g << 8 | b; } } else { - avpriv_request_sample(avctx, "STTT planes=%d", planes); - return AVERROR_PATCHWELCOME; + av_assert0(0); } } else if (tag == AV_RB32("TIMG")) { bytestream2_skip(&gb, 4); if (planes != 15) { - avpriv_request_sample(avctx, "TIMG planes=%d", planes); - return AVERROR_PATCHWELCOME; + av_assert0(0); } } else if (tag == AV_RB32("XIMG")) { bytestream2_skip(&gb, 6); @@ -215,8 +225,7 @@ static int gem_decode_frame(AVCodecContext *avctx, row_width = avctx->width * pixel_size; put_lines = put_lines_bytes; } else { - avpriv_request_sample(avctx, "XIMG planes=%d", planes); - return AVERROR_PATCHWELCOME; + av_assert0(0); } } else if (planes == 1) { palette[0] = 0xFFFFFFFF; @@ -244,7 +253,8 @@ static int gem_decode_frame(AVCodecContext *avctx, planes = 1; row_width = avctx->width * pixel_size; put_lines = put_lines_bytes; - } + } else + av_assert0(0); ret = av_reallocp_array(&avctx->priv_data, planes, row_width); if (ret < 0) -- 2.17.1
On Sun, Dec 05, 2021 at 10:19:07PM +0100, Michael Niedermayer wrote:
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc> --- libavcodec/gemdec.c | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-)
diff --git a/libavcodec/gemdec.c b/libavcodec/gemdec.c index eee21a50d4b..fd14b22390c 100644 --- a/libavcodec/gemdec.c +++ b/libavcodec/gemdec.c @@ -157,10 +157,22 @@ static int gem_decode_frame(AVCodecContext *avctx, if (header_size >= 11) tag = bytestream2_peek_be32(&gb);
- if (tag == AV_RB32("STTT") || tag == AV_RB32("TIMG") || tag == AV_RB32("XIMG") || - planes == 1 || planes == 2 || planes == 3 || planes == 4 || - planes == 8 || planes == 16 || planes == 24) { - } else { + if (tag == AV_RB32("STTT")) { + if (planes != 4) { + avpriv_request_sample(avctx, "STTT planes=%d", planes); + return AVERROR_PATCHWELCOME; + } + } else if (tag == AV_RB32("TIMG")) { + if (planes != 15) { + avpriv_request_sample(avctx, "TIMG planes=%d", planes); + return AVERROR_PATCHWELCOME; + } + } else if (tag == AV_RB32("XIMG")) { + if (planes != 1 && planes != 2 && planes != 4 && planes != 8 && planes != 16 && planes != 24 && planes != 32) { + avpriv_request_sample(avctx, "XIMG planes=%d", planes); + return AVERROR_PATCHWELCOME; + } + } else if (planes != 1 && planes != 2 && planes != 3 && planes != 4 && planes != 8 && planes != 16 && planes != 24) { avpriv_request_sample(avctx, "planes=%d", planes); return AVERROR_PATCHWELCOME; } @@ -184,14 +196,12 @@ static int gem_decode_frame(AVCodecContext *avctx, palette[i] = 0xFF000000 | r << 16 | g << 8 | b; } } else { - avpriv_request_sample(avctx, "STTT planes=%d", planes); - return AVERROR_PATCHWELCOME; + av_assert0(0); } } else if (tag == AV_RB32("TIMG")) { bytestream2_skip(&gb, 4); if (planes != 15) { - avpriv_request_sample(avctx, "TIMG planes=%d", planes); - return AVERROR_PATCHWELCOME; + av_assert0(0); } } else if (tag == AV_RB32("XIMG")) { bytestream2_skip(&gb, 6); @@ -215,8 +225,7 @@ static int gem_decode_frame(AVCodecContext *avctx, row_width = avctx->width * pixel_size; put_lines = put_lines_bytes; } else { - avpriv_request_sample(avctx, "XIMG planes=%d", planes); - return AVERROR_PATCHWELCOME; + av_assert0(0); } } else if (planes == 1) { palette[0] = 0xFFFFFFFF; @@ -244,7 +253,8 @@ static int gem_decode_frame(AVCodecContext *avctx, planes = 1; row_width = avctx->width * pixel_size; put_lines = put_lines_bytes; - } + } else + av_assert0(0);
ret = av_reallocp_array(&avctx->priv_data, planes, row_width); if (ret < 0) -- 2.17.1
please apply -- Peter (A907 E02F A6E5 0CD2 34CD 20D2 6760 79C5 AC40 DD6B)
On Mon, Dec 06, 2021 at 06:44:00PM +1100, Peter Ross wrote:
On Sun, Dec 05, 2021 at 10:19:07PM +0100, Michael Niedermayer wrote:
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc> --- libavcodec/gemdec.c | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-)
diff --git a/libavcodec/gemdec.c b/libavcodec/gemdec.c index eee21a50d4b..fd14b22390c 100644 --- a/libavcodec/gemdec.c +++ b/libavcodec/gemdec.c @@ -157,10 +157,22 @@ static int gem_decode_frame(AVCodecContext *avctx, if (header_size >= 11) tag = bytestream2_peek_be32(&gb);
- if (tag == AV_RB32("STTT") || tag == AV_RB32("TIMG") || tag == AV_RB32("XIMG") || - planes == 1 || planes == 2 || planes == 3 || planes == 4 || - planes == 8 || planes == 16 || planes == 24) { - } else { + if (tag == AV_RB32("STTT")) { + if (planes != 4) { + avpriv_request_sample(avctx, "STTT planes=%d", planes); + return AVERROR_PATCHWELCOME; + } + } else if (tag == AV_RB32("TIMG")) { + if (planes != 15) { + avpriv_request_sample(avctx, "TIMG planes=%d", planes); + return AVERROR_PATCHWELCOME; + } + } else if (tag == AV_RB32("XIMG")) { + if (planes != 1 && planes != 2 && planes != 4 && planes != 8 && planes != 16 && planes != 24 && planes != 32) { + avpriv_request_sample(avctx, "XIMG planes=%d", planes); + return AVERROR_PATCHWELCOME; + } + } else if (planes != 1 && planes != 2 && planes != 3 && planes != 4 && planes != 8 && planes != 16 && planes != 24) { avpriv_request_sample(avctx, "planes=%d", planes); return AVERROR_PATCHWELCOME; } @@ -184,14 +196,12 @@ static int gem_decode_frame(AVCodecContext *avctx, palette[i] = 0xFF000000 | r << 16 | g << 8 | b; } } else { - avpriv_request_sample(avctx, "STTT planes=%d", planes); - return AVERROR_PATCHWELCOME; + av_assert0(0); } } else if (tag == AV_RB32("TIMG")) { bytestream2_skip(&gb, 4); if (planes != 15) { - avpriv_request_sample(avctx, "TIMG planes=%d", planes); - return AVERROR_PATCHWELCOME; + av_assert0(0); } } else if (tag == AV_RB32("XIMG")) { bytestream2_skip(&gb, 6); @@ -215,8 +225,7 @@ static int gem_decode_frame(AVCodecContext *avctx, row_width = avctx->width * pixel_size; put_lines = put_lines_bytes; } else { - avpriv_request_sample(avctx, "XIMG planes=%d", planes); - return AVERROR_PATCHWELCOME; + av_assert0(0); } } else if (planes == 1) { palette[0] = 0xFFFFFFFF; @@ -244,7 +253,8 @@ static int gem_decode_frame(AVCodecContext *avctx, planes = 1; row_width = avctx->width * pixel_size; put_lines = put_lines_bytes; - } + } else + av_assert0(0);
ret = av_reallocp_array(&avctx->priv_data, planes, row_width); if (ret < 0) -- 2.17.1
please apply
will apply thx [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB In a rich man's house there is no place to spit but his face. -- Diogenes of Sinope
Quoting Michael Niedermayer (2021-12-05 22:19:01)
Fixes: Timeout Fixes: 41564/clusterfuzz-testcase-minimized-ffmpeg_dem_VIVO_fuzzer-6309014024093696
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc> --- libavformat/vivo.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/libavformat/vivo.c b/libavformat/vivo.c index b2904cd25a7..8e819d910b7 100644 --- a/libavformat/vivo.c +++ b/libavformat/vivo.c @@ -206,11 +206,12 @@ static int vivo_read_header(AVFormatContext *s) return AVERROR_INVALIDDATA; value_used = 1; } else if (!strcmp(key, "FPS")) { - AVRational tmp; + double d; + if (sscanf(value, "%f", &d) != 1) + return AVERROR_INVALIDDATA;
value_used = 1; - if (!av_parse_ratio(&tmp, value, 10000, AV_LOG_WARNING, s)) - fps = av_inv_q(tmp); + fps = av_d2q(1/d, 10000); }
if (!value_used) -- 2.17.1
Won't this be inexact? You might also skip parsing the field if the relevant key has already been seen. -- Anton Khirnov
On Mon, Dec 06, 2021 at 10:25:01AM +0100, Anton Khirnov wrote:
Quoting Michael Niedermayer (2021-12-05 22:19:01)
Fixes: Timeout Fixes: 41564/clusterfuzz-testcase-minimized-ffmpeg_dem_VIVO_fuzzer-6309014024093696
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc> --- libavformat/vivo.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/libavformat/vivo.c b/libavformat/vivo.c index b2904cd25a7..8e819d910b7 100644 --- a/libavformat/vivo.c +++ b/libavformat/vivo.c @@ -206,11 +206,12 @@ static int vivo_read_header(AVFormatContext *s) return AVERROR_INVALIDDATA; value_used = 1; } else if (!strcmp(key, "FPS")) { - AVRational tmp; + double d; + if (sscanf(value, "%f", &d) != 1) + return AVERROR_INVALIDDATA;
value_used = 1; - if (!av_parse_ratio(&tmp, value, 10000, AV_LOG_WARNING, s)) - fps = av_inv_q(tmp); + fps = av_d2q(1/d, 10000); }
if (!value_used) -- 2.17.1
Won't this be inexact?
you mean the 1/d or in general ? the code before used av_expr_parse_and_eval() in av_parse_ratio() so was using floating point already. The 1/d could be done in AVRational if you prefer? The intermediate is inexact, the end result i would expect to be exact as it should be the "closest" fraction with num and den below 10000 we also could do the whole without floating point. The actual fields all where of the format AB.XY so 2 digits after the decimal dot. if it was always that then its very easy to parse. But if some oddball 3E1 or .99 something turns up that could add bugs for little gain
You might also skip parsing the field if the relevant key has already been seen.
yes, but it didnt do that before, ill add a seperate patch for that thx [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Those who are best at talking, realize last or never when they are wrong.
Quoting Michael Niedermayer (2021-12-06 11:35:50)
On Mon, Dec 06, 2021 at 10:25:01AM +0100, Anton Khirnov wrote:
Quoting Michael Niedermayer (2021-12-05 22:19:01)
Fixes: Timeout Fixes: 41564/clusterfuzz-testcase-minimized-ffmpeg_dem_VIVO_fuzzer-6309014024093696
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc> --- libavformat/vivo.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/libavformat/vivo.c b/libavformat/vivo.c index b2904cd25a7..8e819d910b7 100644 --- a/libavformat/vivo.c +++ b/libavformat/vivo.c @@ -206,11 +206,12 @@ static int vivo_read_header(AVFormatContext *s) return AVERROR_INVALIDDATA; value_used = 1; } else if (!strcmp(key, "FPS")) { - AVRational tmp; + double d; + if (sscanf(value, "%f", &d) != 1) + return AVERROR_INVALIDDATA;
value_used = 1; - if (!av_parse_ratio(&tmp, value, 10000, AV_LOG_WARNING, s)) - fps = av_inv_q(tmp); + fps = av_d2q(1/d, 10000); }
if (!value_used) -- 2.17.1
Won't this be inexact?
you mean the 1/d or in general ? the code before used av_expr_parse_and_eval() in av_parse_ratio() so was using floating point already. The 1/d could be done in AVRational if you prefer? The intermediate is inexact, the end result i would expect to be exact as it should be the "closest" fraction with num and den below 10000
we also could do the whole without floating point. The actual fields all where of the format AB.XY so 2 digits after the decimal dot. if it was always that then its very easy to parse. But if some oddball 3E1 or .99 something turns up that could add bugs for little gain
I mean involving floats at all. If that's already the case, then I don't object to the patch (though it would be nice to know if it is in fact fixed point and parse it as such). -- Anton Khirnov
On 5 Dec 2021, at 22:19, Michael Niedermayer wrote:
Fixes: Timeout Fixes: 41564/clusterfuzz-testcase-minimized-ffmpeg_dem_VIVO_fuzzer-6309014024093696
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc> --- libavformat/vivo.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/libavformat/vivo.c b/libavformat/vivo.c index b2904cd25a7..8e819d910b7 100644 --- a/libavformat/vivo.c +++ b/libavformat/vivo.c @@ -206,11 +206,12 @@ static int vivo_read_header(AVFormatContext *s) return AVERROR_INVALIDDATA; value_used = 1; } else if (!strcmp(key, "FPS")) { - AVRational tmp; + double d; + if (sscanf(value, "%f", &d) != 1) + return AVERROR_INVALIDDATA;
Shouldn't this use av_sscanf, so it's not locale dependent?
value_used = 1; - if (!av_parse_ratio(&tmp, value, 10000, AV_LOG_WARNING, s)) - fps = av_inv_q(tmp); + fps = av_d2q(1/d, 10000); }
if (!value_used) -- 2.17.1
_______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
participants (6)
-
Andreas Rheinhardt -
Anton Khirnov -
Marvin Scholz -
Michael Niedermayer -
Peter Ross -
Tomas Härdin