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

49349 Commits

Author SHA1 Message Date
Marvin Scholz
b0afceda28 avcodec/mvcdec: zero-initialize color array
Fixes MSAN use-of-uninitialized-value.

Signed-off-by: Marvin Scholz <epirat07@gmail.com>
(cherry picked from commit 3a5eb948e7)
2026-10-21 19:10:07 +00:00
James Almer
78f37c74b2 avcodec/libfdk-aacdec: clear and reset some fields when flushing
The decoder can't know where a seek landed, so the "delay_samples" way to
discard the decoder delay in the first frame is not truly viable, so it needs
to be removed.
Add a call to aacDecoder_DecodeFrame() with the AACDEC_CLRHIST flag set, as the
call to aacDecoder_SetParam() with the AAC_TPDEC_CLEAR_BUFFER setting was
seemingly not enough to truly flush all the fdkaac internal buffers.

Should fix issue #24527.

Signed-off-by: James Almer <jamrial@gmail.com>
(cherry picked from commit b894a6f7c1)
2026-09-19 21:16:46 -03:00
James Almer
374049720c avcodec/libfdk-aacdec: properly handle decoder delay
Shift timestamps when available, and take into account the caller requested
samples to be discarded alongside the decoder delay.

Should fix issue #24526.

Signed-off-by: James Almer <jamrial@gmail.com>
(cherry picked from commit c8595be8e6)
2026-09-19 21:16:45 -03:00
James Almer
a34013df6d avcodec/libfdk-aacdec: fix the check for downmix layout order
The code reads a mask afer this check, meaning it expects NATIVE order, not
others.

Signed-off-by: James Almer <jamrial@gmail.com>
(cherry picked from commit 7755d264bd)
2026-09-19 21:16:19 -03:00
James Almer
416d8cbaf9 avcodec/libfdk-aacdec: set keyframe flag and profile in output frames
Don't depend on the generic code setting this.
This is in preparation for a following change.

Signed-off-by: James Almer <jamrial@gmail.com>
(cherry picked from commit 281b7fc02e)
2026-09-19 21:16:19 -03:00
James Almer
f22d56bd5c avcodec/bsf/dca_core: clear profile value on init()
The output stream no longer has extension sub-streams, so the
declared input profile, if it was set, is no longer valid.

Fixes issue #24388.

Signed-off-by: James Almer <jamrial@gmail.com>
(cherry picked from commit 7dc71230a9)
2026-09-06 23:19:20 +00:00
Kacper Michajłow
a4f6f7588e avcodec/h264_direct: do not read the other field's rows of colocated mb_type
To determine whether the colocated picture is field coded, the temporal
and spatial direct setup peek at
sl->ref_list[1][0].parent->mb_type[mb_xy] before mb_xy has been remapped
to the colocated field's parity. That row belongs to the current field's
parity, while await_reference_mb_row() above waited on the parity of the
referenced field, so whenever the two differ the load is unsynchronised
and with frame threading can observe macroblocks of a field that is
still being decoded.

Every macroblock of a field picture has MB_TYPE_INTERLACED set, so
checking field_picture first gives the same result in all correctly
synchronized cases without touching the mb_type array.

This also fixes few TSAN reported warnings.

Fixes: https://trac.ffmpeg.org/ticket/10891
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
(cherry picked from commit c3a8a223b29260dc170d41c62f9b3b33f6b97b2d)
2026-08-26 00:42:47 +00:00
Kacper Michajłow
facf02226a avcodec/h264_slice: clear the ER picture when starting a second field
h264_frame_start() clears h->er.cur_pic, and decode_nal_units() only sets
it again for pictures that are not field coded, right before running error
concealment. A second field goes through neither, so h->er.cur_pic keeps
pointing at whatever frame coded picture the context decoded earlier.

With frame threading the two fields of a pair are decoded by different
contexts, so whether this triggers depends on what the context that picks
up the second field decoded before, which is why the number of bogus
warnings varies between runs.

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
(cherry picked from commit f1d318e5eb2eb487d2be4b4b721b93ae76fd5ba7)
2026-08-26 00:42:47 +00:00
Brad Smith
e21e475bdf avcodec/mips/cabac: Fix building on OpenBSD/mips64
src/libavcodec/mips/cabac.h:160:77: error: instruction requires a CPU feature not currently enabled
  160 |         PTR_SUBU   "%[tmp1],         %[c_low],        %[tmp1]             \n\t"
      |                                                                             ^
<inline asm>:13:2: note: instantiated into assembly here
   13 |         movz       $15,          $13,          $24
      |         ^

OpenBSD targets MIPS III ISA.

Signed-off-by: Brad Smith <brad@comstyle.com>
(cherry picked from commit 9432f85830)
2026-08-14 20:01:04 -04:00
Kacper Michajłow
c277e33a18 avcodec/h264_direct: await both fields of a colocated field pair
When a frame coded picture uses a complementary field pair as its
colocated picture, ff_h264_direct_ref_list_init() selects the field whose
POC is closest to the current one and stores it in col_parity. The direct
mode setup then remaps mb_xy to that parity and reads the colocated
mb_type, motion_val and ref_index from it.

await_reference_mb_row() waits on the field given by "ref_field_picture &&
ref_field", which is 1 for any such reference, since the pair is
referenced as a frame and ref->reference is 3. Only the bottom field is
therefore awaited, while the data is just as likely to be read from the
top one. With frame threading the two fields are decoded by different
threads, so the colocated data can be read while the field it belongs to
is still being decoded, yielding stale motion vectors and a corrupt
frame. await_references() already handles the same case correctly for
motion compensation.

Fixes sporadic failures of fate-h264-conformance-cabac_mot_picaff0_full,
where display frame 14.

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
(cherry picked from commit 274cb6731bd204e9537a7e588d4a3436fdf51b93)
2026-08-14 12:40:58 +00:00
Kacper Michajłow
c13d2d1152 avcodec/h264_direct: move check before loading things
(cherry picked from commit 029c80900e2b92a8495e36aa19d7fac9c55b8482)
2026-08-14 12:40:58 +00:00
James Almer
8b3467b31f avcodec/bsf/truehd_core: clear profile value on init()
The output stream no longer has Atmos metadata, so the
AV_PROFILE_TRUEHD_ATMOS profile, if it was set, is no longer valid.

Fixes issue #23195.

Signed-off-by: James Almer <jamrial@gmail.com>
(cherry picked from commit 86940d45af)
2026-07-30 21:51:43 -03:00
James Almer
6645ead5a5 avcodec/bsf/eac3_core: clear profile value on init()
The output stream no longer has Atmos metadata, so the
AV_PROFILE_EAC3_DDP_ATMOS profile, if it was set, is no longer valid.

Signed-off-by: James Almer <jamrial@gmail.com>
(cherry picked from commit c77c0e580a)
2026-07-30 21:51:43 -03:00
James Almer
8139862d3d avcodec/get_buffer: use frame pixel format instead of context
The documentation for get_buffer2() states:

"This callback must use the frame values, not the codec context values, to
calculate the required buffer size."

Fixes wrong output on hbd LCEVC enhanced samples where the base stream is
8bit.

Signed-off-by: James Almer <jamrial@gmail.com>
(cherry picked from commit e1c1b6c558)
2026-07-23 14:13:15 +00:00
Andreas Rheinhardt
67e4f737ed avcodec/cbs_sei: Always zero-initialize SEI payload
Fixes: Use-of-uninitialized value
Fixes: clusterfuzz-testcase-minimized-ffmpeg_BSF_H264_METADATA_fuzzer-5458626041413632

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
(cherry picked from commit bfcee368e2)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-20 17:42:28 +02:00
Reimar Döffinger
852b178240 avcodec/parser: Reset *buf_size on realloc failure
Fixes: out of array access
Fixes: crash-0d640731c7da52415670eb47a2af701cbe2e1a3b
Fixes: crash-e745864ead6ea418959c8df56de2765571201dae

Found-by: Catena cyber <contact@catenacyber.fr>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 605fc72f19)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-20 17:42:28 +02:00
Michael Niedermayer
52d9196ab2 avcodec/hevc/hevcdec: Clean sao_pixel_buffer_v on allocation
Fixes: use of uninitialized memory
Fixes: 378102648/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_HEVC_fuzzer-5896308499480576

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 7a21c37f75)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-20 17:42:28 +02:00
Michael Niedermayer
9ac8662ac0 avcodec/hevc/hevcdec: initialize qp_y_tab
This does not replicate on my setup, thus this is a blind fix based on ossfuzz trace

Fixes: use of uninitialized value
Fixes: 71747/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_HEVC_fuzzer-5427736120721408

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 4fc43e45f9)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-20 17:42:28 +02:00
Zhao Zhili
cc221d1551 aarch64/hpeldsp_neon: fix out-of-bounds read
Fix #21141

The performance improved a little bit.
On A76:
                              Before            After
put_pixels_tab[0][1]_neon:    32.4 ( 3.91x)     31.6 ( 3.99x)
put_pixels_tab[0][3]_neon:    88.0 ( 4.50x)     74.6 ( 5.31x)
put_pixels_tab[1][1]_neon:    33.5 ( 2.52x)     31.2 ( 2.71x)
put_pixels_tab[1][3]_neon:    30.5 ( 3.61x)     21.7 ( 5.08x)

On A55:
                             Before            After
put_pixels_tab[0][1]_neon:   175.2 ( 2.41x)    138.7 ( 3.04x)
put_pixels_tab[0][3]_neon:   334.3 ( 2.71x)    296.1 ( 3.07x)
put_pixels_tab[1][1]_neon:   168.3 ( 1.78x)     94.1 ( 3.19x)
put_pixels_tab[1][3]_neon:   112.3 ( 2.20x)     90.0 ( 2.74x)

(cherry picked from commit 840183d823)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-20 17:42:28 +02:00
James Almer
92bc9031be avcodec/jpeg2000dec: clear array length when freeing it
Fixes NULL pointer dereferences.
Fixes ticket #11393.

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: James Almer <jamrial@gmail.com>
(cherry picked from commit 7f9c7f9849)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-20 17:42:28 +02:00
Martin Storsjö
864ba88bbc av1dec: Don't crash if decoding of some frames have failed
If decoding with hwaccel, but decoding fails, these pointers
are null at this point.

Signed-off-by: Martin Storsjö <martin@martin.st>
(cherry picked from commit a27f3c590f)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-20 17:42:28 +02:00
Bogdan Lisman
5e1aefd045 avcodec/snowenc: fix SIGFPE in get_dc() when a block lies outside the plane
get_dc() divides the accumulated, OBMC-weighted DC by aa, the sum of the
squared OBMC weights taken over the in-plane pixels.  When an OBMC block
falls entirely outside the plane - e.g. a tiny chroma plane after mcdeint
splits a frame into fields - no pixel contributes, aa stays 0 and the
ROUNDED_DIV() divides by zero (SIGFPE).  ab is 0 in exactly the same case,
so the result degenerates to 0; return it directly.

Reproducible with the GPL mcdeint filter in slow/extra_slow mode, e.g.

    ffmpeg -f lavfi -i testsrc=s=128x2 -vf mcdeint=mode=slow -f null -

Add a self-contained lavfi-based FATE regression test for the slow mode,
which previously crashed and is therefore not covered by the existing
sample-based fast/medium tests.

Fixes trac ticket #7779.

Signed-off-by: Bogdan Lisman <bogdan@pydevsolutions.com>
(cherry picked from commit a62d996927)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-17 03:41:40 +02:00
Michael Niedermayer
4616870a87 avcodec/snowenc: fix out-of-bounds OBMC read in get_dc() for narrow planes
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 30c6667dad)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-17 03:34:05 +02:00
Bogdan Lisman
04bc39441d avcodec/snowenc: fix out-of-bounds memcpy in get_block_rd() for narrow planes
For an edge block, get_block_rd() copies the full-OBMC-weight central
region directly from cur[] into the reconstruction.  It moved one
boundary to block_w/block_h but overwrote the in-plane clip (x0/x1/y0/y1
computed earlier from the plane size) instead of intersecting with it.
When a plane is narrower than block_w - e.g. a tiny field/chroma plane
produced by the mcdeint filter - the right-edge case left x0 = block_w
while x1 stayed clipped to w - sx < block_w, so x1 - x0 became negative
and was passed to memcpy() as a huge size_t, crashing with SIGSEGV.

Intersect the moved boundaries with the existing clip so the copy region
stays inside the plane and the memcpy length can never be negative.

Reproducible with the GPL mcdeint filter in slow/extra_slow mode, e.g.

    ffmpeg -f lavfi -i testsrc=s=5x32 -vf mcdeint=mode=slow -f null -

This is a separate crash from the get_dc() SIGFPE (ticket #7779) reached
through the same iterative_me() path.  Add a lavfi-based FATE regression
test.

Signed-off-by: Bogdan Lisman <bogdan@pydevsolutions.com>
(cherry picked from commit 1168447626)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-17 01:34:13 +02:00
Michael Niedermayer
3483911d58 avcodec/cbs_av1_syntax_template: reset seen_frame_header on sequence
headers

With this change CBS and the decoder appear to be in sync.

Fixes: division by 0

Fixes: 501794431/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_AV1_fuzzer-4792576644546560
Fixes: 501898692/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_AV1_fuzzer-4772278394224640
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 fd290e2fcd)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-15 23:50:43 +02:00
James Almer
bc74f7a6fa avcodec/cbs_h266_syntax_template: reject subpic info with res_change_in_clvs
Found-by: Anthony Hurtado
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 0cf9169c85)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 2859534720bf9d8377129aedf880eb3750ede467)
2026-06-14 20:01:25 +02:00
Michael Niedermayer
c0b34f9eac avcodec/misc4: Check nb channels
Found-by: Forgejo Fairy
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 7b717fe50d)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 024a019649c576afe33621cfee8398f1bb405faa)
2026-06-14 20:01:25 +02:00
Michael Niedermayer
de1ef7c9a6 avcodec/rv10, rv34: check init_get_bits8() before RealVideo bit access
Found-by: Samarth Kumbla <samarthk@cantina.security>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 0c662529f6)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 916b4081ccdbffb646d7644f23b5b834eb8c0dd0)
2026-06-14 20:01:25 +02:00
David Korczynski
5431238945 avcodec/agm: validate actual src_y against prev plane in decode_inter_plane
Found-by: Anthropic agents; validated and reported by Ada Logics.

Signed-off-by: David Korczynski <david@adalogics.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 4527854281)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit dbfe1e3b662381e33c61df5ee4c527bb5905c141)
2026-06-14 20:01:13 +02:00
Michael Niedermayer
e3a3abeb4a avcodec/hevc/ps: Check window parameters
Fixes: signed integer overflow: -1094995529 * 2 cannot be represented in type 'int'
Fixes: 484567435/clusterfuzz-testcase-minimized-ffmpeg_dem_HXVS_fuzzer-5628836988649472

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 82f097c825)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 3b94b6f863dfb9b7193047e5da6707213563a02a)
2026-06-14 20:01:01 +02:00
Michael Niedermayer
5986b500b2 avcodec/hevc/ps: Factor window reading out
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 8c868a1fd2)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 04b3060413fcfed3e31f3b9197779e75e38faf33)
2026-06-14 20:01:01 +02:00
David Korczynski
e2fb95fd68 avcodec/truespeech: reject iterations count whose * 240 product overflows 32-bit
Found-by: Anthropic agents; validated and reported by Ada Logics.
Signed-off-by: David Korczynski <david@adalogics.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit d30dead35e)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 5251f49710950561a85e49b2b2f43500c04ccf22)
2026-06-14 20:01:01 +02:00
David Korczynski
6bb2d6999b avcodec/on2avc: reject subframe count whose * SUBFRAME_SIZE product overflows 32-bit
Found-by: Anthropic agents; validated and reported by Ada Logics.
Signed-off-by: David Korczynski <david@adalogics.com>
(cherry picked from commit 331b3e9dea)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 9651473d00a51a199811afdda1fe299ed5895729)
2026-06-14 20:00:38 +02:00
Michael Niedermayer
eacf21e6d1 avcodec/adpcm: fix signed integer overflow in get_nb_samples()
Fixes: signed integer overflow: 314572800 * 8 cannot be represented in type 'int'

Tighten the guard to INT_MAX/14, which covers the largest expansion
factor used in the function currently.

Found-by: Jiale Yao <19888972804@163.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 04e2341056)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit c4215fb9a085afcccbbcbb8eb98826eb44ba45c6)
2026-06-14 20:00:38 +02:00
David Korczynski
d3052a2145 avcodec/fastaudio: reject subframes count whose * 256 product overflows 32-bit
fastaudio_decode() computes
    subframes = pkt->size / (40 * channels);
    frame->nb_samples = subframes * 256;
both as 32-bit signed multiplications. When pkt->size is large enough
to make subframes >= 2^24, the second multiplication overflows the
signed int range and frame->nb_samples wraps to a small value.
ff_get_buffer() then sizes the audio plane for that wrapped sample
count, while the decoder loop at line 152 still iterates the full
(unwrapped) subframes count, performing a 1024-byte memcpy per
subframe per channel. The 27th iteration (or first iteration with
nb_samples=0) writes one byte past the per-plane allocation,
yielding the ASan heap-buffer-overflow WRITE at libavcodec/fastaudio
.c:171 reported as ANT-2026-03891.

Reject the subframes value whose *256 product would overflow before
performing the multiplication. The bound INT_MAX / 256 (= 8388607)
keeps the existing two's-complement semantics of every reachable
input and rejects only the configurations that would have wrapped.

Reproducer: a crafted AVI declaring one mono audio chunk of
671_088_680 bytes (sparse) with the decoder forced via
'ffmpeg -c:a fastaudio -i evil.avi'.

Found-by: Anthropic agents; validated and reported by Ada Logics.

Signed-off-by: David Korczynski <david@adalogics.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 1e9984772b)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 3a6d2606de8c106a0d5c7d2e82e1be6cdb07f187)
2026-06-14 20:00:38 +02:00
Michael Niedermayer
2985b5b541 avcodec/vc2enc_dwt: avoid signed overflow in the 9/7 DWT lifting
Fixes: 490488944/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_VC2_fuzzer-5310290362433536
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 5f91556215)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 02d8fdcb43cf6527914b2aa4a6225e3ec8bcd689)
2026-06-14 20:00:37 +02:00
Michael Niedermayer
5eaa817dac avcodec/vc2enc_dwt: avoid signed overflow in the 5/3 and Haar DWT
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 7c7ca349bc)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 5a32352bb66904b8dbeb2169f02456cdfbca2608)
2026-06-14 20:00:37 +02:00
Michael Niedermayer
ed158d187f avcodec/mwsc: do not dereference a missing reference frame
Fixes: 493841393/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_MWSC_fuzzer-5079884677578752
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 ba825ce85f)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit c0b4c7fac0f7f048584b5fc6bac3fe909fbbd3d1)
2026-06-14 20:00:37 +02:00
Michael Niedermayer
b94bb7de20 avcodec/misc4: reject invalid sample rate
Fixes: AVERROR_BUG

Fixes: 493055111/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_MISC4_fuzzer-5752676962074624
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 32eb07bb83)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 6d0a286a1a0ce370e906d014da47617a73414f97)
2026-06-14 20:00:37 +02:00
Anthony Hurtado
e336234f90 avcodec/diracdec: fix heap buffer overflow in edge_emu_buffer
Fixes: poc_dirac_v2_*
(cherry picked from commit 495b402f27)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit bf4e7984c18d447d762b4365ecd755e2ab64e4e7)
2026-06-14 20:00:25 +02:00
Michael Niedermayer
b8c5d2a85f avcodec/jpeglsdec: only apply color transform to decoded rows
Fixes: Timeout
Fixes: 503996733/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_MJPEG_DEC_fuzzer-4948713016721408
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 3669a742dd)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit f6b60eed07b96ac01473b24df85eb764e1f1638e)
2026-06-14 20:00:25 +02:00
Michael Niedermayer
fcf2dcead1 avcodec/aac/aacdec: reject decoded frame without a valid sample rate
Later code will turn this into AVERROR_BUG

When returning sample_rate == 0 samples is considered a bug, we have no
nice choice but to error out cleanly

Fixes: assertion failure
Fixes: ffmpeg_AV_CODEC_ID_AAC_DEC_fuzzer crash-0a86d46fef2442b222ee34403c21f7f582ffccb0
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit e711e60827)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-14 19:38:57 +02:00
James Almer
de03bce1b8 avcodec/cbs_h266_syntax_template: Fix pps_exp_slice_height_in_ctus_minus1 range
Found-by: Claude (Anthropic). Human-verified and reported by Omkhar Arasaratnam <omkhar@linkedin.com>.

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit bf608f16fd)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-14 19:38:56 +02:00
Frank Plowman
ae0908a0c2 lavc/vvc: Stricter bound on pps_exp_slice_height_in_ctus_minus1
When pps_num_exp_slices_in_tile[i] is nonzero, the ith tile is made up
of pps_num_exp_slices_in_tile[i] slices stacked atop one another, where
the height of the jth slice in the ith tile is given by
pps_exp_slice_height_in_ctus_minus1[i][j].  The sum of the heights of
the slices in the tile should not exceed the height of the tile itself.

Signed-off-by: Frank Plowman <post@frankplowman.com>
2026-06-14 19:38:56 +02:00
David Korczynski
3fc2073945 avcodec/cook: bound subpacket channel sum against channel count
Fixes: out of array read
Fixes: evil.rm

Found-by: Anthropic agents; validated and reported by Ada Logics.

Signed-off-by: David Korczynski <david@adalogics.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 1152139b48)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-14 19:38:55 +02:00
Michael Niedermayer
d960f78135 avcodec/jpeg2000dec: Clear header derived variables
Fixes: NULL pointer dereference

Found-by: Oguzhan Akkaya with AFL++ fuzzing (May 2026)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 6631bbc5d4)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-14 19:38:54 +02:00
Hassan Hany
9d0a977120 avcodec/x86/vorbisdsp: change cmpleps to cmpltps in inverse coupling
Changed the comparison from cmpleps to strictly less than
(cmpltps) to strictly follow the Vorbis spec

Fixes https://code.ffmpeg.org/FFmpeg/FFmpeg/issues/21501

(cherry picked from commit 9288681068)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-14 19:38:54 +02:00
Franciszek Kalinowski
b47f49586c avcodec/h264_slice: guard color_frame() against chroma-width underflow
In the >= 9 bit path, color_frame() does
`av_memcpy_backptr(dst + 2, 2, bytes - 2)`. When the effective chroma width
is 1 pixel (bytes == 1) the count becomes -1 and the underlying fill16()
loop runs roughly 2^32 times, producing a heap overflow. The original count
was also wrong in units (pixels rather than bytes); fix that at the same
time so the 2-pixel case still fills both pixels.

Confirmed via a standalone harness reproducing av_memcpy_backptr's fill16
loop with cnt = -1; reaching the call from a crafted H.264 bitstream
requires Hi10P plus a frame_num gap on a frame whose effective chroma width
is 1 pixel, which is hard to express but is reachable via mid-stream SPS
changes. Compiles cleanly; no regressions seen running existing crafted
H.264 PoCs and trivial transcodes.

Reported by Franciszek Kalinowski (isec.pl / striga.ai) and Bartosz Smigielski.

(cherry picked from commit c79dfd29e6)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-14 19:38:54 +02:00
Ori Hollander
e74d0cbd86 avcodec/magicyuv: reject slice_height misaligned with chroma vshift
Fixes: poc_magicyuv.avi
Fixes: out of array access

Found-by: Ori Hollander of the JFrog Vulnerability Research team
(cherry picked from commit 374b726ffa)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-14 19:38:53 +02:00
Michael Niedermayer
0cc12e43cb avcodec/magicyuv: Expand the s->interlaced slice-height sanity check
Fixes: poc_magicyuv.avi
Fixes: out of array access

Found-by: Ori Hollander of the JFrog Vulnerability Research team
(cherry picked from commit 5806e8b9f3)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-14 19:38:53 +02:00