Commit Graph

23705 Commits

Author SHA1 Message Date
Vittorio Giovara
9afde28093 mov: Skip computing SAR from invalid display matrix elements 2021-04-06 16:52:07 +02:00
Michael Niedermayer
0f6a3405e8 avformat/mov: check offset for overflow in mov_probe()
Fixes: Invalid read of size 4
Fixes: ASAN_Deadlysignal.zip

Found-by: Hardik Shah <hardik05@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2021-04-05 18:41:59 +02:00
Andreas Rheinhardt
b3652d9745 avformat/dss: Return 0 on success
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-04-05 18:36:51 +02:00
Andreas Rheinhardt
48a594aba5 avformat/dss: Avoid using intermediate buffer
All one needs is one byte beyond the end of the normal data; and because
the packet is padded, one already has it.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-04-05 18:34:52 +02:00
Andreas Rheinhardt
ef8c8b4163 avformat/dss: Set values known during read_header in read_header
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-04-05 17:48:11 +02:00
Andreas Rheinhardt
5d06d26be3 avformat/mpegtsenc: Preserve disposition in the absence of language
Implements ticket #9113.

Reviewed-by: Marton Balint <cus@passwd.hu>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-04-05 04:04:00 +02:00
Andreas Rheinhardt
af867e59d9 avformat/vividas: Fix crash when seeking without audio stream
The current code tries the access the codecpar of a nonexistent
audio stream when seeking. Stop that. Fixes ticket #9121.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-04-02 21:03:39 +02:00
Andreas Rheinhardt
afa511ad34 avformat/dss: Don't prematurely modify context variable
The DSS demuxer currently decrements a counter that should be positive
at the beginning of read_packet; should it become negative, it means
that the data to be read can't be read contiguosly, but has to be read
in two parts. In this case the counter is incremented again after the
first read if said read succeeded; if not, the counter stays negative.

This can lead to problems in further read_packet calls; in tickets #9020
and #9023 it led to segfaults if one tries to seek lateron if the seek
failed and generic seek tried to read from the beginning. But it could
also happen when av_new_packet() failed and the user attempted to read
again afterwards.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-04-02 15:36:32 +02:00
Andreas Rheinhardt
543e4a1942 avformat/utils: Check allocations for failure
There would be leaks in case of failure.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-04-02 15:27:42 +02:00
Andreas Rheinhardt
ec4c04aa7b avformat/asf: Use ff_add_attached_pic() to read attached pics
Also removes a stack packet.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-04-01 18:23:13 +02:00
Andreas Rheinhardt
7aee4762d3 avformat/utils: Free new streams in ff_add_attached_pic on error
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-04-01 18:23:13 +02:00
Andreas Rheinhardt
39ecb63d0f avformat: Add and use helper function to add attachment streams
All instances of adding attached pictures to a stream or adding
a stream and an attached packet to said stream have several things
in common like setting the index and flags of the packet, setting
the stream disposition etc. This commit therefore factors this out.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-04-01 18:23:13 +02:00
Michael Niedermayer
f7a5150447 avformat/imx: Check palette chunk size
Fixes: out of array write
Fixes: 32116/clusterfuzz-testcase-minimized-ffmpeg_dem_SIMBIOSIS_IMX_fuzzer-6702533894602752

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2021-04-01 10:10:21 +02:00
Michael Niedermayer
cf2fd9204b avformat/rmdec: use larger intermediate type for audio_framesize * sub_packet_h check
Fixes: signed integer overflow: 65535 * 65535 cannot be represented in type 'int'
Fixes: 31406/clusterfuzz-testcase-minimized-ffmpeg_dem_IVR_fuzzer-5024692843970560

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2021-04-01 10:10:21 +02:00
Martin Storsjö
b484e140ef tls_gnutls: Print the underlying IO error message and pass the error code through
Signed-off-by: Martin Storsjö <martin@martin.st>
2021-04-01 09:05:10 +03:00
Martin Storsjö
84ad471fce tls_openssl: Improve quality of printed error messages, pass IO error codes through
Print every error in the stack, if more than one, and don't print
bogus errors if there's none logged within OpenSSL.

Retain the underlying IO error code, print an error message out of
it, and pass the error code on to the caller.

Signed-off-by: Martin Storsjö <martin@martin.st>
2021-04-01 09:05:10 +03:00
Gyan Doshi
eac77f7cf0 rtpenc_mpegts: add AVClass to the muxer context 2021-04-01 09:34:58 +05:30
Michael Niedermayer
6cc65d3d67 avformat/mpc8: check for size overflow in mpc8_get_chunk_header()
Fixes: signed integer overflow: -9223372036854775760 - 50 cannot be represented in type 'long'
Fixes: 31673/clusterfuzz-testcase-minimized-ffmpeg_dem_MPC8_fuzzer-580134751869337

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2021-03-31 23:09:35 +02:00
Michael Niedermayer
c1fe1114bc avformat/mov: Do not zero memory that is written too or unused
Fixes: OOM
Fixes: 31220/clusterfuzz-testcase-minimized-ffmpeg_dem_MOV_fuzzer-6033383962574848

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2021-03-31 23:09:35 +02:00
Michael Niedermayer
2611d20d35 avformat/mov: Ignore multiple STSC / STCO
Fixes: STSC / STCO inconsistency and assertion failure
Fixes: crbug1184666.mp4

Found-by: Chromium ASAN fuzzer
Reviewed-by: Matt Wolenetz <wolenetz@google.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2021-03-31 23:09:35 +02:00
Michael Niedermayer
b37ff29e0e avformat/utils: Extend overflow check in dts wrap in compute_pkt_fields()
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>
2021-03-31 23:09:35 +02:00
Andreas Rheinhardt
dfeb9b3a8b avformat/asf: Factor common code out
Both functions to read attached pictures coincide since
e83f27a21a (save for some log messages
in case av_dict_set failed).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-03-31 22:01:36 +02:00
Alok Priyadarshi
62f486e793 avformat/rtpdec: Fix prft wallclock time.
Timestamp difference is available in media timebase (1/90K) where as
rtcp time is in the default microseconds timebase. This patch fixes
the calculated prft wallclock time by rescaling the timestamp delta
to the microseconds timebase.

Signed-off-by: James Almer <jamrial@gmail.com>
2021-03-30 11:59:15 -03:00
Andreas Rheinhardt
c81b8e04aa Avoid intermediate bitcount for number of bytes in PutBitContext
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2021-03-30 12:36:32 +02:00
Michael Niedermayer
1f74661543 avformat/wtvdec: Check size in SBE2_STREAM_DESC_EVENT / stream2_guid
Fixes: signed integer overflow: 539033600 - -1910497124 cannot be represented in type 'int'
Fixes: 30928/clusterfuzz-testcase-minimized-ffmpeg_dem_WTV_fuzzer-5922630966312960

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2021-03-29 22:19:39 +02:00
Michael Niedermayer
6dc6e1cce0 avformat/utils: Fix integer overflow with duration_gcd in ff_rfps_calculate()
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>
2021-03-29 22:19:39 +02:00
Michael Niedermayer
ea12590c8e avformat/cafdec: Do not build an index if all packets are the same
Fixes: Timeout
Fixes: 28214/clusterfuzz-testcase-minimized-ffmpeg_dem_CAF_fuzzer-6495999421579264

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2021-03-29 22:19:39 +02:00
Andreas Rheinhardt
558426b847 avformat/sierravmd: Make struct smaller by reordering
Also remove keyframe from vmd_frame, it is unused.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2021-03-28 19:09:29 +02:00
Andreas Rheinhardt
440a401d89 avformat/sierravmd: Remove outdated check
The check has been added at a time when the code performed the
multiplication itself instead of deferring it to av_malloc_array()
and when our allocation functions used unsigned instead of size_t.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2021-03-28 19:09:29 +02:00
Andreas Rheinhardt
117a41b7e3 avformat/segafilm: Remove outdated check
The check has been added at a time when the code performed the
multiplication itself instead of deferring it to av_malloc_array()
and when our allocation functions used unsigned instead of size_t.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2021-03-28 19:09:29 +02:00
Andreas Rheinhardt
63fcf3da01 avformat/utils: Remove redundant check
This check is outdated because the caller doesn't need to check that
the multiplication overflows when using av_realloc_array() (the code
in question used av_realloc() before that); furthermore, the check
is also a remnant of the time in which our allocation functions
didn't use size_t parameters.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2021-03-28 19:09:29 +02:00
Andreas Rheinhardt
a42c47b77f avformat/webmdashenc: Don't pass NULL to memcmp
Affects the FATE-tests webm-dash-manifest-unaligned-video-streams,
webm-dash-manifest and webm-dash-manifest-representations.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2021-03-28 17:50:17 +02:00
Michael Niedermayer
e44214a824 avformat/vividas: Use equals check with n in read_sb_block()
Fixes: OOM
Fixes: 27780/clusterfuzz-testcase-minimized-ffmpeg_dem_VIVIDAS_fuzzer-5097985075314688

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2021-03-28 14:20:00 +02:00
Michael Niedermayer
2c477be08a avformat/jacosubdec: Use 64bit intermediate for start/end timestamp shift
Fixes: signed integer overflow: -1957694447 + -1620425806 cannot be represented in type 'int'
Fixes: 30207/clusterfuzz-testcase-minimized-ffmpeg_dem_JACOSUB_fuzzer-5050791771635712

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2021-03-28 14:20:00 +02:00
Michael Niedermayer
b5d8fe1c87 avformat/flvdec: Check array entry number
Fixes: signed integer overflow: -2147483648 - 1 cannot be represented in type 'int'
Fixes: 30209/clusterfuzz-testcase-minimized-ffmpeg_dem_FLV_fuzzer-5724831658147840

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2021-03-28 14:20:00 +02:00
Gyan Doshi
8b2bde0494 avformat/rtpenc_mpegts: stop leaks
Fixes CID 1474460 & 1474461
2021-03-28 15:55:02 +05:30
Derek Buitenhuis
f404a2716a avformat/mov: Properly forward error codes from av_seek
This is important, for example, for connection timed out events,
when used over a network, returning AVERROR(ETIMEDOUT).

Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
2021-03-26 20:04:12 +00:00
Michael Niedermayer
5c2ff44f91 avformat/movenc: Avoid loosing cluster array on failure
Fixes: crash
Fixes: check_pkt.mp4

Found-by: Rafael Dutra <rafael.dutra@cispa.de>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2021-03-26 16:00:14 +01:00
Michael Niedermayer
f733688d30 avformat/avidec: Check for dv streams before using priv_data in parse ##dc/##wb
Fixes: null pointer dereference
Fixes: 31588/clusterfuzz-testcase-minimized-ffmpeg_dem_AVI_fuzzer-6165716135968768

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Reviewed-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2021-03-26 16:00:14 +01:00
Michael Niedermayer
d35677736a avformat/mov: Check sample size for overflow in mov_parse_stsd_audio()
Fixes: signed integer overflow: 2 * 1914708000 cannot be represented in type 'int'
Fixes: 31639/clusterfuzz-testcase-minimized-ffmpeg_dem_MOV_fuzzer-6303428239294464

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2021-03-26 16:00:14 +01:00
Michael Niedermayer
f44068db1e avformat/sbgdec: Check for overflow in last loop in expand_timestamps()
Fixes: signed integer overflow: 9223372036854775807 + 86400000000 cannot be represented in type 'long'
Fixes: 31003/clusterfuzz-testcase-minimized-ffmpeg_dem_SBG_fuzzer-6256298771480576

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Reviewed-by: Nicolas George <george@nsup.org>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2021-03-26 15:53:30 +01:00
Gyan Doshi
2c806aa2b4 avformat/rtpenc_mpegts: convey options for rtp muxer 2021-03-26 12:37:10 +05:30
Gyan Doshi
325bb04188 avformat/rtpenc_mpegts: relay streamid to mpegts muxer streams. 2021-03-26 12:35:37 +05:30
Gyan Doshi
affe911c65 avformat/rtpenc_mpegts: convey options for mpeg-ts muxer
Fixes #5239
2021-03-26 12:34:27 +05:30
Andreas Rheinhardt
df6dc331dd avformat/libmodplug: Fix memleaks on error
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2021-03-26 03:03:59 +01:00
Andreas Rheinhardt
9e0c16fcc3 avformat/libgme: Remove redundant setting of packet size
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2021-03-26 03:03:59 +01:00
Andreas Rheinhardt
1897286d05 avformat/libgme: Actually set the duration
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2021-03-26 03:03:59 +01:00
Andreas Rheinhardt
05457a3661 avformat/libgme: Fix memleaks on errors
Also free the gme_info_t structure immediately after its use.
This simplifies cleanup, because it might be unsafe to call
gme_free_info(NULL) (or even worse, gme_track_info() might even
on error set the pointer to the gme_info_t structure to something
else than NULL).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2021-03-26 03:03:59 +01:00
Andreas Rheinhardt
3ec3370dea avformat/aadec: Fix leak on error
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2021-03-26 03:03:59 +01:00
Andreas Rheinhardt
4f11685e4c avformat/jacosubdec: Fix leak on error
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2021-03-26 03:03:59 +01:00
Zane van Iperen
64fb63411d
avformat/pp_bnk: allow seeking to start
Allows "ffplay -loop" to work.

Signed-off-by: Zane van Iperen <zane@zanevaniperen.com>
2021-03-25 12:51:10 +10:00
Zane van Iperen
ea9732c5d6
avformat/alp: allow seeking to start
Allows "ffplay -loop" to work.

Signed-off-by: Zane van Iperen <zane@zanevaniperen.com>
2021-03-25 12:51:10 +10:00
Zane van Iperen
3cc4a140ef
avformat/kvag: allow seeking to start
Allows "ffplay -loop" to work.

Signed-off-by: Zane van Iperen <zane@zanevaniperen.com>
2021-03-25 12:51:10 +10:00
Andreas Rheinhardt
dfad5794fb avformat/amvenc: Remove unnecessary av_packet_free()
The muxer's deinit function takes care of cleaning up when init fails.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2021-03-24 00:31:29 +01:00
Andreas Rheinhardt
3903c139a9 avformat/webpenc: Fix memleak when trailer is never written
When the trailer is never written (or when a stream switches from
non-animation mode to animation mode mid-stream), a cached packet
(if existing) would leak. Fix this by adding a deinit function.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2021-03-24 00:30:45 +01:00
Andreas Rheinhardt
df9d969954 avformat/webpenc: Reindentation
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2021-03-24 00:29:32 +01:00
Andreas Rheinhardt
f9043de99a avformat/webpenc: Fix memleak when using invalid packets
The WebP muxer sometimes caches a packet it receives to write it later;
yet if a cached packet is too small (so small as to be invalid),
it is cached, but not written and not unreferenced. Such a packet leaks,
either by being overwritten by the next packet or because it is never
unreferenced at all.

Fix this by not caching unusable packets at all; and error out on
invalid packets.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2021-03-24 00:28:21 +01:00
Andreas Rheinhardt
484a322f0a avformat/webpenc: Use init instead of write_header function
webp_write_header() didn't write anything.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2021-03-24 00:27:26 +01:00
Andreas Rheinhardt
0519a32a64 avformat/ipmovie: Avoid stack packet
Replace it in ipmovie_read_header() by AVFormatInternal.parse_pkt
which is unused when reading the header.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2021-03-24 00:26:45 +01:00
Andreas Rheinhardt
79a90b42ca avformat/ipmovie: Remove redundant initializations
The demuxer's context has already been zeroed generically.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2021-03-24 00:26:18 +01:00
Andreas Rheinhardt
2ef4c5bba4 avformat/ipmovie: Fix indentation
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2021-03-24 00:25:38 +01:00
Andreas Rheinhardt
7070bc53aa avformat/ipmovie: Deduplicate parsing video data opcodes
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2021-03-24 00:24:50 +01:00
Andreas Rheinhardt
0ce702d999 avformat/ipmovie: Avoid reading packets during read_header
They will be discarded anyway because this can only happen
for invalid data. This already implies that the pkt won't be used
at all when parsing the very first chunk when reading the header,
so one can use NULL as argument and remove the av_packet_unref()
on error.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2021-03-24 00:21:32 +01:00
Andreas Rheinhardt
da9eed79b9 avformat/ipmovie: Remove redundant av_packet_unref()
When one of these errors happens during ipmovie_read_packet(),
an error is returned and the packet is cleaned up generically.
And since 712d3ac539 the same happens
in ipmovie_read_header().

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2021-03-24 00:21:01 +01:00
Andreas Rheinhardt
3750390ede avformat/asfdec_f: Avoid stack packet
Replace it by using AVFormatInternal.parse_pkt which is otherwise unused
when reading a header.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2021-03-24 00:19:54 +01:00
Andreas Rheinhardt
2e1d5123c1 avformat/moflex: Simplify freeing packets
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2021-03-24 00:18:06 +01:00
Andreas Rheinhardt
a4d036965d avformat/matroskadec: Reuse AVFormatInternal.parse_pkt
Before 8d78e90a6b the Matroska demuxer
used stack packets to hold temporary packets; now it uses a temporary
packet allocated by the Matroska demuxer. Yet because it used stack
packets the code has always properly reset the packet on error, while
on success these temporary packets were put into a packet list via
avpriv_packet_list_put(), which already resets the source packet.
This means that this code is compatible with just reusing
AVFormatInternal.parse_pkt (which is unused while one is in the
demuxer's read_packet() function). Compared to before 8d78e90a6
this no longer wastes one initialization per AVPacket read
(the resetting of the stack packet performed by av_packet_move_ref()
in avpriv_packet_list_put() was for naught).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2021-03-24 00:07:36 +01:00
Alok Priyadarshi
adff25412a avformat/rtpdec: attach producer reference time if available
This produces true wallclock time at rtp source instead of the
local wallclock time at rtp client.

Signed-off-by: James Almer <jamrial@gmail.com>
2021-03-23 19:02:47 -03:00
Andreas Rheinhardt
4a9eb7072c avformat/utils: Don't allocate separate packet for extract_extradata
One can simply reuse AVFormatInternal.parse_pkt instead.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2021-03-23 14:23:49 +01:00
Andreas Rheinhardt
e375e09d82 libavformat/utils: Fix indentation
Originally added in 12f996edfa
behind #if 0; aebb56e184 then
removed the #if and replaced it by using av_dlog. Then commit
1a3eb042c7 replaced this with av_log
at trace level. Yet the code block always stayed within { }
at an increased level of indentation.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2021-03-23 14:04:46 +01:00
Andreas Rheinhardt
84b02bbb78 avformat/s337m: Use av_get_packet() to read packet
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2021-03-23 01:05:17 +01:00
Andreas Rheinhardt
47d0b86cf3 avformat/s337m: Use and test Dolby-E-parser
This makes av_read_frame() return packets with proper timestamps.
As a result, seeking now works in combination with streamcopy.
A FATE-test for this has been added.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2021-03-23 01:05:17 +01:00
Andreas Rheinhardt
2fccd8bfb9 avformat/utils: Fix confusing return value for ff_read_packet()
Currently, ff_read_packet() sometimes forwards the return value of
AVInputFormat.read_packet() (which should be zero on success, but isn't
for all demuxers) and sometimes it overwrites this with zero.
Furthermore, it uses two variables, one for the read_packet return value
and one for other errors, which is a bit confusing; it is also
unnecessary given that the documentation explicitly states that
ff_read_packet() never returns positive values. Returning a positive
value would lead to leaks with some callers (namely asfrtp_parse_packet
and estimate_timings_from_pts). So always return zero in case of
success.

(This behaviour stems from a time before av_read_packet sanitized
the return value of read_packet at all: It was added in commit
626004690c and was unnecessary since
88b00723906f68b7563214c30333e48888dddf78.)

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2021-03-23 01:04:09 +01:00
Andreas Rheinhardt
ab5803553b avformat/apetag: Avoid stack packet when reading attached picture
Read it directly into AVStream.attached_pic.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2021-03-21 23:08:19 +01:00
James Almer
34f4f57800 avformat: remove FF_API_INIT_PACKET from AVStream.attached_pic
This field needs to be replaced altogether, not just its type changed.
This will be done in a separate change.

Signed-off-by: James Almer <jamrial@gmail.com>
2021-03-21 18:47:27 -03:00
Derek Buitenhuis
85f397c828 avformat/mov: Fix extended atom size buffer length check
When extended atom size support was added to probing in
fec4a2d232, the buffer
size check was backwards, but probing continued to work
because there was no minimum size check yet, so despite
size being 1 on these atoms, and failing to read the 64-bit
size, the tag was still correctly read.

When 0b78016b2d introduced a
minimum size check, this exposed the bug, and broke probing
any files with extended atom sizes, such as entirely valid
large files that start whith mdat atoms.

Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
2021-03-21 14:14:36 +00:00
Gyan Doshi
75fd3e1519 avformat/rtp_mpegts: typedef MuxChain struct 2021-03-21 15:50:40 +05:30
Carl Eugen Hoyos
9f8c81efc5 lavf/swfdec: Allow decoding Nellymoser in swf.
Such files exist in the wild, see ticket #9153.
2021-03-20 18:52:55 +01:00
Andreas Rheinhardt
8a73313412 avformat/pp_bnk: Fix memleaks when reading non-stereo tracks
Commit 6973df1122 added support
for music tracks by outputting its two containing tracks
together in one packet. But the actual data is not contiguous
in the file and therefore one can't simply use av_get_packet()
(which has been used before) for it. Therefore the packet was
now allocated via av_new_packet() and read via avio_read();
and this is also for non-music files.

This causes problems because one can now longer rely on things
done automatically by av_get_packet(): It automatically freed
the packet in case of errors; this lead to memleaks in several
FATE-tests covering this demuxer. Furthermore, in case the data
read is less than the data desired, the returned packet was not
zero-allocated (the packet's padding was uninitialized);
for music files the actual data could even be uninitialized.

The former problems are fixed by using av_get_packet() for
non-music files; the latter problem is handled by erroring out
unless both tracks could be fully read.

Reviewed-by: Zane van Iperen <zane@zanevaniperen.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2021-03-20 08:21:30 +01:00
Andreas Rheinhardt
258a88dfe4 avformat/utils: Always leave parse_pkt in blank state, avoid resetting
Always leaving said packet in a blank state after having used it
allows to avoid having to reset it before one uses it; and it also
allows to use it in more places than just in parse_packet() here.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2021-03-20 04:23:05 +01:00
Michael Niedermayer
c361fa9e21 Bump minor versions after release branch
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2021-03-20 01:02:11 +01:00
Michael Niedermayer
c67d2a2875 Bump Versions before release/4.4 branch
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2021-03-20 01:01:12 +01:00
Michael Niedermayer
92fde2585e avformat/mov: Check offset addition for overflow
Fixes: signed integer overflow: 9223372036854775807 + 536870912 cannot be represented in type 'long'
Fixes: 31678/clusterfuzz-testcase-minimized-ffmpeg_dem_MOV_fuzzer-5614204619980800

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2021-03-19 23:59:45 +01:00
Jiangjie Gao
3e9284fccb avformat/rtsp: support buffer_size and pkt_size options for RTP
And forward it to the underlying UDP protocol.

Fixes ticket #7517.

Signed-off-by: Jiangjie Gao <gaojiangjie@live.com>
Signed-off-by: Marton Balint <cus@passwd.hu>
2021-03-19 23:13:26 +01:00
Zhao Zhili
d86f44fecc avformat/libsrt: fix help message
SRTO_TLPKTDROP works for receiver and sender both.

Signed-off-by: Marton Balint <cus@passwd.hu>
2021-03-19 22:57:23 +01:00
Zhao Zhili
65bfb6af66 avformat/libsrt: fix setsockopt() typo
Signed-off-by: Marton Balint <cus@passwd.hu>
2021-03-19 22:57:20 +01:00
Moritz Barsnick
94b63e8ae8 avformat/http,tls: honor http_proxy command line variable for HTTPS
Add the "http_proxy" option and its handling to the "tls" protocol,
pass the option from the "https" protocol.

The "https" protocol already defines the "http_proxy" command line
option, like the "http" protocol does. The "http" protocol properly
honors that command line option in addition to the environment
variable. The "https" protocol doesn't, because the proxy is
evaluated in the underlying "tls" protocol, which doesn't have this
option, and thus only handles the environment variable, which it
has access to.

Fixes #7223.

Signed-off-by: Moritz Barsnick <barsnick@gmx.net>
Signed-off-by: Marton Balint <cus@passwd.hu>
2021-03-19 22:43:02 +01:00
Zane van Iperen
6973df1122
avformat/pp_bnk: treat music files as stereo
These files are technically a series of planar mono tracks.
If the "music" flag is set, merge the packets from the two
mono tracks, essentially replicating:

  [0🅰️0][0🅰️1]join=inputs=2:channel_layout=stereo[a]

Signed-off-by: Zane van Iperen <zane@zanevaniperen.com>
2021-03-19 23:38:33 +10:00
Andreas Rheinhardt
a46d781905 avcodec/packet: Also change av_packet_pack/unpack_dictionary to size_t
These are auxiliary side-data functions, so they should have been
switched to size_t in d79e0fe65c,
but this has been forgotten.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2021-03-19 03:12:24 +01:00
Andreas Rheinhardt
e318438f2f avformat: Make AVChapter.id an int64_t on next major bump
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>
2021-03-19 02:36:58 +01:00
Andreas Rheinhardt
e1e6a5c8a5 avformat/matroskaenc: Check chapter ids for duplicates
Up until now, there has been no check that each chapter has a unique id;
there was only a check for whether a chapter id is zero (this happens
often when the chapters originated from a format that lacks the concept
of chapter id and simply counts from zero) which is invalid in Matroska.
In this case the chapter ids are offset by 1 to make them nonnegative.
Yet offsetting won't fix duplicate ids, therefore this is changed to
simply create new chapter uids when the input chapter uids don't conform
to the requirements of Matroska (in which case it can be presumed that
they did not originate from Matroska, so that we don't need to bother
to preserve them).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2021-03-19 02:31:49 +01:00
Andreas Rheinhardt
edcbb3e1b9 avformat/tests/fifo_muxer: Fix memleak on error, fix API violation
The test program for the FIFO muxer allocates a buffer without padding
and wraps it into a packet via av_packet_from_data(). This is an API
violation. Furthermore, said buffer leaks in case av_packet_from_data()
fails. Fix both of these issues by using av_new_packet() instead.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2021-03-19 02:25:02 +01:00
Andreas Rheinhardt
aff1d373b1 avformat/tests/fifo_muxer: Fix leak of AVPacket on error
Also factor allocating and freeing the packet out.
Fixes Coverity issues #1473722 and #1473723; it is a regression
since 4b386b2059.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2021-03-19 02:24:53 +01:00
Andreas Rheinhardt
ea1e15fdc4 avformat/mxfdec: Fix leak on error
It was introduced in d3d9b1fc8e2dfc8b4d66c9916ab7221062ff4660;
Fixes Coverity issue #733800.

Reviewed-by: Tomas Härdin <tjoppen@acc.umu.se>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2021-03-19 00:42:27 +01:00
Andreas Rheinhardt
9224b1f6b3 avformat/mxfdec: Don't use wrong type of pointer
If one of the two results of a ternary conditional is a pointer to void,
the type of the whole conditional operator is a pointer to void, even
when the other possible result is not a pointer to void. This loophole
in the type system has allowed mxf_read_local_tags to have a pointer of
type pointer to MXFMetadataSet that actually points to an MXFContext.

Reviewed-by: Tomas Härdin <tjoppen@acc.umu.se>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2021-03-19 00:41:16 +01:00
James Almer
d365f74dce avformat/tests/movenc: use av_packet_alloc() to allocate packets
Signed-off-by: James Almer <jamrial@gmail.com>
2021-03-17 15:19:36 -03:00
James Almer
4b386b2059 avformat/tests/fifo_muxer: use av_packet_alloc() to allocate packets
Signed-off-by: James Almer <jamrial@gmail.com>
2021-03-17 15:19:36 -03:00
James Almer
2fdfad5525 avformat/wc3movie: use av_packet_alloc() to allocate packets
Signed-off-by: James Almer <jamrial@gmail.com>
2021-03-17 15:19:36 -03:00
James Almer
98a776b5e3 avformat/subtitles: use av_packet_alloc() to allocate packets
Signed-off-by: James Almer <jamrial@gmail.com>
2021-03-17 15:19:36 -03:00
James Almer
fd23efb20b avformat/rtpenc_mpegts: use av_packet_alloc() to allocate packets
Signed-off-by: James Almer <jamrial@gmail.com>
2021-03-17 15:19:36 -03:00