Commit graph

27249 commits

Author SHA1 Message Date
James Almer
3393dc3020 avformat/dashdec: propagate parsing requirement from the underlying demuxer
Signed-off-by: James Almer <jamrial@gmail.com>
2026-05-03 17:00:17 +00:00
James Almer
e76bfba1cf avformat/mov: request parsing for LCEVC streams
Given that no standalone decoder will be present, use a parser to get stream
information that's not reported by the container.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-05-03 17:00:17 +00:00
Andreas Rheinhardt
21c2d38537 avformat/rmdec: Fix shadowing
Reviewed-by: Ramiro Polla <ramiro.polla@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-05-03 18:22:46 +02:00
Andreas Rheinhardt
2fd9d69034 avformat/rmdec: Add av_fallthrough
Reviewed-by: Ramiro Polla <ramiro.polla@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-05-03 18:22:44 +02:00
Michael Niedermayer
2678bce860 avformat/avidec: check LIST size in avi_load_index()
This avoids an unsigned integer underflow and passing that large value to ff_read_riff_info()
2026-05-03 14:40:49 +00:00
depthfirst-dev[bot]
f1c3f1cae1 avformat/avidec: validate INFO list size before parsing
Reject INFO list chunks that are too small to contain the expected
4-byte list type field before calling ff_read_riff_info().

The parser subtracts 4 from the list size when handing the remaining
payload to ff_read_riff_info(). If the chunk is smaller than 4 bytes,
that underflows the expected structure and should be treated as invalid
input.

Fixes: DFVULN-607

*Vulnerability reported by Zhenpeng (Leo) Lin at depthfirst*
*Patch validated by Zheng Yu at depthfirst*
2026-05-03 14:40:49 +00:00
Michael Niedermayer
f47ca0a5e6 avformat/matroskadec: Check audio.sub_packet_h * audio.frame_size
Fixes: out of array access
Fixes: poc_matroska.mkv

This issue requires manually increasing the malloc limit
(-max_alloc 4294967296)

Found-by: Guanni Qu <qguanni@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-05-03 14:39:45 +00:00
Michael Niedermayer
9d9250e5da avformat/pcm: Use 64bit for byte_rate
Fixes: integer overflow

Found-by: Marius Momeu <marius.momeu@berkeley.edu>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-05-03 13:26:34 +00:00
Michael Niedermayer
2d4ec46345 libavformat/xwma: fix overflow in seek position
Fixes: signed integer overflow

Found-by: Marius Momeu <marius.momeu@berkeley.edu>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-05-03 13:26:34 +00:00
depthfirst-dev[bot]
8010aa2193 avformat/rtpdec_mpeg4: reject zero-length AU header sections
Reject AU header sections with a signaled length of zero in
rtp_parse_mp4_au().

The AU-headers-length field specifies the length in bits of the AU header
section that immediately follows. A zero-length section is not useful input
for this parser and can lead to invalid downstream state, so reject it
up front together with oversized values.

*Vulnerability reported by Zhenpeng (Leo) Lin at depthfirst*
*Patch validated by Zheng Yu at depthfirst*

Fixes: OOB read
2026-05-03 13:19:55 +00:00
Flavio Milan
a45a91b23b avformat/rtmpproto: prevent integer overflow accumulating FLV buffer size
Fixes: out of array access
2026-05-03 13:18:54 +00:00
depthfirst-dev[bot]
52b78cd3fe avformat/rtmpproto: validate compressed SWF header length
Reject truncated compressed SWF input before attempting to read the
8-byte header in rtmp_calc_swfhash().

Compressed SWF data identified by the "CWS" signature must be at least
8 bytes long to contain the fixed header. Bail out early when the input
is shorter to avoid operating on malformed data.

*Vulnerability reported by Zhenpeng (Leo) Lin at depthfirst*
*Patch validated by Zheng Yu at depthfirst*

Fixes: DFVULN-612
2026-05-03 12:43:21 +00:00
depthfirst-dev[bot]
1a00ea51cb avformat/rtsp: Fix out-of-bounds read in SDP parser when control_url is empty
Guard against empty string before reading the last byte in control_url.
When parsing relative a=control: paths, if no base control URL was set,
the code would access control_url[strlen(control_url)-1] which on an
empty string causes a size_t underflow and out-of-bounds read.

Now compute the length first and check for len == 0 before array access.

*Vulnerability reported by Zhenpeng (Leo) Lin at depthfirst*
*Patch validated by Zheng Yu at depthfirst*

Fixes: DFVULN-611
2026-05-03 12:43:05 +00:00
depthfirst-dev[bot]
664d44a825 avformat/rtpdec_latm: avoid integer overflow in LATM length parsing
latm_parse_packet() accumulated attacker-controlled AU length bytes in
a signed int and later checked data->pos + cur_len against data->len.
That addition could overflow, allowing malformed packets to bypass the
bounds check and drive memcpy() far past the end of the LATM buffer.

Reject length-byte accumulation that would exceed the remaining packet
size, and compare cur_len against the remaining buffer space using
subtraction so the bounds check cannot overflow.

Fixes: DFVULN-610

*Vulnerability reported by Zhenpeng (Leo) Lin at depthfirst*
*Patch validated by Zheng Yu at depthfirst*
2026-05-03 12:42:57 +00:00
Kacper Michajłow
702b0784b7 avformat/concat: guard total_size overflow
Fixes: 466797413/clusterfuzz-testcase-minimized-fuzzer_options_parser-6015183727427584
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2026-05-03 07:30:46 +00:00
Kacper Michajłow
be207a0d66 avformat/concat: change concat_data::total_size to int64_t
It's both initialized as int64_t in concat_open() and returned as
int64_t in concat_seek().
2026-05-03 07:30:46 +00:00
Michael Niedermayer
016a241102 avformat/iamf_parse.c: Fix potential integer overflow in opus_decoder_config()
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-05-03 02:36:54 +00:00
Michael Niedermayer
8439e02037 avformat: Fix various extradata padding issues
Reported-by: Kenan Alghythee <kalghy2@uic.edu>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-05-03 02:36:54 +00:00
depthfirst-dev[bot]
5408059eb7 avformat/cafdec: fix negative index use in read_seek
av_index_search_timestamp() returns a negative value when a seek target
cannot be resolved from the stream index. Bail out before using that
result as an index into sti->index_entries to avoid out-of-bounds reads.

Fixes: Buffer underflow

Fixes: DFVULN-608

*Vulnerability reported by Zhenpeng (Leo) Lin at depthfirst*
*Patch validated by Zheng Yu at depthfirst*
2026-05-02 21:40:19 +00:00
Michael Niedermayer
91d29be49a avformat/rtpdec_jpeg: check qtable_len
Fixes: out of array access
Fixes: 605/pc.py

Based-on patch by depthfirst

*Reporter: Zhenpeng (Leo) Lin at depthfirst*
2026-05-02 21:16:51 +00:00
ASTRA
26732641fb avformat/vividas: use-of-uninitialized-value in keybuffer
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-05-02 21:16:19 +00:00
Kacper Michajłow
1bb12370b0 avformat/httpauth: avoid casting callback functions type
Technically it's is UB to call function of different type.

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2026-05-01 23:58:40 +00:00
Kacper Michajłow
d768bd564e avformat/hls: avoid casting callback functions type
Technically it's is UB to call function of different type.

Fixes:
src/libavformat/utils.c:531:9: runtime error: call to function handle_variant_args through pointer to incorrect function type 'void (*)(void *, const char *, int, char **, int *)'
src/libavformat/hls.c:379: note: handle_variant_args defined here

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2026-05-01 23:58:40 +00:00
Dale Curtis
a7d42bfba8 avformat/mov: Limit maximum box size for mov_read_lhvc()
Signed-off-by: Dale Curtis <dalecurtis@chromium.org>
2026-04-30 22:50:51 +00:00
depthfirst-dev[bot]
68ea660d83 avformat/mov: reject dimg references with zero entries
Reject dimg entries with a zero reference count in mov_read_iref_dimg().
This is the earliest point where the parser learns how many input images
a derived HEIF item references, so it is the right place to enforce the
invariant.

If entries == 0 is accepted here, the value is stored in HEIFGrid.nb_tiles,
later propagated by read_image_iovl() into AVStreamGroupTileGrid.nb_tiles,
and finally consumed in istg_parse_tile_grid(), which assumes at least one
tile and reads tg->offsets[tg->nb_tiles - 1]. With zero tiles, that
assumption breaks and leads to the out-of-bounds access seen in ASan.

Fixing the problem at the parser boundary is preferable to adding a later
workaround because it prevents creation of an invalid derived-image state
and stops that malformed state from reaching downstream consumers.

This is also consistent with the HEIF specification. Both iovl and grid
derived images are formed from one or more input images, and for grid the
dimg reference count must equal rows * columns; since rows and columns are
encoded as *_minus_one + 1, that count cannot be zero. A zero dimg entry
count is therefore invalid input and should be rejected when parsed.
2026-04-30 19:19:07 +00:00
Nicolas Dato
3aa5d957d1 avformat/dashdec: fix previous commit where I inadvertently removed the case when calc_next_seg_no_from_timelines returned -1 and move_timelines wasn't called
Signed-off-by: Nicolas Dato <nicolas.dato@gmail.com>
2026-04-29 23:54:37 +00:00
Nicolas Dato
8a8bde6a54 avformat/dashdec: fix calculation and usage of cur_seq_no, fixing issue 22335
Functions like calc_cur_seg_no, calc_min_seg_no, and calc_max_seg_no calculated
the segment number taking into account the first_seq_no.
However, functions like get_segment_start_time_based_on_timeline and
calc_cur_seg_no didn't take first_seq_no into account.
This made dashdec believe that the cur_seq_no was always less than min_seq_no,
logging 'old fragment' and calling calc_cur_seq_no.

In live dash streams with some startNumber, that call to calc_cur_seq_no after
the 'old fragment' log made ffmpeg reposition itself 60 seconds before the
current time whenever the manifest reloaded.
This made ffmpeg skip segments, specially when the manifest reloaded slower
than the segments duration, resulting in a new manifest with more than one new
segment.

Signed-off-by: Nicolas Dato <nicolas.dato@gmail.com>
2026-04-29 23:54:37 +00:00
Michael Niedermayer
c25673fe70 avformat/mpegts: Fix memleak of pes_filter.opaque
Fixes: 490257166/clusterfuzz-testcase-minimized-ffmpeg_dem_MPEGTS_fuzzer-4815675538604032

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-04-29 20:50:21 +00:00
James Almer
2e6af10481 avformat/dashdec: copy stream groups from input representations
Signed-off-by: James Almer <jamrial@gmail.com>
2026-04-29 14:00:03 +00:00
James Almer
8fad6dcfd9 avformat/dashdec: support more than one underlying stream per Representation
Some Dash manifests contain Representations within an Adaptation Set that
reference an underlying mp4 context that contain more than the stream it
describes, as is the case of LCEVC enhancements.

Despite the fact open_demux_for_component() loops through all streams in the
underlying context, the rest of the demuxer is writen assuming only the
stream described by the corresponding representation will be present, which
results in completely wrong stream index assignments.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-04-29 14:00:03 +00:00
Michael Niedermayer
7c67748537 avformat/mov: check extradata in mov_read_dops()
We do want to limit an attackers ability to change once parsed structures.
So once extradata (or another array) is finished and possibly has been used we do not
want to allow an attacker to change it.

This reduces the attack surface

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-04-29 00:46:47 +00:00
Ted Meyer
53cd2c9f2a avformat/mov: Check read size for opus extradata
in mov_read_dops, `size` bytes is allocated for
`st->codecpar->extradata`, but ff_alloc_extradata doesn't memset, so the
contents of that buffer are just old heap data. If `avio_read` reads
fewer bytes than were requested, uninitialized data can still be left in
the extradata buffer, which is operated on by AV_WL16A and AV_WL32A.

I think the best solution here is to just check the read size and ensure
it's filling the extradata buffer in it's entirety, or erroring out if
there isn't enough data left.
2026-04-28 23:46:56 +00:00
Zhao Zhili
beb315ca31 avformat/wavdec: fix unchecked avio_read in w64_read_header
Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2026-04-28 13:44:57 +00:00
Marvin Scholz
89870d404c avformat/aiffdec: add fall-through annotations 2026-04-28 12:29:37 +00:00
Marvin Scholz
f0e9854f79 avformat/avidec: add fall-through annotations 2026-04-28 12:29:37 +00:00
Marvin Scholz
85c88d748f avformat/avienc: add fall-through annotations 2026-04-28 12:29:37 +00:00
Marvin Scholz
2ea8e764e2 avformat/bethsoftvid: add fall-through annotations 2026-04-28 12:29:37 +00:00
Marvin Scholz
749f01e3ea avformat/cafdec: add fall-through annotations 2026-04-28 12:29:37 +00:00
Marvin Scholz
c25c83abf5 avformat/concat: add fall-through annotations 2026-04-28 12:29:37 +00:00
Marvin Scholz
720d5c3c51 avformat/electronicarts: add fall-through annotations 2026-04-28 12:29:37 +00:00
Marvin Scholz
337a3fba9d avformat/epafdec: add fall-through annotations 2026-04-28 12:29:37 +00:00
Marvin Scholz
3f815180e8 avformat/flvdec: add fall-through annotations 2026-04-28 12:29:37 +00:00
Marvin Scholz
c26334f750 avformat/flvenc: add fall-through annotations 2026-04-28 12:29:37 +00:00
Marvin Scholz
223939e6be avformat/id3v2: add break 2026-04-28 12:29:37 +00:00
Marvin Scholz
e2c36fbb7f avformat/idroqdec: add fall-through annotations 2026-04-28 12:29:37 +00:00
Marvin Scholz
44271c2dde avformat/jacobsubdec: add fall-through annotations 2026-04-28 12:29:37 +00:00
Marvin Scholz
f715db05fa avformat/lmlm4: add fall-through annotations 2026-04-28 12:29:37 +00:00
Marvin Scholz
346d7f63cb avformat/lvfdec: add fall-through annotations 2026-04-28 12:29:37 +00:00
Marvin Scholz
6d3392fd60 avformat/matroskadec: add break 2026-04-28 12:29:37 +00:00
Marvin Scholz
bcf0b71d8c avformat/mov: add fall-through annotations 2026-04-28 12:29:37 +00:00