[PR] avcodec/riscv/flacdsp: guard the LPC loops against len <= pred_order (PR #23630)

michaelni via ffmpeg-devel <[email protected]>
Newsgroups gmane.comp.video.ffmpeg.devel
Message-ID <178269072838.59.8811734201523000441@29965ddac10e>
PR #23630 opened by michaelni
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/23630
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/23630.patch

Fixes: out of array write
Fixes: nxPpr3NozEXk
Fixes: ca664f2254 (lavc/flacdsp: R-V V LPC16 function)
Found-by: Clouditera Security, Z.ai Security, NSFOCUS
Signed-off-by: Michael Niedermayer <[email protected]>



>From 9e3f64d474f8bc6fb18a6bbb457b39c04b09101a Mon Sep 17 00:00:00 2001
From: Michael Niedermayer <[email protected]>
Date: Sun, 28 Jun 2026 23:05:56 +0200
Subject: [PATCH] avcodec/riscv/flacdsp: guard the LPC loops against len <=
 pred_order

Fixes: out of array write
Fixes: nxPpr3NozEXk
Fixes: ca664f2254 (lavc/flacdsp: R-V V LPC16 function)
Found-by: Clouditera Security, Z.ai Security, NSFOCUS
Signed-off-by: Michael Niedermayer <[email protected]>
---
 libavcodec/riscv/flacdsp_rvv.S | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/libavcodec/riscv/flacdsp_rvv.S b/libavcodec/riscv/flacdsp_rvv.S
index a927f188d3..e24ecbeddd 100644
--- a/libavcodec/riscv/flacdsp_rvv.S
+++ b/libavcodec/riscv/flacdsp_rvv.S
@@ -26,6 +26,7 @@ func ff_flac_lpc16_rvv, zve32x, b
         vsetvl  zero, a2, t0
         vle32.v v8, (a1)
         sub     a4, a4, a2
+        blez    a4, 2f
         vle32.v v16, (a0)
         sh2add  a0, a2, a0
         vmv.s.x v0, zero
@@ -42,6 +43,7 @@ func ff_flac_lpc16_rvv, zve32x, b
         addi    a0, a0, 4
         bnez    a4, 1b
 
+2:
         ret
 endfunc
 
@@ -55,6 +57,7 @@ func ff_flac_lpc32_rvv, zve64x, zba
         vsetvli zero, a2, e32, m8, ta, ma
         vle32.v v8, (a1)
         sub     a4, a4, a2
+        blez    a4, 2f
         vle32.v v16, (a0)
         sh2add  a0, a2, a0
 1:
@@ -75,6 +78,7 @@ func ff_flac_lpc32_rvv, zve64x, zba
         addi    a0, a0, 4
         bnez    a4, 1b
 
+2:
         ret
 endfunc
 
@@ -87,6 +91,7 @@ func ff_flac_lpc32_rvv_simple, zve64x, b
         vsetvl  zero, zero, t2 // e32
         vle32.v v8, (a1)
         sub     a4, a4, a2
+        blez    a4, 2f
         vle32.v v16, (a0)
         sh2add  a0, a2, a0
 1:
@@ -104,6 +109,7 @@ func ff_flac_lpc32_rvv_simple, zve64x, b
         addi    a0, a0, 4
         bnez    a4, 1b
 
+2:
         ret
 endfunc
 
@@ -115,6 +121,7 @@ func ff_flac_lpc33_rvv, zve64x, b
         sh2add  a1, a3, a1
         vle32.v v24, (a2)
         sub     a5, a5, a3
+        blez    a5, 2f
         vle64.v v16, (a0)
         sh3add  a0, a3, a0
         vsext.vf2 v8, v24
@@ -132,6 +139,7 @@ func ff_flac_lpc33_rvv, zve64x, b
         addi    a0, a0, 8
         bnez    a5, 1b
 
+2:
         ret
 endfunc
 #endif
-- 
2.52.0

_______________________________________________
ffmpeg-devel mailing list -- [email protected]
To unsubscribe send an email to [email protected]
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.