Commit graph

26978 commits

Author SHA1 Message Date
Michael Niedermayer
f112ae503e avformat/hls: Check for integer overflow with #EXTINF:
Found-by: 이동준 <ldj6192@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-02-05 17:59:29 +00:00
Michael Niedermayer
00b4d67812
avformat/demux: Allow non opened codec in has_decode_delay_been_guessed()
Fixes: assertion failure
Fixes: 472097507/clusterfuzz-testcase-minimized-ffmpeg_dem_LIVE_FLV_fuzzer-6016386662203392

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-02-05 18:01:31 +01:00
Michael Niedermayer
5fa7d588f5
avformat/flvdec: Check need_context_update when audio codec changes
We did check video codecs but not audio
Fixes: Assertion failure (on codec_id) in parser.c
Fixes: 472097507/clusterfuzz-testcase-minimized-ffmpeg_dem_LIVE_FLV_fuzzer-6016386662203392

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-02-05 18:01:31 +01:00
Zane van Iperen
b628cafd48
libavformat/argo_brp: fix incorrect ASF chunk header read
Was inadvertently broken in the switch to ffio_read_size().

Fixes: 6dd83fab44

PR: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/21650

Reviewed-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Signed-off-by: Zane van Iperen <zane@zanevaniperen.com>
2026-02-05 22:19:48 +10:00
Anthony Bajoua
627da1111c libavformat/movenc: Uses dynamic buffers for fragmented chunks 2026-02-04 18:45:15 -08:00
Jack Lau
36b23092f9 avformat/rtsp: replace the deprecated localport with localrtpport
The `localport` already deprecated in 3a29702cb6

Signed-off-by: Jack Lau <jacklau1222gm@gmail.com>
2026-02-04 00:26:26 +00:00
Michael Niedermayer
1fd718c6a9 avformat/mpegts: Check program_info_length
Fixes: overread
No testcase

Found-by: Marton Balint
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-02-04 00:04:41 +00:00
Michael Niedermayer
5975149603 avformat/mpegts: Check IOD_DESCRIPTOR len
Fixes: out of array read
Fixes: VULN-7/poc.ts

Found-by: Zhenpeng (Leo) Lin from depthfirst
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-02-04 00:04:41 +00:00
Jack Lau
5c6c12acb1 avformat/rtpenc: fix memleak when sdp create failed
Fix #20712

When print_sdp() fails during rtp streaming, sch_start()
returns error code without calling wirte_trailer, causing
a memory leak.

The avformat_free_context() will call the mux->deinit, so
we should add a rtp_deinit() to free all internal allocations.

Signed-off-by: Jack Lau <jacklau1222gm@gmail.com>
2026-02-03 23:31:17 +00:00
Michael Niedermayer
65fc0db581 avformat/hlsenc: fix format string vulnerability in parse_playlist
Found-by: Sarthak Munshi <sarthakmunshi@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-02-03 11:26:23 +00:00
Andreas Rheinhardt
836d34e3ba avformat/tests/movenc: Make objects static
(This also fixes a symbol name collision with libssh,
which has a nonstatic function called md5.)

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-02-02 23:06:57 +01:00
James Almer
b613eebe78 avformat/demux: don't overwrite packet durations with parser ones if unset
Prevents loss of values taken from the demuxer when the underlying parser
doesn't set durations.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-02-02 12:52:02 -03:00
James Almer
3fc7e39eb8 avformat/cafenc: disable muxing Opus streams
We're not writing a kuki chunk because its contents for Opus are currently
unknown, so it's best if we don't allow the creation of non spec compliant
files.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-02-02 12:52:02 -03:00
James Almer
bec16c0bd3 avformat/cafdec: export Opus extradata
Given the contents of the Opus kuki are not fully clear, generate it
using know values from the desc and pakt chunks.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-02-02 12:52:02 -03:00
James Almer
d151c904df avformat/cafdec: take into account priming samples in timestamps
Signed-off-by: James Almer <jamrial@gmail.com>
2026-02-02 12:52:02 -03:00
Gyan Doshi
50bcc96a75 avformat/cafdec: parse non-intra streams
Needed to set KF flags so that they can be streamcopied using CLI.
2026-01-30 16:59:53 +00:00
Andreas Rheinhardt
de3f99d74b avformat/cafenc: Truncate values for avio_w8()
Fixes triggering av_assert2() in avio_w8().

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-01-30 13:24:06 +01:00
Andreas Rheinhardt
4367c055b6 avformat/cafenc: Fix segfault upon error, avoid indirection
caf_write_deinit() would segfault if the CAFStreamContext
couldn't be allocated. Fix this by moving everything from
CAFStreamContext to the ordinary CAFContext; the separation
doesn't make sense for a format with only one stream anyway
and removing it also avoids an indirection.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-01-30 11:30:30 +01:00
James Almer
277f9cb5d8 avformat/cafenc: add init and deinit callbacks
Signed-off-by: James Almer <jamrial@gmail.com>
2026-01-29 21:09:03 -03:00
James Almer
2d5556b082 avformat/cafenc: reindent after the previous changes
Signed-off-by: James Almer <jamrial@gmail.com>
2026-01-29 21:09:03 -03:00
James Almer
7581abdcb1 avformat/cafenc: support writing Packet Table Chunk Header if there are priming or remainder frames
If a codec has fixed block_align and frame_size but a given sample has either
priming or remainder frames, a pakt chunk can be written declaring zero packets
and no table, reporting only the samples to be discarded.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-01-29 21:09:02 -03:00
James Almer
6ff12c4f6c avformat/cafenc: add support for variable frame size codecs
Signed-off-by: James Almer <jamrial@gmail.com>
2026-01-29 21:09:02 -03:00
James Almer
7600d12383 avformat/cafenc: define a structure to store stream private fields
Will be useful in the following commit.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-01-29 21:09:02 -03:00
James Almer
8d1f247ec1 avformat/cafenc: fix setting frame count fields in Packet Table Description
st->duration is not guaranteed to be set, so store the sum of packet durations instead.
Also, set mPrimingFrames and mRemainderFrames to correct values.

Based on a patch by Jun Zhao.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-01-29 21:09:02 -03:00
James Almer
f5ea09afe8 avformat/cafdec: export frame size when present
Signed-off-by: James Almer <jamrial@gmail.com>
2026-01-29 21:09:02 -03:00
James Almer
c52b287ba9 avformat/cafdec: fix setting stream and packet durations
Take into account priming frames, exported as start time, and remainder frames,
substracted from the stream duration as well as exported as discard padding
side data in the last packet.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-01-29 21:09:02 -03:00
Jack Lau
2a0a32c42b avformat/whip: remove the confused option buffer_size
See https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20965#issuecomment-22815

The buffer_size isn't inlcuded in release/8.0,
directly use new option ts_buffer_size to replace
buffer_size shoule be okay.

Signed-off-by: Jack Lau <jacklau1222gm@gmail.com>
2026-01-29 12:18:22 +00:00
Jack Lau
4ad20a2c09 avformat/tls_gnutls: set key and cert when they're PEM string
Signed-off-by: Jack Lau <jacklau1222gm@gmail.com>
2026-01-28 10:47:07 +00:00
Jack Lau
28fb3f5e9e avformat/tls_gnutls: set srtp profile when it is enabled
Signed-off-by: Jack Lau <jacklau1222gm@gmail.com>
2026-01-28 10:47:07 +00:00
Jack Lau
8f9825cf41 avformat/tls_gnutls: add check for s->external_sock
When s->external_sock is enabled, the underlying sock
will be set after tls_open(), so it should not open a
sock and handshake.

Signed-off-by: Jack Lau <jacklau1222gm@gmail.com>
2026-01-28 10:47:07 +00:00
Jack Lau
7f9d8b0c16 avformat/tls_gnutls: enable dtls build
Implement ff_ssl_*_key_cert()

Generate self-signed cert and key in server
mode if there're no key and cert input.

Implement ff_tls_set_external_socket() and
ff_dtls_export_materials()

Add gnutls as dtls protocol deps.

Signed-off-by: Jack Lau <jacklau1222gm@gmail.com>
2026-01-28 10:47:07 +00:00
Steven Liu
a97632827d avformat/dashdec: check value valid after read value from mpd xml
before this commit ffmpeg get Heap Buffer Overflow in DASH Demuxer
via Negative Start Number.
Check the value from mpd xml, set the value to 0 if get negative value.

Fixes: heap buffer overflow
Found-by: Zhenpeng (Leo) Lin from depthfirst
2026-01-27 08:28:43 +00:00
Rost Kurylo
4c9953592f avformat/udp: don't bind sockets to 0.0.0.0 by default for unicast UDP inputs 2026-01-24 20:26:24 +00:00
Jack Lau
ba3cbc2b4a avformat/whip: fix hard code in SDP BUNDLE
In early code, the BUNDLE always has two stream
id "a=group:BUNDLE 0 1" even though there's only
one stream.

This patch aims to dynamically set BUNDLE value.

Signed-off-by: Jack Lau <jacklau1222@qq.com>
2026-01-21 09:18:59 +00:00
Jack Lau
69b6af0e68 avformat/whip: remove redundant NONBLOCK set for dtls
DTLS handshake already force set BLOCK mode.

Signed-off-by: Jack Lau <jacklau1222@qq.com>
2026-01-21 08:52:28 +00:00
Jack Lau
bbd63b5a82 avformat/whip: handle the error of dtls_initialize
Correct the log level to AV_LOG_ERROR when dtls fails

Signed-off-by: Jack Lau <jacklau1222@qq.com>
2026-01-21 08:52:28 +00:00
Jack Lau
42596578ee avformat/whip: put dtls init code into dtls_initialize
Signed-off-by: Jack Lau <jacklau1222@qq.com>
2026-01-21 08:52:28 +00:00
Jack Lau
ddf3e56514 avformat/whip: correct the ice time log
The ICE handshake actually finished after recieve
and handle binding request from peer when the peer
is not ice lite mode.

Log the ice status when it really done.

Signed-off-by: Jack Lau <jacklau1222@qq.com>
2026-01-21 08:52:28 +00:00
Jun Zhao
33dd3485ba lavf/format: skip multiple consecutive ID3v2 tags in probe
Files with multiple consecutive ID3v2 tags were getting low probe
scores (1) because av_probe_input_format3 only skipped the first tag,
leaving subsequent tags to be treated as non-audio data.

Fix by looping to skip all consecutive ID3v2 tags before probing.

Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
2026-01-21 02:37:43 +00:00
James Almer
41a2eb735c avformat/iamf_parse: stop trying to parse files that report an unknown layout
Exporting unknown layouts as unspec type is pointless in a format that expects
the user to remix the channels in location specific ways.
This simplifies assumptions and reduces the chances of heap buffer overflows.

Fixes: heap-buffer-overflow
Fixes: clusterfuzz-testcase-minimized-ffmpeg_dem_IAMF_fuzzer-6363647720095744
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: James Almer <jamrial@gmail.com>
2026-01-21 00:02:58 +00:00
Jack Lau
8bd5594a0f avformat/whip: fix potential out of bound read in is_dtls_packet
Signed-off-by: Jack Lau <jacklau1222gm@gmail.com>
2026-01-19 21:37:17 +08:00
Jack Lau
5bc9e76ec6 avformat/whip: fix parameter order of ELAPSED
Signed-off-by: Jack Lau <jacklau1222gm@gmail.com>
2026-01-19 21:37:17 +08:00
Jack Lau
5e73027099 avfotmat/whip: remove ssl_error_message since it's no longer in use
Signed-off-by: Jack Lau <jacklau1222gm@gmail.com>
2026-01-19 21:37:17 +08:00
Jack Lau
d15a9d5961 avformat/whip: fix memleak when avio_alloc_context() fails
The buffer is prepared for avio, so we need to free
the buffer at the end when avio_alloc_context() fails,
otherwise, it will cause memleak.

Signed-off-by: Jack Lau <jacklau1222gm@gmail.com>
2026-01-19 21:34:43 +08:00
Jack Lau
cc8f392136 avformat/whip: add new option ts_buffer_size to deprecate buffer_size
See https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20965#issuecomment-15854

The old option name `buffer_size` maybe confusing because there're some
protocols and muxer using this.

Signed-off-by: Jack Lau <jacklau1222gm@gmail.com>
2026-01-18 03:42:05 +00:00
Jack Lau
74bc79e475 avformat/tls_gnutls: fix build error on linux
The fd_set need <sys/select.h> on linux, but it's
not included in os_support.h, it's included in os_support.c

So this patch use poll() to replace select() to avoid
this issue and simplify the code.

Signed-off-by: Jack Lau <jacklau1222gm@gmail.com>
2026-01-18 01:57:56 +00:00
James Almer
5ec31dac94 avformat/mov: fix memory leak on error
Regression since 52b1977353.

Fixes CID 1680454.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-01-17 17:52:52 -03:00
James Almer
c1a7c79624 avformat/hcom: check that all extradata bytes were read from the input
Fixes issue #21493.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-01-17 17:42:06 -03:00
James Almer
52b1977353 avformat/mov: add overflow checks to item offset values
Fixes issue #21478.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-01-17 13:02:49 -03:00
Jun Zhao
6c878f8b82 lavf/movenc: fix missing padding for AV1 extradata
The extradata allocated in mov_write_single_packet() for AV1 was missing
the required AV_INPUT_BUFFER_PADDING_SIZE padding bytes. This could lead
to out-of-bounds reads when the extradata is parsed by bitstream readers.

Replace av_memdup() with av_malloc() + memset() + memcpy() to ensure
proper padding is present and zeroed.

Reproduced with:
./ffmpeg -y -f lavfi -i "testsrc=duration=1:size=320x240:rate=30" -c:v libaom-av1 -cpu-used 8 -crf 50 test-av1.mp4

Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
2026-01-14 23:56:39 +00:00