Commit graph

26745 commits

Author SHA1 Message Date
Michael Niedermayer
fa4f6f7526
avformat/hls: Check for integer overflow with #EXTINF:
Found-by: 이동준 <ldj6192@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit f112ae503e)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-05-03 19:50:00 +02:00
Michael Niedermayer
fa848c5730
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>
(cherry picked from commit 5fa7d588f5)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-05-03 19:50:00 +02:00
Zane van Iperen
0ddd43e074
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>
(cherry picked from commit b628cafd48)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-05-03 19:49:59 +02:00
Michael Niedermayer
5596a4cd9c
avformat/mpegts: Check program_info_length
Fixes: overread
No testcase

Found-by: Marton Balint
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 1fd718c6a9)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-05-03 19:49:58 +02:00
Michael Niedermayer
04848bb2ff
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>
(cherry picked from commit 5975149603)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-05-03 19:49:58 +02:00
Michael Niedermayer
f9ad7df474
avformat/hlsenc: fix format string vulnerability in parse_playlist
Found-by: Sarthak Munshi <sarthakmunshi@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 65fc0db581)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-05-03 19:49:57 +02:00
Steven Liu
be5d31af5f
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
(cherry picked from commit a97632827d)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-05-03 19:49:57 +02:00
James Almer
9d48fca4f0
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>
(cherry picked from commit 41a2eb735c)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-05-03 19:49:55 +02:00
Michael Niedermayer
68ff515b6b
avformat/http: Check that the protocol of redirects is http or https
Fixes: #YWH-PGM40646-10

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit b9227d49ea)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-05-03 19:49:54 +02:00
Michael Niedermayer
9eab48cc1d
avformat/hls: fix double space
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 9e974b2c45)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-05-03 19:49:53 +02:00
Michael Niedermayer
3f90d4fb2e
avformat/hls: Check seg size and offset for overflow
Fixes: integer overflow
Fixes: signed integer overflow: 9223372036854775807 + 2039324394 cannot be represented in type 'int64_t' (aka 'long')

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 d1985442e1)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-05-03 19:49:53 +02:00
Andreas Rheinhardt
9e211b89ae
avformat/flac_picture: Correct check
Since af97c9865f,
the return value of avio_read() has been compared against
an uint32_t, so that the int is promoted to uint32_t for
the comparison (on common systems with 32bit ints). The upshot was
that errors returned from avio_read() were ignored, so that
the buffer could be uninitialized on success.

Fix this by using ffio_read_size() instead.

Fixes: MemorySanitizer: use-of-uninitialized-value
Fixes: 443923343/clusterfuzz-testcase-minimized-ffmpeg_dem_FLAC_fuzzer-5458132865449984

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
(cherry picked from commit 4aed9db83c)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-05-03 19:49:52 +02:00
James Almer
246c55de06
avformat/demux: ensure avformat_find_stream_info updates internal stream contexts
read_frame_internal() may result in a stream being modified without also
returning a packet from it. Given said function only bothered to update the
internal stream context for the returned packet, the result would be a desync
between the stream's AVCodecParameters and the internal AVCodecContext.

This change makes sure all streams are updated within the
avformat_find_stream_info() loop.

Fixes #YWH-PGM40646-20

Signed-off-by: James Almer <jamrial@gmail.com>
(cherry picked from commit c9c95f6f32)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-05-03 19:49:52 +02:00
James Almer
5b3ca5240c
avformat/iamf_parse: fix parsing of Scalable layouts with Mono and Stereo layers
An ASAN heap-buffer-overflow in scalable_channel_layout_config was caused by an
unchecked assumption that the channel layout of a scalable audio layer is a
superset of the previous layer's channel layout.

scalable_channel_layout_config constructs a channel layout map by copying
channels from the previous layer and adding new ones. The memory allocation is
based on the target loudspeaker_layout. However, if the target layout doesn't
encompass all previous channels (e.g., Mono to Stereo), copying previous
channels followed by adding current ones could exceed the allocated size,
causing a heap buffer overflow.

This commit adds an exception for the know case of Mono -> Stereo, and a check
to ensure the previous layer's channel layout is a subset of the current
layer's layout by comparing their masks. If the condition isn't met,
an error is returned.

Fixes: https://issues.oss-fuzz.com/issues/464965414

Co-authored-by: Oliver Chang <ochang@google.com>
Signed-off-by: James Almer <jamrial@gmail.com>
(cherry picked from commit 2d5abf27e5)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-05-03 19:49:52 +02:00
AdityaTeltia
17f8db1538 avformat/hls_sample_encryption: add missing padding for audio setup buffer
Fixes ticket #22890.

The ff_hls_senc_parse_audio_setup_info function passes setup_data to
parsers like avpriv_ac3_parse_header and init_get_bits8 which require
the buffer to be padded with AV_INPUT_BUFFER_PADDING_SIZE bytes at the end.

(cherry picked from commit 71d5fa8d4d)
Signed-off-by: Marvin Scholz <epirat07@gmail.com>
2026-04-28 21:52:30 +00:00
Derek Buitenhuis
2c4c6bc5b1 avformat/mov: Merge tts after building index for old-style uncompressed PCM
This was a regression introduced in 292c1df7c1.

Since we don't know the length of the stts data until after building the
index, since we're generating it, we need to merge any ctts data after,
since otherwise tts_count is set to 0, and no packets will be output.

We can't remove the merge entirely, because uncompressed PCM with
a ctts atom is technically valid (e.g. a constant CTS offset).

This fixes old-style uncompressed PCM demuxing.

Fixes #11490.

Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
(cherry picked from commit ae03b629db)
2026-04-25 05:02:47 -04:00
James Almer
26fdd2258b avformat/mov: check return value of mov_read_iref_thmb()
Signed-off-by: James Almer <jamrial@gmail.com>
(cherry picked from commit 77298c29bc)
2026-03-05 23:29:52 -03:00
James Almer
343938f182 avformat/mov: Fix multiple issues related to mov_read_iref_dimg()
forward errors and cleanup in teh failure cases

Fixes: freeing uninitialized pointers
Fixes: 487160965/clusterfuzz-testcase-minimized-ffmpeg_dem_MOV_fuzzer-6525162874011648

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 f10c0ae276)
2026-03-05 23:21:21 -03:00
James Almer
0ef3600643 avformat/mov: free item_name on infe entry parsing failure
Fixes regression since 28c330d0f3.

Signed-off-by: James Almer <jamrial@gmail.com>
(cherry picked from commit 40e0463113)
2026-03-05 23:16:17 -03:00
James Almer
f9b61216ae avformat/mov: check for EOF in more loops
Signed-off-by: James Almer <jamrial@gmail.com>
(cherry picked from commit c3aa28f23d)
2026-03-05 23:16:10 -03:00
James Almer
6a756fbb21 avformat/mov: abort if the queried item doesn't exist instead of overwriting it
The check for item presence was insufficient as it would result in the last
item in the array being overwritten if it existed even if the id didn't match.

Fixes: Assertion ref failed at src/libavformat/mov.c:10649
Fixes: clusterfuzz-testcase-minimized-ffmpeg_dem_MOV_fuzzer-5312542695292928
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg

Signed-off-by: James Almer <jamrial@gmail.com>
(cherry picked from commit 28c330d0f3)
2026-03-05 23:16:02 -03:00
James Almer
7399d533ac avformat/mov: add overflow checks to item offset values
Fixes issue #21478.

Signed-off-by: James Almer <jamrial@gmail.com>
(cherry picked from commit 52b1977353)
2026-03-05 23:11:12 -03:00
James Almer
85a32c764b avformat/mov: reindent after the previous change
Signed-off-by: James Almer <jamrial@gmail.com>
(cherry picked from commit fd4e86be9e)
2026-03-05 23:10:37 -03:00
James Almer
19df26bc82 avformat/mov: don't parse reserved ISOBMFF fields as if they were QT
Signed-off-by: James Almer <jamrial@gmail.com>
(cherry picked from commit c0044ec9c4)
2026-03-05 23:10:35 -03:00
James Almer
5acd4d17cc avformat/mov: make items referencing items generic
Signed-off-by: James Almer <jamrial@gmail.com>
(cherry picked from commit 74e430202d)
2026-03-05 23:07:58 -03:00
James Almer
27b8d1a017 avformat/mov: fix cases where we discard iamf packets from enabled streams
Given the entire iamf struct is inside a single Track, if the first iamf stream
(which is the one sharing the index and id from the Track) was to be disabled,
then packets from every iamf stream would be discarded.
Fix this by actually going through the entire iamf Sample and discarding those
from the disabled streams only.

Signed-off-by: James Almer <jamrial@gmail.com>
(cherry picked from commit 16ee3d8d99)
2026-02-27 12:27:15 -03:00
James Almer
415c801ab5 avformat/mov: fix setting iamf stream id offsets
If we were to add the highest id of a non iamf stream as offset to iamf stream
ids, and one of the latter was 0, then an id overlap would ocurr.

Signed-off-by: James Almer <jamrial@gmail.com>
(cherry picked from commit 51aef95ba1)
2026-02-27 12:19:31 -03:00
Jack Lau
15504610b0 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>
(cherry picked from commit 2a0a32c42b)
2026-02-10 09:32:56 +00:00
Jack Lau
0f43795c24 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>
(cherry picked from commit cc8f392136)
2026-02-10 09:32:56 +00:00
Jack Lau
c853beb7c3 avformat/whip: remind user increase -buffer_size
The udp buffer size might be too small to easily
be full temporarily and return WSAEWOULDBLOCK.
The udp code will handle the windows error code
and convert it to AVERROR(EAGAIN).

This issue just can be reproduced on windows.

If sleep a interval and retry to send pkt when hit
EAGAIN, it will increase latency, and appropriate
interval is hard to define.

So this patch just remind user increase the buffer
size via -buffer_size to avoid this issue.

Signed-off-by: Jack Lau <jacklau1222@qq.com>
(cherry picked from commit ec0a04de0d)
2026-02-10 09:32:56 +00:00
Jack Lau
185d07ede1 avformat/whip: pass through buffer_size option to udp
Signed-off-by: Jack Lau <jacklau1222@qq.com>
(cherry picked from commit b3793d9941)
2026-02-10 09:32:56 +00:00
Jack Lau
2096bb7466 avformat/whip: fix potential 8bit overflow for profile_idc
The profile contains profile_idc and constraint_set*_flag,
throws away high 8 bit flags and then we get profile_idc.

Signed-off-by: Jack Lau <jacklau1222@qq.com>
(cherry picked from commit 785a4e0d6c)
2026-02-10 09:32:56 +00:00
Jack Lau
342747ac7d avformat/whip: fix 8 bits overflow and map constraint_set bits for H264
profile_iop is an 8 bits field. Previous code copied
AVCodecParameters::profile (which can contain bits
beyond 8 bits) into profile_iop, producing overflow
and wrong values.

This patch maps the constrained flags into the proper
profile_iop bits (constraint_set1 / 3)

Signed-off-by: Jack Lau <jacklau1222@qq.com>
(cherry picked from commit 6c2768bf8c)
2026-02-10 09:32:56 +00:00
Jack Lau
6350cd623b avformat/whip: fix SDP ICE candidates parsing
fix issue #20407

Refer to RFC 5245 15.1,
the foundation may be any string up to 32 chars.
The old code could misread foundations as transport("udp").
This patch fully parse all these attr to avoid parsing error.

Signed-off-by: Jack Lau <jacklau1222@qq.com>
(cherry picked from commit b41f8207c4)
2026-02-10 09:32:56 +00:00
Jack Lau
65a58c5bd7 avformat/whip: fix ssrc might be same
use audio_ssrc + 1 for video_ssrc to avoid ssrc collision

See RFC 3550 Section 8,
The SSRC identifier carried in the RTP header and in various fields
of RTCP packets is a random 32 bit number that is required to be
globally unique within an RTP session.

simply + 1 also can get an unique ssrc, and faster than generating
new unique ssrc.

Signed-off-by: Jack Lau <jacklau1222@qq.com>
(cherry picked from commit b3ea558492)
2026-02-10 09:32:56 +00:00
Andreas Rheinhardt
8a0fd0f9f3 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-03 15:12:44 -03:00
Timo Rothenpieler
ec78e95627 avformat/img2dec: reject input images too big to fit into a single packet
Not entirely sure if it should instead use some entirely different
approach here, given that images exceeding 2GB don't seem that crazy
to me, but so far processing such images results in a heap overflow,
since the size addition overflows and a much too small packet is
allocated and its size never checked again when writing into it.

Fixes #YWH-PGM40646-32

(cherry picked from commit f6a95c7eb7)
2026-01-01 19:52:19 +00:00
James Almer
bfa334de42 avformat/iamf_writer: check that stream count is consistent for ambisonic Audio Elements
Signed-off-by: James Almer <jamrial@gmail.com>
(cherry picked from commit a0fc454871)
2025-12-30 20:23:51 -03:00
James Almer
06fcee2e26 avformat/iamf_writer: fix writting some ambisonics fields in Audio Elements
The fields are defined as 8 bit long unsigned ints. Fortunately, writing most sane values
as leb is equivalent, which is why no tests are affected.

Signed-off-by: James Almer <jamrial@gmail.com>
(cherry picked from commit 21ff60d2cf)
2025-12-30 20:23:50 -03:00
James Almer
af60dd8419 avformat/iamf_parse: fix setting denominator in AVIAMFLayer.demixing_matrix
The format of demixing_matrix is Q15 fixed point values.

Signed-off-by: James Almer <jamrial@gmail.com>
(cherry picked from commit 03a981445e)
2025-12-30 20:23:50 -03:00
James Almer
fe72a8781b avformat/iamf_parse: ensure the stream count in a scalable channel representation is equal to the audio element's stream count
Signed-off-by: James Almer <jamrial@gmail.com>
(cherry picked from commit faa382e5b1)
2025-11-27 21:58:55 -03:00
James Almer
b5996929df avformat/iamf_parse: ensure each layout in an scalable channel representation has an increasing number of channels
Fixes issue #21013

Signed-off-by: James Almer <jamrial@gmail.com>
(cherry picked from commit 554ae5ada9)
2025-11-27 21:58:42 -03:00
Zhao Zhili
2e1d5b1415 avformat/mov: fix missing video size when some decoders are disabled
Fix #20667

Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
(cherry picked from commit 6b961f5963)
2025-11-23 13:58:51 +00:00
Zhao Zhili
6e147cb8a6 avformat/mov: relax check on proj box size
Pico VR adds a '\0' after projection_type (a real C string than
a fourcc). It's not strictly correct, but doesn't affect parsing.

[prji: Projection Information Box]
    position = 149574743
    size = 17
    version = 0
    flags = 0x000000
    projection_type = rect

Co-Authored-by: Keven Ma
Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
(cherry picked from commit 0734d1c55a)
2025-11-23 13:58:51 +00:00
Michael Niedermayer
719171a375
avformat/whip: Fix rtp_ctx->streams access
Fixes: out of array access
No testcase

Found-by: Joshua Rogers <joshua@joshua.hu> with ZeroPath
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit c199b3d48f)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-11-19 02:05:02 +01:00
Michael Niedermayer
58efabb076
avformat/rtpdec_rfc4175: Only change PayloadContext on success
Reviewed-by: Joshua Rogers <joshua@joshua.hu>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit c03e49dd1d)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-11-19 02:05:02 +01:00
Michael Niedermayer
b833558b76
avformat/rtpdec_rfc4175: Check dimensions
Fixes: out of array access
Fixes: zeropath/int_overflow_in_rtpdec_rfc4175

Found-by: Joshua Rogers <joshua@joshua.hu>
Reviewed-by: Joshua Rogers <joshua@joshua.hu>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit d4e0d5ed48)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-11-19 02:05:01 +01:00
Michael Niedermayer
c1b57e2102
avformat/rtpdec_rfc4175: Fix memleak of sampling
Reviewed-by: Joshua Rogers <joshua@joshua.hu>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit af3dee3132)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-11-19 02:05:01 +01:00
Michael Niedermayer
cfc6fe6400
avformat/http: Fix off by 1 error
Fixes: out of array access
Fixes: zeropath/off-by-one-one-byte

Found-by: Joshua Rogers <joshua@joshua.hu>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit b518c027a0)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-11-19 02:05:01 +01:00
Michael Niedermayer
bc680e230c
avformat/sctp: Check size in sctp_write()
Fixes: out of array access
No testcase

Found-by: Joshua Rogers <joshua@joshua.hu> with ZeroPath
Reviewed-by: Joshua Rogers <joshua@joshua.hu>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 5b98cea4bf)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-11-19 02:05:00 +01:00