From b0b7e7fa7a48485c4d6b0ae64bfddedd519716f5 Mon Sep 17 00:00:00 2001
From: =?utf-8?q?Bastien_Roucari=C3=A8s?= <rouca@debian.org>
Date: Sun, 16 Mar 2025 23:25:15 +0100
Subject: [PATCH] CVE-2023-32627 Filter null sampling rate in VOC coder

Source: https://salsa.debian.org/lts-team/packages/sox/-/blob/debian/14.4.2+git20190427-1+deb10u3/debian/patches/0028-CVE-2023-32627-Filter-null-sampling-rate-in-VOC-code.patch

CVE: CVE-2023-32627
Upstream-Status: Inactive-Upstream [lastrelease: 2015]
Signed-off-by: Peter Marko <peter.marko@siemens.com>
---
 src/voc.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/src/voc.c b/src/voc.c
index 0ca07f94..d8b982c5 100644
--- a/src/voc.c
+++ b/src/voc.c
@@ -353,6 +353,11 @@ static size_t read_samples(sox_format_t * ft, sox_sample_t * buf,
             v->block_remaining = 0;
             return done;
           }
+          if(uc == 0) {
+            lsx_fail_errno(ft, EINVAL, "invalid rate value");
+            v->block_remaining = 0;
+            return done;
+          }
           *buf = SOX_UNSIGNED_8BIT_TO_SAMPLE(uc,);
           lsx_adpcm_init(&v->adpcm, 6 - v->size, SOX_SAMPLE_TO_SIGNED_16BIT(*buf, ft->clips));
           ++buf;
