Commit Graph

26729 Commits

Author SHA1 Message Date
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
Michael Niedermayer
89c5d8bdab avformat/rtmpproto: consider command line argument lengths
Fixes: out of array access
Fixes: zeropath/rtmp-2025-10

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 83e0298de2)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-11-19 02:05:00 +01:00
Michael Niedermayer
bb680a9d53 avformat/rtmpproto_ Check tcurl and flashver length
Fixes: out of array accesses

Reviewed-by: Joshua Rogers <joshua@joshua.hu>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit a64e037429)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-11-19 02:05:00 +01:00
Michael Niedermayer
8b42ed314a avformat/rtpenc_h264_hevc: Check space for nal_length_size in ff_rtp_send_h264_hevc()
Fixes: memcpy with negative size
Fixes: momo_trip-poc/input

Reported-by: Momoko Shiraishi <shiraishi@os.is.s.u-tokyo.ac.jp>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit d03483bd26)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-11-19 02:04:59 +01:00
Michael Niedermayer
8674f8c3cd avformat/dhav: Fix off by length of read element error
Fixes: out of array read
Fixes: BIGSLEEP-445383648
Fixes: crash_input_1/2/3.dhav

Found-by: Google Big Sleep
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 55e71768cf)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-11-19 02:04:58 +01:00
Andreas Rheinhardt
bb0e3e7a7c avformat/aviobuf: Keep checksum_ptr consistent in avio_seek()
Otherwise it might be > buf_ptr in which case ffio_get_checksum()
could segfault (s->buf_ptr - s->checksum_ptr would be negative
which would be converted to something very big when converted
to unsigned for the update_checksum callback).

Fixes ticket #11233.

Reported-by: Du4t
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
(cherry picked from commit 987c955cd7)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-11-19 02:04:57 +01:00
Desmond Liu
8e8c1f498d libavformat/udp: Fix call to recvfrom(2)
Last parameter to recvfrom() is not initialized, causing
recvfrom() to randomly return EINVAL. Issue was introduced in
af04a27893.

(cherry picked from commit 4348bde2d2)
2025-11-19 00:58:21 +00:00
Brad Smith
cb570f824d avformat/udp: fix warning about unused varible
libavformat/udp.c:283:9: warning: unused variable 'i' [-Wunused-variable]

Signed-off-by: Brad Smith <brad@comstyle.com>
(cherry picked from commit db0b86a4ad)
2025-11-16 21:13:46 -05:00
James Almer
24205bc657 avformat/demux: pass new extradata to the parser
The parser API doesn't work with packets, only raw data, so in order for it to
be made aware of new extradata propagated through packet side data we need to
pass it in some other form, namely, replacing the main extradata and ensuring
it will be parsed by restarting the parser.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-10-28 11:45:10 -03:00
Marvin Scholz
d1f31a829d avformat/rtsp: fix leading space in RTSP reason
When parsing the RTSP message reason, the whole remainder
after parsing the status code was used, which would lead to
a leading space in the parsed reason string.

(cherry picked from commit e63e040f0c)
Signed-off-by: Marvin Scholz <epirat07@gmail.com>
2025-10-16 15:57:19 +02:00
Marvin Scholz
1e56c51d3b avformat/rtsp: do not log invalid values
When reading fails the first time, ch would be uninitialized and
printed in the log message. Instead check for an error early and
log it properly.

(cherry picked from commit 2ed47ab725)
Signed-off-by: Marvin Scholz <epirat07@gmail.com>
2025-10-16 15:57:19 +02:00
Marvin Scholz
45fcd5567a avformat/http: Handle IPv6 Zone ID in hostname
When using a literal IPv6 address as hostname, it can contain a Zone ID
especially in the case of link-local addresses. Sending this to the
server in the Host header is not useful to the server and in some cases
servers refuse such requests.

To prevent any such issues, strip the Zone ID from the address if it's
an IPv6 address. This also removes it for the Cookies lookup.

Based on a patch by: Daniel N Pettersson <danielnp@axis.com>

(cherry picked from commit 5cb6d2221a)
Signed-off-by: Marvin Scholz <epirat07@gmail.com>
2025-10-16 15:57:19 +02:00
James Almer
558994b051 avformat/dump: fix log level passed to av_log when printing stream group side data
Signed-off-by: James Almer <jamrial@gmail.com>
(cherry picked from commit 2e1d702cfc)
2025-10-15 20:31:21 -03:00
Damiano Galassi
e219c8f77b movenc: ensure chapters track extradata is not null and populated
fix a regression introduced in 4eca8df,
writing chapters failed if chapters where
not available before mov_write_header().

(cherry picked from commit b2f5bc7fd3)
2025-08-24 10:32:33 -03:00
Marvin Scholz
a6c578ef65 avformat/hlsproto: explicitly deprecate it
This makes it more clear that it will be removed in a future release.
2025-08-22 00:28:33 +02:00
Michael Niedermayer
debbeb006b avformat/lrcdec: Fix fate-sub-lrc-ms-remux on x86-32
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 0243cf89b1)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-08-19 17:56:51 +02:00
James Almer
abf123b744 avformat/mov: don't use an allocated array for sample_size with HEIF images
The array is only ever needed for streams where each sample entry may have a
different value. Given that for non animated HEIF there's a single value that
applies to the image, use the field defined for that.

Fixes: NULL pointer dereference
Fixes: 437528618/clusterfuzz-testcase-minimized-ffmpeg_dem_MOV_fuzzer-6537287645331456

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 a28e01a6c1)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-08-19 17:56:50 +02:00