Commit graph

27226 commits

Author SHA1 Message Date
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
Marvin Scholz
9f22a4d363 avformat/mxfdec: add fall-through annotation and break 2026-04-28 12:29:37 +00:00
Marvin Scholz
50b1da33e4 avformat/mxfenc: add fall-through annotations 2026-04-28 12:29:37 +00:00
Marvin Scholz
452d0239ca avformat/network: add fall-through annotations 2026-04-28 12:29:37 +00:00
Marvin Scholz
f819d3452c avformat/nutdec: add fall-through annotations 2026-04-28 12:29:37 +00:00
Marvin Scholz
a6b8525f6e avformat/nuv: add fall-through annotations 2026-04-28 12:29:37 +00:00
Marvin Scholz
49fc8ddf65 avformat/oggparsetheora: add fall-through annotations 2026-04-28 12:29:37 +00:00
Marvin Scholz
70fed6fd33 avformat/rtmppkt: add fall-through annotations 2026-04-28 12:29:37 +00:00
Marvin Scholz
2777e4d389 avformat/takdec: add fall-through annotations 2026-04-28 12:29:37 +00:00
Marvin Scholz
125dd9ee2a avformat/txd: add fall-through annotations 2026-04-28 12:29:37 +00:00
Marvin Scholz
d607b2249f avformat/ty: add fall-through annotations 2026-04-28 12:29:37 +00:00
Marvin Scholz
5988639f39 avformat/yuv4mpegdec: return proper error
The header is not invalid in this case, but ffmpeg still doesn't
support it.
2026-04-28 12:29:37 +00:00
Marvin Scholz
d5ae10e6d4 avformat: replace fall-through comments 2026-04-28 12:29:37 +00:00
depthfirst-dev[bot]
eec78bdac1 avformat/rtspdec: reject non-positive ANNOUNCE Content-Length
rtsp_read_announce() treated any non-zero Content-Length as valid,
including negative values parsed via strtol(). This could send invalid
sizes into allocation, body reads and trailing NUL writes.

Accept only strictly positive SDP body lengths and reject invalid
Content-Length values with AVERROR_INVALIDDATA.

Found-by: Seung Min Shin (was reported to us on 10th April)
CC: 신승민 <guncraft2000@naver.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-04-28 12:07:16 +00:00
Zhao Zhili
9eaa559847 avformat/matroskadec: fix invalid check and uninitialized memory access
size is uninitialized when av_dynamic_hdr_smpte2094_app5_alloc failed.

Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2026-04-28 11:59:59 +00:00
ASTRA
163ba704b7 avformat/wavdec: Fix use-of-uninitialized-value in find_guid()
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-04-24 06:36:41 +00:00
AdityaTeltia
71d5fa8d4d 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.
2026-04-24 03:23:06 +00:00
Ramiro Polla
0cd2bbe4f4 avformat/apngdec: fix playback of piped apng files
The check for avio_size() made apng_read_header() return an error
instead of just disabling looping.
2026-04-23 16:46:21 +00:00
Ramiro Polla
2e92764b86 avformat/apngdec: remove unused function argument 2026-04-23 16:46:21 +00:00
jade
5242bdae82 avformat/id3v2: add image/jxl for JPEG XL image attachments
This allows JPEG XL images to be recognized as valid attachments.
Since JPEG is already widely used for cover art, JXL's support for
lossless JPEG transcodes can decrease the total size of music collections.
This fixes JXL cover art rendering in applications like mpv which rely
on FFmpeg for demuxing.

Signed-off-by: jade <heartstopp1ng@proton.me>
2026-04-22 13:28:17 +00:00
Andreas Rheinhardt
5e69e6d49c avformat/pdvenc: Don't silently truncate value
This muxer seems to intend to support output that does
not begin at zero (instead of e.g. just hardcoding
nb_frames_pos to 16). But then it is possible
that avio_seek() returns values > INT_MAX even
though the part of the file written by us can not
exceed this value. So the return value of avio_seek()
needs to be checked as 64bit integer and not silently
truncated to int.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-04-20 12:54:31 +02:00
Andreas Rheinhardt
2b8438a495 avformat/pdvenc: Remove always-false checks
The number of streams is always one (namely one video stream
with codec id AV_CODEC_ID_PDV) due to the MAX_ONE_OF_EACH,
ONLY_DEFAULT_CODECS flags. Also, the generic code (init_muxer()
in mux.c) checks that video streams have proper dimensions set.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-04-20 12:54:31 +02:00
Andreas Rheinhardt
fcffc0e1c5 avformat/matroskaenc: Remove pointless side-data size checks
Just presume that we any present side data is actually valid.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-04-17 23:53:12 +02:00
Andreas Rheinhardt
38df985fba avformat/matroskaenc: Use separate buffer for SMPTE 2094 blockadditional
Otherwise the buffer for the hdr10+ blockadditional would
be clobbered if both are present (the buffers can only be
reused after the ebml_writer_write() call).

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-04-17 23:53:07 +02:00