Commit Graph

23147 Commits

Author SHA1 Message Date
Andreas Rheinhardt 9c341c6c92 avformat/apngdec: Fix size/overflow checks
apng data consists of parts containing a small header (including a
four-byte size field) and a data part; the size field does not account
for everything and is actually twelve bytes short of the actual size. In
order to make sure that the size fits into an int, the size field is
checked for being > INT_MAX; yet this does not account for the + 12 and
upon conversion to int (which happens when calling append_extradata()),
the size parameter can still wrap around. In this case the currently
used check would lead to undefined signed integer overflow.

Furthermore, append_extradata() appends the new data to the already
existing extradata and therefore needs to make sure that the combined
size of new and old data as well as padding fits into an int. The check
used for this is "if (old_size > INT_MAX - AV_INPUT_BUFFER_PADDING_SIZE -
new_size)". If new_size is > INT_MAX - AV_INPUT_BUFFER_PADDING_SIZE
the right side becomes negative if the types are signed (as they are
now); yet changing this to "if (new_size > INT_MAX -
AV_INPUT_BUFFER_PADDING_SIZE - old_size)" is better as this also works
for unsigned types (where it is of course presumed that INT_MAX is
replaced by the corresponding maximum for the new type).

Both of these issues have been fixed.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-11-03 14:27:25 +01:00
Andreas Rheinhardt 2cf1eefae5 avformat/apngdec: Return error for incomplete header
If avio_read() could read anything, it returns the number of bytes read,
even if it could not read as much as the caller desired.
apng_read_header() only checked the return value of its avio_read() calls
for being negative and this meant that it was possible for an incomplete
header to not be detected. The return value of the last successfull call
has been returned instead. This commit changes this.

Fixes: OOM
Fixes: 26608/clusterfuzz-testcase-minimized-ffmpeg_dem_APNG_fuzzer-4839491644424192

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-11-03 14:27:25 +01:00
Zane van Iperen 5fb628521f
avformat/argo_brp: bail if no video frames
Fixes: Assertion failure
Fixes: 26572/clusterfuzz-testcase-minimized-ffmpeg_dem_ARGO_BRP_fuzzer-5166735591997440

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: Zane van Iperen <zane@zanevaniperen.com>
2020-11-03 10:47:37 +10:00
Michael Niedermayer 2610acb49a avformat/concatdec: use av_strstart()
Fixes: out array read
Fixes: 26610/clusterfuzz-testcase-minimized-ffmpeg_dem_CONCAT_fuzzer-5631838049271808

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Reviewed-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Reviewed-by: Nicolas George <george@nsup.org>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2020-11-03 00:46:59 +01:00
Michael Niedermayer 7b2244565a avformat/wavdec: Refuse to read chunks bigger than the filesize in w64_read_header()
Fixes: OOM
Fixes: 26414/clusterfuzz-testcase-minimized-ffmpeg_dem_FWSE_fuzzer-5070632544632832
Fixes: 26475/clusterfuzz-testcase-minimized-ffmpeg_dem_W64_fuzzer-5770207722995712

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2020-10-30 17:49:51 +01:00
Michael Niedermayer c79d8a6851 avformat/rsd: Check size and start before computing duration
Fixes: signed integer overflow: 100794754 * 28 cannot be represented in type 'int'
Fixes: 26474/clusterfuzz-testcase-minimized-ffmpeg_dem_RSD_fuzzer-5181797606096896

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2020-10-30 17:49:51 +01:00
Michael Niedermayer b848baef0d avformat/vividas: better check of current_sb_entry
This is the simplest fix for the problem, it is possible to instead check
this when the variables are set and propagate errors and then fail earlier

Fixes: out of array access
Fixes: 26490/clusterfuzz-testcase-minimized-ffmpeg_dem_VIVIDAS_fuzzer-5723367078100992

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2020-10-30 17:49:51 +01:00
Michael Niedermayer 3588e2e6b0 avformat/iff: More completely check body_size
Fixes: infinite loop
Fixes: 26485/clusterfuzz-testcase-minimized-ffmpeg_dem_IFF_fuzzer-5126561373880320

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2020-10-30 17:49:51 +01:00
Michael Niedermayer d5c42b8c08 avformat/vividas use avpriv_set_pts_info()
Fixes: assertion failure
Fixes: 26482/clusterfuzz-testcase-minimized-ffmpeg_dem_VIVIDAS_fuzzer-4905102324006912
Fixes: 26491/clusterfuzz-testcase-minimized-ffmpeg_dem_VIVIDAS_fuzzer-6002953141616640

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2020-10-30 17:46:34 +01:00
Michael Niedermayer 44b18a76b8 avformat/xwma: Check for EOF in dpds_table read code
Fixes: Timeout (>30 -> 140ms)
Fixes: 26478/clusterfuzz-testcase-minimized-ffmpeg_dem_XWMA_fuzzer-5918147066200064

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2020-10-30 17:46:34 +01:00
Limin Wang be4ff0f1b2 avformat/mpegtsenc: check that not only first pts but also first dts is valid
Reviewed-by: Marton Balint <cus@passwd.hu>
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
2020-10-30 22:41:59 +08:00
Limin Wang 27e8a6c44b avformat/mpegtsenc: first_pts_check -> first_pts_checked
change to first_pts_checked and reverse the logic.

Reviewed-by: Marton Balint <cus@passwd.hu>
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
2020-10-30 22:41:59 +08:00
Andreas Rheinhardt 11ea0ed20e avformat/jacosubdec: Fix unintended fallthrough
Regression since 715ff75e5d.

Fixes Coverity issues #1468654 and #1468656.

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-10-30 14:06:19 +01:00
ruiquan.crq ae9a1a9698 lavf/url: fix relative url parsing when the query string or fragment has a colon
This disallows the usage of ? and # in libavformat specific scheme options
(e.g. subfile,,start,32815239,end,0,,:video.ts) but this change was considered
acceptable.

Signed-off-by: ruiquan.crq <caihaoning83@gmail.com>
Signed-off-by: Marton Balint <cus@passwd.hu>
2020-10-28 21:34:09 +01:00
James Almer 37d742b607 avcodec/codec2utils: move the remaining avpriv functions to lavf
They are only used by the codec2 demuxers.

The symbols are kept around until the next major bump.

Signed-off-by: James Almer <jamrial@gmail.com>
2020-10-28 11:59:35 -03:00
James Almer 7f76974e7d libavcodec/codec2utils: remove codec2_version_from_extradata()
It's only used in the codec2 demuxers, and can be simplified with an AV_RB16()
call instead.

Suggested-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Signed-off-by: James Almer <jamrial@gmail.com>
2020-10-28 11:59:16 -03:00
James Almer 3916af4d95 avcodec/codec2utils: remove avpriv prefix from inline functions
Signed-off-by: James Almer <jamrial@gmail.com>
2020-10-28 11:55:53 -03:00
Anton Khirnov 744b7f2e91 lavf: move AVStream.last_in_packet_buffer to AVStreamInternal
Those are private fields, no reason to have them exposed in a public
header.
2020-10-28 15:01:40 +01:00
Anton Khirnov 30f5180ca6 lavf: move AVStream.probe_data to AVStreamInternal
Those are private fields, no reason to have them exposed in a public
header.
2020-10-28 15:01:22 +01:00
Anton Khirnov 91a98cc4ea lavf: move AVStream.pts_buffer to AVStreamInternal
Those are private fields, no reason to have them exposed in a public
header.
2020-10-28 15:00:40 +01:00
Anton Khirnov cea7c19cda lavf: move AVStream.*index_entries* to AVStreamInternal
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.
2020-10-28 14:59:28 +01:00
Anton Khirnov 7e87288f73 lavf: move AVStream.interleaver_chunk_* to AVStreamInternal
Those are private fields, no reason to have them exposed in a public
header.
2020-10-28 14:58:28 +01:00
Anton Khirnov 108864acee lavf: move AVStream.{request_probe,skip_to_keyframe} to AVStreamInternal
Those are private fields, no reason to have them exposed in a public
header.
2020-10-28 14:57:01 +01:00
Anton Khirnov 456b170bd7 lavf: move AVStream.{*skip_samples.*_discard_sample} to AVStreamInternal
Those are private fields, no reason to have them exposed in a public
header.
2020-10-28 14:56:20 +01:00
Anton Khirnov cb46a6bcbc lavf: move AVStream.{nb_decoded_frames,mux_ts_offset} to AVStreamInternal
Those are private fields, no reason to have them exposed in a public
header.
2020-10-28 14:55:53 +01:00
Anton Khirnov 323c9a8c52 lavf: move AVStream.{pts_wrap_*,update_initial_durations_done} to AVStreamInternal
Those are private fields, no reason to have them exposed in a public
header.
2020-10-28 14:54:51 +01:00
Anton Khirnov 36d7c1dee8 lavf: move AVStream.pts_reorder_error[_count] to AVStreamInternal
Those are private fields, no reason to have them exposed in a public
header.
2020-10-28 14:54:35 +01:00
Anton Khirnov 25bade3258 lavf: move AVStream.{last_dts_for_order_check,dts_[mis]ordered} to AVStreamInternal
Those are private fields, no reason to have them exposed in a public
header.
2020-10-28 14:54:22 +01:00
Anton Khirnov c1b916580a lavf: move AVStream.{inject_global_side_data,display_aspect_ratio} to AVStreamInternal
Those are private fields, no reason to have them exposed in a public
header.
2020-10-28 14:53:45 +01:00
Anton Khirnov 8741f1fe26 lavf: move AVStream.info to AVStreamInternal
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).
2020-10-28 14:52:06 +01:00
Anton Khirnov f95d9510ff avformat: add a stream event flag for new packets 2020-10-28 13:58:29 +01:00
Anton Khirnov 48f3ed96e9 avformat: extend documentation of event_flags
Document how it is to be used for muxing (currently supported by
flvenc).
2020-10-28 13:57:38 +01:00
Anton Khirnov c515a35dde avformat: fix typo in doxy
av_read_frame() reads new packets, av_read_packet() does not exist.
2020-10-28 13:57:38 +01:00
Anton Khirnov 886c601a70 lavf/latmenc: use a local simplified copy of avpriv_copy_bits()
This is the only place in lavf where avpriv_copy_bits() is used, so this
allows us to make avpriv_copy_bits() lavc-local.
2020-10-28 13:53:23 +01:00
Anton Khirnov 2068ad5914 lavf/latmenc: fix units mismatch
avpriv_copy_bits() takes the size in bits, not bytes. According to
a736eb4a60, nobody is quite sure whether
this code produces working files.
2020-10-28 13:53:23 +01:00
Yigit Uyan c1efb1decb rtsp: increase the control uri size
Current browsers support up to 2k characters.

Signed-off-by: Anton Khirnov <anton@khirnov.net>
2020-10-28 13:53:20 +01:00
Limin Wang 6f36eb0da7 avformat/mpegtsenc: make first_pcr sync with the first valid dts
now first_pts assume dts will start from zero, if it's not true(copyts is enable),
too many null packet will be inserted for cbr output.

Please test with below command, you'll get huge test.ts without the patch:
./ffmpeg -y -copyts -i ../fate-suite/mpegts/loewe.ts  -c:v libx264 -x264opts \
   nal-hrd=cbr:force-cfr=1 -b:v 3500k -minrate 3500k -maxrate 3500k -bufsize \
   1000k  -c:a mp2 -muxrate 4500k  -vframes 1000 test.ts

Reviewed-by: Marton Balint <cus@passwd.hu>
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
2020-10-27 18:18:24 +08:00
Limin Wang f3568a33c9 avformat/mpegtsenc: use total_size instead of avio_tell()
avio_tell() fails to get the amount of data written so far when the
underlying IO context is flushed to segments.

Please test with below command:
$ ./ffmpeg  -f lavfi -i testsrc=duration=100:size=vga -c:v libx264 -x264opts \
  nal-hrd=cbr:force-cfr=1 -b:v 500k -minrate 500k -maxrate 500k -bufsize 500k \
  -f hls -hls_time 10  -hls_ts_options "muxrate=2000000" test%d.ts

$ du -h test*.ts
Before:
2.4M    test00.ts
4.8M    test11.ts
7.2M    test22.ts
9.6M    test33.ts
12M     test44.ts
...

After apply the patch:
 2.4M   test00.ts
 2.4M   test11.ts
 2.4M   test22.ts
 2.4M   test33.ts
 2.4M   test44.ts
...

Reviewed-by: Marton Balint <cus@passwd.hu>
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
2020-10-27 18:18:24 +08:00
Zane van Iperen 7a11cc29d6
avformat: add alp muxer 2020-10-25 23:44:26 +10:00
Zane van Iperen 5df7fd1cbe
avformat/alp: fix handling of TUN files
Sample rate is always 22050. Verified by trying various files in the game.
2020-10-25 23:44:25 +10:00
Michael Niedermayer 728330462c avformat/rmdec: Make expected_len 64bit
Fixes: signed integer overflow: 1347551268 * 14 cannot be represented in type 'int'
Fixes: 26458/clusterfuzz-testcase-minimized-ffmpeg_dem_RM_fuzzer-5655364324032512

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2020-10-25 09:49:40 +01:00
Michael Niedermayer b23a619c13 avformat/pcm: Check block_align
Fixes: signed integer overflow: 321 * 8746632 cannot be represented in type 'int'
Fixes: 26461/clusterfuzz-testcase-minimized-ffmpeg_dem_PVF_fuzzer-6326427831762944

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2020-10-25 09:49:31 +01:00
Michael Niedermayer 80bc2ac3c0 avformat/lrcdec: Clip timestamps
Fixes: signed integer overflow: 7111111111111531010 - -7335632962598013506 cannot be represented in type 'long'
Fixes: 26463/clusterfuzz-testcase-minimized-ffmpeg_dem_LRC_fuzzer-6015558333759488

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2020-10-25 09:49:26 +01:00
Michael Niedermayer 857aba7c45 avformat/electronicarts: Check for EOF in each iteration of the loop in ea_read_packet()
Fixes: timeout(>20sec -> 1ms)
Fixes: 26526/clusterfuzz-testcase-minimized-ffmpeg_dem_EA_fuzzer-5672328069120000

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Reviewed-by: Peter Ross <pross@xvid.org>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2020-10-25 09:05:01 +01:00
Michael Niedermayer b990148d1e avformat/ifv: Check that total frames do not overflow
Fixes: Infinite loop
Fixes: 26392/clusterfuzz-testcase-minimized-ffmpeg_dem_GIF_fuzzer-5713658237419520
Fixes: 26435/clusterfuzz-testcase-minimized-ffmpeg_dem_SUBVIEWER_fuzzer-6548251853193216

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2020-10-24 19:11:12 +02:00
Michael Niedermayer 7c144b363e avformat/nistspheredec: Check bps
Fixes: left shift of 1111111190 by 3 places cannot be represented in type 'int'
Fixes: 26437/clusterfuzz-testcase-minimized-ffmpeg_dem_NISTSPHERE_fuzzer-4886896091856896

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2020-10-24 19:11:12 +02:00
Michael Niedermayer 715ff75e5d avformat/jacosubdec: Use 64bit inside get_shift()
Fixes: signed integer overflow: 111111111 * 30 cannot be represented in type 'int'
Fixes: 26448/clusterfuzz-testcase-minimized-ffmpeg_dem_JACOSUB_fuzzer-5638440374501376

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2020-10-24 19:11:12 +02:00
Michael Niedermayer 37396e9ba8 avformat/genh: Check block_align
Fixes: infinite loop
Fixes: 26440/clusterfuzz-testcase-minimized-ffmpeg_dem_GENH_fuzzer-5632134020333568

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2020-10-24 19:11:12 +02:00
Michael Niedermayer a413ed9863 avformat/mvi: Check count for overflow
Fixes: left shift of 21378748 by 10 places cannot be represented in type 'int'
Fixes: 26449/clusterfuzz-testcase-minimized-ffmpeg_dem_MVI_fuzzer-5680463374712832

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2020-10-24 19:11:12 +02:00
Michael Niedermayer 209b9ff5c3 avformat/asfdec_f: Check for negative ext_len
Fixes: Infinite loop
Fixes: 26376/clusterfuzz-testcase-minimized-ffmpeg_dem_PCM_U32LE_fuzzer-6050518830678016
Fixes: 26377/clusterfuzz-testcase-minimized-ffmpeg_dem_TY_fuzzer-4838195726123008
Fixes: 26384/clusterfuzz-testcase-minimized-ffmpeg_dem_G729_fuzzer-5173450337157120
Fixes: 26396/clusterfuzz-testcase-minimized-ffmpeg_dem_PCM_S24BE_fuzzer-5071092206796800

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2020-10-23 10:07:57 +02:00