aboutsummaryrefslogtreecommitdiffstats
path: root/libavformat/utils.c
Commit message (Collapse)AuthorAgeFilesLines
* avformat/utils: Fix invalid NULL pointer operation in ff_parse_key_value()Michael Niedermayer2022-04-061-1/+1
| | | | | | | | | | Fixes: pointer index expression with base 0x000000000000 overflowed to 0xffffffffffffffff Fixes: 44012/clusterfuzz-testcase-minimized-ffmpeg_dem_HLS_fuzzer-5670607746891776 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 59328aabd2c789ae053e18a62a20a7addfd4d069) Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avformat/utils: Ignore negative duration in codec_info_duration computationMichael Niedermayer2021-10-051-1/+1
| | | | | | | | | | Fixes: signed integer overflow: -5994697211974418462 + -3255307777713450286 cannot be represented in type 'long' Fixes: 35332/clusterfuzz-testcase-minimized-ffmpeg_dem_MATROSKA_fuzzer-5868035117285376 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 4d81550df9580b454d2530bcb37de20b8354ad6e) Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avformat/utils: Avoid overflow in codec_info_duration computation for subtitlesMichael Niedermayer2021-06-181-1/+3
| | | | | | | | | | Fixes: signed integer overflow: 9223126845747118112 - -2594073385365397472 cannot be represented in type 'long' Fixes: 34936/clusterfuzz-testcase-minimized-ffmpeg_dem_MATROSKA_fuzzer-6739888002170880 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 ffe4851e2359e17c4406ab05e2e31fc7ef68de95) Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avformat/utils: check dts/duration to be representable before using themMichael Niedermayer2021-06-181-1/+3
| | | | | | | | | | Fixes: signed integer overflow: 6854513951393103890 + 3427256975738527712 cannot be represented in type 'long' Fixes: 32936/clusterfuzz-testcase-minimized-ffmpeg_dem_R3D_fuzzer-5236914752978944 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 bf4e7ec8257fd24a12327c7fa14e322028250be4) Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avformat/utils: Use 64bit earlier in r_frame_rate checkMichael Niedermayer2021-06-181-1/+1
| | | | | | | | | | Fixes: signed integer overflow: 1406796319 * 2 cannot be represented in type 'int' Fixes: 32777/clusterfuzz-testcase-minimized-ffmpeg_IO_DEMUXER_fuzzer-5632576913014784 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 578633fc1ac8c02a36a706bd71f775550412d1e1) Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avformat/utils: Check allocations for failureAndreas Rheinhardt2021-04-021-4/+12
| | | | | | | There would be leaks in case of failure. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com> (cherry picked from commit 543e4a194252050cf1abcded7c75e4b889e3db4f)
* avformat/utils: Extend overflow check in dts wrap in compute_pkt_fields()Michael Niedermayer2021-04-011-1/+1
| | | | | | | | | | Fixes: signed integer overflow: -9223372032574480351 - 4294967296 cannot be represented in type 'long long' Fixes: 30022/clusterfuzz-testcase-minimized-ffmpeg_dem_KUX_fuzzer-5568610275819520 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 b37ff29e0e093b15585e9fb44bbd82bdf14b5230) Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avformat/utils: Fix integer overflow with duration_gcd in ff_rfps_calculate()Michael Niedermayer2021-04-011-1/+2
| | | | | | | | | | Fixes: signed integer overflow: 136323327 * 281474976710656 cannot be represented in type 'long' Fixes: 30913/clusterfuzz-testcase-minimized-ffmpeg_dem_IVF_fuzzer-5753392189931520 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 6dc6e1cce0ec0aadab27e8b3fd3fc87c93c3acd6) Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* Revert "lavf: move AVStream.*index_entries* to AVStreamInternal"James Almer2021-03-231-23/+23
| | | | | | | This reverts commit cea7c19cda0ea1630ae1de8c102ab14231b9db10. Until an API is added to make index_entries public in a proper way, keeping this here is harmless.
* avformat: Make AVChapter.id an int64_t on next major bumpAndreas Rheinhardt2021-03-191-0/+4
| | | | | | | | | 64 bits are needed in order to retain the uid values of Matroska chapters; the type is kept signed because the semantics of NUT chapters depend upon whether the id is > 0 or < 0. Reviewed-by: Anton Khirnov <anton@khirnov.net> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avformat/utils: use av_packet_alloc() to allocate packetsJames Almer2021-03-171-43/+57
| | | | Signed-off-by: James Almer <jamrial@gmail.com>
* avformat/mux: use av_packet_alloc() to allocate packetsJames Almer2021-03-171-0/+1
| | | | Signed-off-by: James Almer <jamrial@gmail.com>
* avcodec/packet_internal: make avpriv_packet_list_* functions use an internal ↵James Almer2021-03-171-7/+7
| | | | | | | | | struct The next pointer is kept at the end for backwards compatability until the major bump, when it should ideally be moved at the front. Signed-off-by: James Almer <jamrial@gmail.com>
* avformat: use the buffer_size_t typedef where requiredJames Almer2021-03-101-1/+1
| | | | Signed-off-by: James Almer <jamrial@gmail.com>
* avformat/utils: change AVStream side data related public function and struct ↵James Almer2021-03-101-2/+2
| | | | | | | | | size types to size_t av_stream_add_side_data() already defines size as a size_t, so this makes it consistent across all side data functions. Signed-off-by: James Almer <jamrial@gmail.com>
* avformat: Deprecate AVFMT_FLAG_PRIV_OPT, remove av_demuxer_open on bumpAndreas Rheinhardt2021-03-031-2/+10
| | | | | | | | | | | | | | | | | | | | | | | This flag was added in 492026209b9b58eaf6d2ea56423f6b1e1a8a76a5 in conjunction with av_demuxer_open() to allow to pass private options to demuxers. It worked as follows: av_open_input_stream() (the predecessor of avformat_open_input()) would not call the read_header function if this flag is set. Instead the user could set private options of the demuxer via the format's private class after avformat_open_input() and then call av_demuxer_open() which called the format's read_header function. This approach was abandoned in e37f161e66e042d6c2c7470c4d9881df9427fc4a and av_demuxer_open() deprecated; instead the AVDictionary based way of passing private options to the demuxer was choosen. Yet AVFMT_FLAG_PRIV_OPT has never been deprecated and av_demuxer_open() never removed. This commit implements the deprecation of the flag and schedules av_demuxer_open for removal on the next major bump. Given that av_demuxer_open() has been deprecated in 2012 and that this flag is useless without it, the flag will be ignored after the next major version bump. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avcodec: remove pointless lowres deprecation wrappersJames Almer2021-02-221-2/+0
| | | | | | | | Neither the feature, public fields, or AVOptions were ever truly deprecated, nor will have been removed if this FF_API_ define was left in place, so get rid of it as it's misleading. Signed-off-by: James Almer <jamrial@gmail.com>
* avformat/utils: Add av_assert1 to preclude NULL + len, len != 0Andreas Rheinhardt2021-02-151-0/+1
| | | | | | | | | Such a scenario is undefined behaviour and would also indicate a bug in our code. Suggested-by: James Almer <jamrial@gmail.com> Reviewed-by: James Almer <jamrial@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avformat/utils: Fix undefined NULL + 0Andreas Rheinhardt2021-02-141-1/+1
| | | | | | | | | | | This is undefined behaviour in C, so use data = len ? data + len : data instead of data += len. GCC optimizes the branch away in this case; Clang unfortunately doesn't. Fixes ticket #8592. Reviewed-by: Paul B Mahol <onemda@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avformat/utils: force lowres to 0 in avformat_find_stream_info()James Almer2021-02-131-9/+8
| | | | | | Instead of applying it and then restoring the original codecpar dimensions. Signed-off-by: James Almer <jamrial@gmail.com>
* avformat/utils: Use av_sat_sub64() in max_analyze_duration checkMichael Niedermayer2021-01-291-2/+4
| | | | | | | | Fixes: signed integer overflow: 9223372036854710272 - -541165944832 cannot be represented in type 'long' Fixes: 27000/clusterfuzz-testcase-minimized-ffmpeg_dem_IVF_fuzzer-5643670608674816 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avformat: Change avpriv_new_chapter() from O(n) to (1) in the common caseMichael Niedermayer2021-01-281-3/+8
| | | | | | | | Fixes: timeout (slow -> 300ms) Fixes: 28876/clusterfuzz-testcase-minimized-ffmpeg_dem_MOV_fuzzer-5664824587583488 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avformat/utils: Check dts in update_initial_timestamps() moreMichael Niedermayer2021-01-261-0/+1
| | | | | | | | Fixes: signed integer overflow: -9223372036853488158 - 90000000 cannot be represented in type 'long long' Fixes: 26910/clusterfuzz-testcase-minimized-ffmpeg_dem_MPSUB_fuzzer-6696625298866176 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avformat/utils: Check dts - (1<<pts_wrap_bits) overflowMichael Niedermayer2021-01-231-1/+1
| | | | | | | | Fixes: signed integer overflow: -9223372036842389247 - 2147483648 cannot be represented in type 'long long' Fixes: 26910/clusterfuzz-testcase-minimized-ffmpeg_dem_FLV_fuzzer-4845007531671552 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* libavformat/utils: consider avio_size() failure in ffio_limit()Michael Niedermayer2021-01-211-3/+6
| | | | | | | | Fixes: Timeout (>20sec -> 3ms) Fixes: 26918/clusterfuzz-testcase-minimized-ffmpeg_dem_THP_fuzzer-5750425191710720 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avformat/utils: check for integer overflow in av_get_frame_filename2()Michael Niedermayer2021-01-201-1/+4
| | | | | | | | Fixes: signed integer overflow: 317316873 * 10 cannot be represented in type 'int' Fixes: 24708/clusterfuzz-testcase-minimized-ffmpeg_DEMUXER_fuzzer-5731180885049344 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avformat/utils: wrap_timestamp() is only needed for less than 64 bitsMichael Niedermayer2021-01-111-1/+1
| | | | | | | | | Fixes: shift exponent 64 is too large for 64-bit type 'unsigned long long' Fixes: 26497/clusterfuzz-testcase-minimized-ffmpeg_dem_AVI_fuzzer-5690188355076096 Fixes: 26903/clusterfuzz-testcase-minimized-ffmpeg_dem_LUODAT_fuzzer-5641466929741824 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avformat/utils: do not overwrite already existing program with defaults in ↵Marton Balint2021-01-091-7/+5
| | | | | | | | | av_new_program av_new_program returns the existing program if that already exists, in that case it makes no sense to overwrite existing attributes. Signed-off-by: Marton Balint <cus@passwd.hu>
* avformat/utils: Change compute_chapters_end() from O(n²) to O(n log n)Michael Niedermayer2021-01-081-11/+33
| | | | | | | | Fixes: Timeout (49sec -> 9sec) Fixes: 27427/clusterfuzz-testcase-minimized-ffmpeg_dem_FFMETADATA_fuzzer-5140589838073856 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* Mark some pointers as constAndreas Rheinhardt2021-01-011-1/+1
| | | | | Reviewed-by: Lynne <dev@lynne.ee> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avformat/utils: Improve ffio_limit logicAndreas Rheinhardt2020-12-111-3/+5
| | | | | | | | | | | | | | | The earlier code would not complain if the remaining size was one byte short of the desired size; and the way it performed the check could run into signed integer overflow. Fixes: signed integer overflow: 9223372036854775807 + 1 cannot be represented in type 'long' Fixes: Timeout Fixes: 26434/clusterfuzz-testcase-minimized-ffmpeg_dem_MV_fuzzer-5752845451919360 Fixes: 26444/clusterfuzz-testcase-minimized-ffmpeg_dem_BINK_fuzzer-4697773380993024 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Reviewed-by: Michael Niedermayer <michael@niedermayer.cc> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* lavf: move AVStream.probe_data to AVStreamInternalAnton Khirnov2020-10-281-2/+3
| | | | | Those are private fields, no reason to have them exposed in a public header.
* lavf: move AVStream.pts_buffer to AVStreamInternalAnton Khirnov2020-10-281-7/+7
| | | | | Those are private fields, no reason to have them exposed in a public header.
* lavf: move AVStream.*index_entries* to AVStreamInternalAnton Khirnov2020-10-281-23/+23
| | | | | | | Those are private fields, no reason to have them exposed in a public header. Since there are some (semi-)public fields located after these, even though this section is supposed to be private, keep some dummy padding there until the next major bump to preserve ABI compatibility.
* lavf: move AVStream.{request_probe,skip_to_keyframe} to AVStreamInternalAnton Khirnov2020-10-281-12/+12
| | | | | Those are private fields, no reason to have them exposed in a public header.
* lavf: move AVStream.{*skip_samples.*_discard_sample} to AVStreamInternalAnton Khirnov2020-10-281-13/+13
| | | | | Those are private fields, no reason to have them exposed in a public header.
* lavf: move AVStream.{nb_decoded_frames,mux_ts_offset} to AVStreamInternalAnton Khirnov2020-10-281-5/+5
| | | | | Those are private fields, no reason to have them exposed in a public header.
* lavf: move AVStream.{pts_wrap_*,update_initial_durations_done} to ↵Anton Khirnov2020-10-281-19/+19
| | | | | | | AVStreamInternal Those are private fields, no reason to have them exposed in a public header.
* lavf: move AVStream.pts_reorder_error[_count] to AVStreamInternalAnton Khirnov2020-10-281-9/+9
| | | | | Those are private fields, no reason to have them exposed in a public header.
* lavf: move AVStream.{last_dts_for_order_check,dts_[mis]ordered} to ↵Anton Khirnov2020-10-281-14/+14
| | | | | | | AVStreamInternal Those are private fields, no reason to have them exposed in a public header.
* lavf: move AVStream.{inject_global_side_data,display_aspect_ratio} to ↵Anton Khirnov2020-10-281-7/+7
| | | | | | | AVStreamInternal Those are private fields, no reason to have them exposed in a public header.
* lavf: move AVStream.info to AVStreamInternalAnton Khirnov2020-10-281-114/+114
| | | | | | | This struct is for internal use of avformat_find_stream_info(), so it should not be exposed in public headers. Keep a stub pointer in its place to avoid changing AVStream layout, since e.g. ffmpeg.c accesses some fields located after it (even though they are marked as private).
* avformat: add a stream event flag for new packetsAnton Khirnov2020-10-281-0/+2
|
* libavformat/utils: Fix misleading indentChris Miceli2020-10-201-2/+1
| | | | | | | | | 6f69f7a8bf6a0d013985578df2ef42ee6b1c7994 introduced this and it was part of a very large merging of refactoring. Current behaviour is what is reflected by this indenting change, however my understanding of timing is such that this correct behaviour. Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avformat/utils: add missing FF_API_LAVF_AVCTX checkJames Almer2020-10-011-2/+12
| | | | Signed-off-by: James Almer <jamrial@gmail.com>
* avcodec/packet: move AVPacketList definition and function helpers over from ↵James Almer2020-09-151-80/+18
| | | | | | | | | libavformat And replace the flags parameter with a function callback that can be used to copy the contents of the packet (e.g, av_packet_ref and av_packet_copy_props). Signed-off-by: James Almer <jamrial@gmail.com>
* avformat/utils: Avoid duplicating extradata from extract_extradata BSFAndreas Rheinhardt2020-09-111-15/+8
| | | | | | | | | | | | | Instead move the extradata contained in packet side-data to its destination. This is possible because the side data already has zeroed padding. Notice that the check for FF_MAX_EXTRADATA_SIZE has been dropped, because said constant is from libavcodec/internal.h. If libavcodec wanted to enforce this, it should do so in the extract_extradata BSF instead. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avformat/utils: reorder duration computation to avoid overflowMichael Niedermayer2020-07-011-1/+1
| | | | | | | | Fixes: signed integer overflow: 8 * 9223372036854774783 cannot be represented in type 'long' Fixes: 23381/clusterfuzz-testcase-minimized-ffmpeg_DEMUXER_fuzzer-4818340509122560 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avformat/utils: Print analyze duration and probesize when printing a ↵Michael Niedermayer2020-06-141-2/+2
| | | | | | suggestion to increase them Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avformat: Fix overflow in compute_pkt_fields().Dale Curtis2020-06-061-1/+1
| | | | | Signed-off-by: Dale Curtis <dalecurtis@chromium.org> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>