1
0
mirror of https://git.ffmpeg.org/ffmpeg.git synced 2026-10-24 02:09:03 +03:00
Commit Graph

28054 Commits

Author SHA1 Message Date
Michael Niedermayer
66143d6aaa Bump minor version for release/9.1
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-10-23 06:44:03 +02:00
Jun Zhao
1a24bd6c7f tests/fate: add an ID3v2 chapter size round-trip
Cover ID3v2.3 and ID3v2.4 with a chapter title long enough that a plain
size and a synchsafe size differ. Print the CHAP size bytes, declared and
actual tag lengths, chapter counts, titles and timings for FATE to compare
against its reference output.

Also give the first embedded text frame an oversized length and verify
through the reference that both chapters and their timings survive.

Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
2026-10-23 09:25:28 +08:00
Jun Zhao
e828b52165 avformat/id3v2: honor the tag version in CHAP frame sizes
ID3v2.3 stores a frame size as a plain 32-bit integer. ID3v2.4 stores it
as a synchsafe integer. write_chapter() always wrote the plain form, and
read_chapter() always read it that way. Once an embedded text frame
reached 128 bytes, the size no longer fitted and the chapter was dropped.

Write the CHAP header with the same version rule as other frames. Read an
embedded frame with that rule, and keep the chapter when a subframe size
does not fit.

Fixes: https://code.ffmpeg.org/FFmpeg/FFmpeg/issues/25357
Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
2026-10-23 07:06:02 +08:00
Michael Niedermayer
2668cb6e31 avformat/asfdec_f: export stream-specific metadata in the stream
Store such entries in the metadata of the corresponding stream.

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-10-22 16:39:53 +00:00
Michael Niedermayer
dadf0b5b2e avformat/asfdec_f: pass the target dictionary to get_tag()
Allows storing tags in a dictionary other than the format metadata.

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-10-22 16:39:53 +00:00
Romain Beauxis
8191fa0b8c avformat/hls: accept EXT-X-START in Master Playlists
EXT-X-START may appear in both Master and Media Playlists (RFC 8216
4.3.5.2). Parsing it allocated a Media Playlist, so a Master Playlist
carrying it before its EXT-X-STREAM-INF entries was rejected since
0e6eef3551.

Record the offset while parsing and apply it once the playlist type is
known. A value from a Master Playlist applies to all its Media
Playlists, which then ignore their own, as RFC 8216 4.3.5 recommends.

Defer EXT-X-ENDLIST the same way, so that it is not lost when it
precedes the first tag allocating the Media Playlist.
2026-10-22 02:51:14 +00:00
Romain Beauxis
1b552f55db libavformat/tests: add an HLS playlist parsing test program
Parse a playlist, then optionally a Media Playlist into the first
playlist it declared, as hls_read_header() does, and print the parsed
playlists with their finished state and EXT-X-START offset.
2026-10-22 02:51:14 +00:00
James Almer
9e6f96bac1 avformat/movenc: wrap AVIF specific functions with a preprocessor check
Signed-off-by: James Almer <jamrial@gmail.com>
2026-10-21 18:35:41 -03:00
James Almer
bcb0ac1d9d avformat/movenc: flag the alpha image in AVIF as hidden
Signed-off-by: James Almer <jamrial@gmail.com>
2026-10-21 18:35:41 -03:00
James Almer
7461dbcb55 avformat/movenc: use bitstream information to write AVIF parameters if needed
If the pixel format is a hardware one, components will be unset, and we will
end up writing an invalid pixi box.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-10-21 18:35:41 -03:00
Martin Mirchev
6dba2558c0 avformat/mov: check the stream group type when updating IAMF streams
The lookup of the stream group for each IAMF audio element compared only
the group id and kept the last match. Mix presentation groups are created
after the audio element groups and use the mix_presentation_id as their
id, so if a mix_presentation_id equals an audio_element_id the mix
presentation group was picked instead. Its entries are the streams of
every audio element, so the same output stream got its index entries
filled twice and the av_assert0(!out_sti->index_entries) aborted.

Such files are written by FFmpeg's own mp4 muxer, e.g. with two audio
elements with ids 1 and 2 and a mix presentation with id 1.

Also check the group type. Keep using the last match: audio element ids
are only unique within one IAMF track, and the groups of the current
track were just appended, so the last match is the audio element of the
current track even if an earlier track uses the same id.

Signed-off-by: Martin Mirchev <mmirchev@comp.nus.edu.sg>
2026-10-21 16:32:08 +00:00
StressTestor
c50d6fca7a avformat/mpegts: stop the raw PCR readahead on a short read
mpegts_raw_read_packet() with compute_pcr looks ahead up to
MAX_PACKET_READAHEAD packets for the next PCR, reading 12 bytes of
each candidate into a stack buffer with avio_read() and ignoring the
return value. When the lookahead runs past the end of the file the
buffer keeps whatever it held, uninitialised on the first iteration,
and parse_pcr() is run on it. If those bytes happen to look like a
PCR, the garbage difference becomes pcr_incr and is published as the
duration of this packet and the pts of every later one. On a build
with -ftrivial-auto-var-init=pattern a file ending in a partial
packet yields duration=1716393918470 instead of 27000000.

Stop the readahead when the seek or the read fails. The packet itself
was already read successfully, and the "no next PCR found" fallback
to the previous increment is the designed behaviour for this case, so
failing the packet would be wrong.

Same class as c2394a0ff3 (binka), 29f513af78 (fsb), 4b47405e1c (genh).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: StressTestor <212606152+StressTestor@users.noreply.github.com>
2026-10-21 09:27:17 +00:00
StressTestor
47ed4708e2 avformat/wtvdec: fail on a short read of a legacy attribute GUID
get_tag() reads a 16-byte GUID attribute into a stack buffer with
avio_read() and ignores the return value. On a legacy_attrib entry
that is cut inside the GUID, the 16 bytes are never written and the
uninitialised stack contents are formatted with PRI_PRETTY_GUID and
published as a metadata string; ffprobe prints them as e.g.
"TAG:encoder=aaaaaaaa-aaaa-aaaa-aaaaaaaaaaaaaaaa" on a build with
-ftrivial-auto-var-init=pattern.

Use ff_get_guid(), which reads with ffio_read_size() and fails on a
short read, and return without adding the tag, as get_tag() already
does when a string attribute is empty.

Same class as c2394a0ff3 (binka), 29f513af78 (fsb), 4b47405e1c (genh).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: StressTestor <212606152+StressTestor@users.noreply.github.com>
2026-10-21 09:27:17 +00:00
James Almer
3b3dc211fe avformat/mov: don't error out on invalid gain map payloads
Unless it's requested by the user's compliant level.
Allows demuxing some seemingly non spec-compliant files in the wild again after
the recent Gain Map support addition.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-10-20 21:23:04 -03:00
James Almer
8ec2b44cfd avformat/mov: fix gain map payload length value
We discard the first byte from the payload, so take that into account afterwards.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-10-20 21:23:04 -03:00
Marvin Scholz
9a861e9687 lavf/cafdec: prevent signed integer overflow
Ensure that adding priming and caf->remainder will not overflow st->nb_frames.

Signed-off-by: Marvin Scholz <epirat07@gmail.com>
2026-10-20 23:43:01 +00:00
Michael Niedermayer
557481dea6 avformat/rdt: Check the size of the AAC data left in the packet
The check was suggested in the report.

Hardening for JRU5LF4QdVjc (AISLE-2026-0111-00165)
Found-by: Joshua Rogers <joshua.rogers@aisle.com>
2026-10-20 21:30:18 +00:00
Michael Niedermayer
5af7de7e3d avformat/rtpdec_av1: Read the OBU header byte after the size checks
Moving the read after the checks was suggested in the report.

Hardening for R5y4vDJ078Lr (AISLE-2026-0111-00004)
Found-by: Joshua Rogers <joshua.rogers@aisle.com>
2026-10-20 21:30:18 +00:00
Michael Niedermayer
47dd85608f avformat/tee: Do not receive from the filters of a slave that failed
The continue was suggested in the report.

Hardening for ZKrMQAvMQyye (AISLE-2026-0111-00318)
Found-by: Joshua Rogers <joshua.rogers@aisle.com>
2026-10-20 21:30:18 +00:00
Michael Niedermayer
a77318037b avformat/rtpenc_h263_rfc2190: check the return of init_get_bits8()
Fixes: OEXYJTpBYJPS
Fixes: NULL pointer dereference
NULL pointer dereference Replicated through API with ASAN
Found during the review of https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/24916
2026-10-20 20:41:50 +00:00
Michael Niedermayer
5422569d6a avformat/aviobuf: retry the read after AVERROR(EAGAIN)
Fixes: 3Fn44aM2tqIx
Fixes: infinite loop
Infinite loop Replicated through UnModified FFmpeg with a nonblocking pipe and timeout
Found during the review of https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/24909
2026-10-20 20:41:50 +00:00
Michael Niedermayer
c46268660b avformat/assenc: do not read the event beyond the packet
Fixes: FJdNqUYeEkPS
Fixes: wrong event text
Fixes: out of array read
Wrong event text Replicated through UnModified FFmpeg with plain output diff
Out of array read Replicated through API with ASAN
Found during the review of https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/24659

Found-by: Marton Balint <cus@passwd.hu>
Suggested-by: Marton Balint <cus@passwd.hu>
2026-10-20 20:41:50 +00:00
zhang xingxing
97daefb4d6 avformat/tls_mbedtls: free the mbedtls contexts on every error path
This is not a security issue.

Not replicated, compile tested only (mbedtls 3.6.2).

Fixes: T7EtPuJBKWqg
Fixes: swarm-Memory-leak-early-return-skips-mbedtls-resource-cleanup-a1d295

Found-by: zhang xingxing <2388969553@qq.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-10-20 11:36:57 +00:00
Michael Niedermayer
0ff8cac632 avformat/md5proto: free the MD5 context when opening the output fails
This is not a security issue.

Fixes: ORPoDnVi3BLg
Fixes: swarm-MD5-context-leaked-when-output-URL-open-fails-e4415f

Found-by: zhang xingxing <2388969553@qq.com>

Memory leak Replicated through UnModified FFmpeg with LSAN

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-10-20 11:36:57 +00:00
Michael Niedermayer
d58b31a865 avformat/matroskaenc: describe timestamp jumps when starting a cluster
The existing warning does not distinguish a forward timestamp outside the
Block's signed 16-bit range from a late packet that forces a backward
Cluster timestamp jump. Include the direction, stream index, incoming
timestamp, current Cluster timestamp and signed difference in milliseconds.

This addresses the diagnostic part of issue #24379. It does not change
packet interleaving or turn the condition into a muxing error.

Assisted-by: Fairy
2026-10-20 11:34:03 +00:00
Michael Niedermayer
857ee5f9c5 avformat/hls: saturate the playlist timestamp offset arithmetic
Fixes: signed integer overflow
Fixes: 2PuIAHF3wU0b
Regression since: e27ad5760c
Found during triage of the review of https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/24873
Signed integer overflow Replicated through UnModified FFmpeg with UBSAN
2026-10-20 02:25:09 +00:00
Michael Niedermayer
3f322521c0 avformat/hls: saturate the timestamps of ID3 timestamped streams
Fixes: signed integer overflow
Fixes: CniIhjP8pfgr
Found during triage of the review of https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/24873
Signed integer overflow Replicated through UnModified FFmpeg with UBSAN
2026-10-20 02:25:09 +00:00
Michael Niedermayer
d00d31e9c9 avformat/mov: saturate the fragment timestamp arithmetic in mov_read_trun()
Fixes: signed integer overflow
Fixes: 5NVcwD9UoHmO
Found during triage of the review of https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/24878
Signed integer overflow Replicated through UnModified FFmpeg with UBSAN
2026-10-20 02:25:09 +00:00
Michael Niedermayer
de6fb646f7 avformat/http: send cookies given without a Domain only to their host
Fixes: cookie disclosure to other hosts
Fixes: u2ys08MO8oEF
Cookie disclosure Replicated through UnModified FFmpeg

Found-by: Yazan Balawneh, Cystack.ps
2026-10-20 02:19:24 +00:00
Michael Niedermayer
b34b321b07 avformat/rtpenc: Fragment MPEG audio frames that do not fit with the payload header
Fixes: ffmpeg -f lavfi -i sine=d=0.5 -ar 48000 -c:a mp2 -b:a 128k -f rtp -packetsize 396 rtp://127.0.0.1:45111?pkt_size=396

Found during triage of the security report TwYfznAFyatl (#22717)
2026-10-20 01:28:04 +00:00
Michael Niedermayer
14f4e547d6 avformat/rtpenc_jpeg: Check that the JPEG payload header fits in the packet
Fixes: heap-buffer-overflow
Fixes: negative-size-param
Fixes: infinite loop
Fixes: hnrHe6JoiDya

Out of array write, negative-size memcpy and endless loop Replicated through UnModified FFmpeg with ASAN

Found during triage of the security report TwYfznAFyatl (#22717), the
JPEG case is mentioned in the discussion of the issue
2026-10-20 01:28:04 +00:00
Michael Niedermayer
0575266957 avformat/rtpenc: Reject packet sizes too small for one sample
Fixes: infinite loop
Fixes: bz6tTr9RAaZT
Fixes: ffmpeg -f lavfi -i sine=d=0.2 -c:a pcm_s16be -f rtp -packetsize 13 /dev/null
Fixes: ffmpeg -f lavfi -i sine=d=0.2 -ar 8000 -c:a g726 -b:a 24k -f rtp -packetsize 14 /dev/null

Endless loop Replicated through UnModified FFmpeg

Found during triage of the security report TwYfznAFyatl (#22717)
2026-10-20 01:28:04 +00:00
Michael Niedermayer
c77edecb53 avformat/rtpenc: Reject packet sizes too small for one iLBC frame
Fixes: heap-buffer-overflow
Fixes: sbHrRrZhcbbZ

Out of array write Replicated through UnModified FFmpeg with ASAN

Found during triage of the security report TwYfznAFyatl (#22717)
2026-10-20 01:28:04 +00:00
Michael Niedermayer
de46025a0c avformat/rtpenc: Reject packet sizes too small for the VC-2 payload header
Fixes: heap-buffer-overflow
Fixes: zZoxZuoiTRhn

Out of array write Replicated through UnModified FFmpeg with ASAN

Found during triage of the security report TwYfznAFyatl (#22717)
2026-10-20 01:28:04 +00:00
Michael Niedermayer
11c22178bb avformat/rtpenc: Reject packet sizes too small for the AV1 payload headers
Fixes: heap-buffer-overflow
Fixes: FyS11JI5UXC7
Fixes: ffmpeg -i fate-suite/av1/film_grain.ivf -frames:v 2 -c copy -strict experimental -f rtp -packetsize 13 /dev/null

Out of array read Replicated through UnModified FFmpeg with ASAN

Found during triage of the security report TwYfznAFyatl (#22717)
2026-10-20 01:28:04 +00:00
Michael Niedermayer
092c2d9b72 avformat/rtpenc: Reject packet sizes too small for the VP9 payload descriptor
Fixes: infinite loop
Fixes: 2bIuZUVk7KRO
Fixes: ffmpeg -f lavfi -i testsrc=duration=0.2:size=64x64:rate=5 -c:v libvpx-vp9 -strict experimental -f rtp -packetsize 13 /dev/null

Endless loop Replicated through UnModified FFmpeg

Found during triage of the security report TwYfznAFyatl (#22717)
2026-10-20 01:28:04 +00:00
Michael Niedermayer
59af4fea04 avformat/rtpenc: Reject packet sizes too small for the H.263 payload header
Fixes: negative-size-param
Fixes: infinite loop
Fixes: gFLqHoPMr8J5
Fixes: ffmpeg -f lavfi -i testsrc=duration=0.2:size=176x144:rate=5 -c:v h263 -f rtp -packetsize 13 /dev/null
Fixes: ffmpeg -f lavfi -i testsrc=duration=0.2:size=176x144:rate=5 -c:v h263 -rtpflags rfc2190 -f rtp -packetsize 13 /dev/null

Negative-size memcpy and endless loop Replicated through UnModified FFmpeg with ASAN

Found during triage of the security report TwYfznAFyatl (#22717)
2026-10-20 01:28:04 +00:00
Michael Niedermayer
fc75877feb avformat/rtpenc: Reject packet sizes too small for the MPEG audio payload header
Fixes: negative-size-param
Fixes: infinite loop
Fixes: KX3pF2MSORSh
Fixes: ffmpeg -f lavfi -i sine=d=0.2 -c:a mp2 -f rtp -packetsize 13 /dev/null

Negative-size memcpy and endless loop Replicated through UnModified FFmpeg with ASAN

Found during triage of the security report TwYfznAFyatl (#22717)
2026-10-20 01:28:04 +00:00
Michael Niedermayer
b85207c8e9 avformat/rtpenc: Reject packet sizes too small for the MPEG video payload header
Fixes: negative-size-param
Fixes: infinite loop
Fixes: vrmb3QRC6jK1
Fixes: swarm-Signed-integer-underflow-in-RTP-MPEG-video-packet-length-4acadd
Fixes: ffmpeg -f lavfi -i color=size=64x64:duration=1 -packetsize 13 -c:v mpeg1video -f rtp rtp://127.0.0.1:45004

Negative-size memcpy and endless loop Replicated through UnModified FFmpeg with ASAN

Found-by: zhang xingxing <2388969553@qq.com>
2026-10-20 01:28:04 +00:00
Michael Niedermayer
4353f63c7c avformat/rtpenc: Reject packet sizes too small for the payload header
Fixes: negative-size-param
Fixes: infinite loop
Fixes: TwYfznAFyatl
Fixes: #22717
Fixes: ffmpeg -f lavfi -i testsrc=duration=0.1:size=16x16:rate=1 -c:v libvpx -f rtp -packetsize 13 rtp://127.0.0.1:9999

Negative-size memcpy and endless loop Replicated through UnModified FFmpeg with ASAN

Found-by: bird <6666242+bird@users.noreply.github.com>
2026-10-20 01:28:04 +00:00
Michael Niedermayer
cae0589065 avformat/idroqdec: continue after the declared size of the first RoQ_INFO chunk
Stream desynchronization Replicated through UnModified FFmpeg

Found during review of the fixes for the security report yyLBi9GsHV9w
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-10-19 23:51:00 +00:00
Michael Niedermayer
d353ea87b7 avformat/sctp: return AVERROR_EOF when the peer closes the association
Fixes: WoBBcuySgSTx
Fixes: swarm-sctp_read-returns-2-on-graceful-close-never-signalling-EOF-2a7ba0
Endless loop Replicated through UnModified FFmpeg

Found-by: zhang xingxing <2388969553@qq.com>
The report suggested not adding the stream id size when recvmsg() returns 0.
The case without max_streams was found during triage of the report.

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-10-19 23:51:00 +00:00
Michael Niedermayer
94505b6444 avformat/idroqdec: compute the codebook and VQ packet size in 64bit
Fixes: yyLBi9GsHV9w
Packet size wraparound Replicated through UnModified FFmpeg

Found-by: zhang xingxing <2388969553@qq.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-10-19 23:51:00 +00:00
zhang xingxing
8b7e5d278c avformat/idroqdec: skip the whole body of a repeated RoQ_INFO chunk
The RoQ player in the Quake III Arena source (code/client/cl_cin.c) also
continues after the declared size of every RoQ_INFO chunk.

Fixes: yyLBi9GsHV9w
Fixes: swarm-RoQ_INFO-re-entry-skips-fixed-size-ignoring-chunk_size-e7709a
Stream desynchronization Replicated through UnModified FFmpeg

Found-by: zhang xingxing <2388969553@qq.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-10-19 23:51:00 +00:00
Martin Mirchev
5993347a1b avformat/flvenc: reject text packets too long for an AMF0 string
AV_CODEC_ID_TEXT packets are written as an AMF0 string, whose length is a
16-bit field. For text over 65535 bytes the length wrapped (e.g. 4464 for
70000 bytes) while the whole text was written, so readers misparse the
onTextData tag.

Fail on such packets before writing the tag.
Found while reviewing the metadata length fix for FLV.

Signed-off-by: Martin Mirchev <mmirchev@comp.nus.edu.sg>
2026-10-19 19:33:13 +00:00
Michael Niedermayer
d20d75cb9b avformat: remove the asf_o demuxer
asf_o is a second, non-default implementation of the ASF demuxer next
to asfdec_f.c. Security issues keep being reported against it, so it
is a maintenance burden without a benefit over the default demuxer.

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-10-19 19:16:58 +00:00
Michael Niedermayer
71403a21b0 avformat/mov: append pssh init info in place instead of re-parsing the side data
Replaces O(n^2) by O(n) implementation

Fixes: Timeout
Found during triage/review of the security report
Fixes: tyKGcmR25mD8
2026-10-19 17:14:29 +02:00
Michael Niedermayer
d522eb22c2 avformat/iamf_parse: free the context when reading the descriptors fails
Fixes: heap-use-after-free
Fixes: GXcHU0CpqXBk
Fixes: ANT-2026-5PRHEUWY
Found-by: Anthropic agents; validated and reported by Ada Logics.
Suggested-by: James Almer <jamrial@gmail.com>
2026-10-19 14:57:27 +00:00
ykisana
40f2812185 avformat/mxfenc: write the actual FFV1 version in the FFV1 sub-descriptor
Fixes issue due to MXF muxer writing FFV1Version by copying byte 14 of the FFV1 codec label.
This caused incorrect version numbers, it would increase by one, so 3 became 4.
Now we save the real version in sc->version.
2026-10-19 11:53:03 +00:00
Jun Zhao
c8db684cbb avformat/apngdec: report out of order APNG chunks
The fcTL and fdAT chunks share a single sequence number, which must start
at 0 and increase by one for every chunk, with no gap and no duplicate.
Report the chunks which do not follow it, resynchronizing on the value
which was read so that the following chunks are not reported as well.

Out of order chunks are only reported and not rejected, so that files
written by encoders getting this wrong are still played.

Validate fdAT lengths and complete reads before locating the sequence
number in the packet. Resynchronize after external seeks, where the next
sequence number cannot be inferred from the previously read frame.

Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
2026-10-19 07:23:22 +08:00