switch audio/sox from the seemingly stalled origonal upstream to 14.4.4

from the sox-ng fork. (they have newer branches too, but let's go one step
at a time, this one has conservative changes including many possibly
security-related).

the library name changes; other ports using this will be synced in the
following commit.

ok tb@, maintainer timeout
This commit is contained in:
sthen
2025-06-30 08:58:27 +00:00
parent 5bc9fec066
commit 5c3f631f43
10 changed files with 35 additions and 312 deletions
+15 -40
View File
@@ -1,11 +1,9 @@
COMMENT= Sound eXchange, the Swiss Army knife of audio manipulation
V= 14.4.2pl20210509
# see AC_INIT in ${WRKSRC}/configure.ac
GIT_V= 14.4.3git
DISTNAME= sox-${V}
SHARED_LIBS += sox 4.1 # 3.0
REVISION= 2
V= 14.4.4
DISTNAME= sox_ng-${V}
PKGNAME= sox-${V}
SHARED_LIBS += sox_ng 0.0 # 3.0
CATEGORIES= audio
HOMEPAGE= https://sox.sourceforge.net/
@@ -14,18 +12,13 @@ MAINTAINER= Jan Stary <hans@stare.cz>
# GPLv2+
PERMIT_PACKAGE= Yes
WANTLIB += c m z sndio
WANTLIB += FLAC gsm mad id3tag mp3lame ogg
WANTLIB += c crypto m pthread sndio z
WANTLIB += FLAC gsm mad mpg123 id3tag mp3lame ogg
WANTLIB += sndfile vorbis vorbisenc vorbisfile
WANTLIB += opusfile twolame wavpack
WANTLIB += opus opusfile twolame wavpack
WANTLIB += png
GITWEB_URL= https://sourceforge.net/code-snapshots/git
GIT_COMMIT= 42b3557e13e0fe01a83465b672d89faddbe65f49
# mirror git checkout as tarball for latest fixes until new release.
# see dist: target and `make dist' to generate tarball.
SITES= https://messagemode2.com/source/
SITES= https://codeberg.org/sox_ng/sox_ng/releases/download/sox_ng-$V/
# see CONFIGURE_ARGS below
LIB_DEPENDS= \
@@ -45,10 +38,12 @@ LIB_DEPENDS= \
CONFIGURE_STYLE=gnu
CONFIGURE_ARGS= --datarootdir=${LOCALBASE} \
--enable-largefile \
--enable-replace \
--enable-symlinks \
--without-libltdl \
--disable-openmp \
--with-distro=OpenBSD
--with-distro=OpenBSD \
--without-sunaudio
# Sound drivers
CONFIGURE_ARGS+= \
@@ -56,7 +51,7 @@ CONFIGURE_ARGS+= \
--disable-oss \
--disable-alsa \
--disable-coreaudio \
--disable-pulseaudio \
--without-pulseaudio \
--disable-waveaudio \
--disable-sunaudio \
--enable-sndio
@@ -85,33 +80,13 @@ CONFIGURE_ARGS+= \
--without-ladspa
CONFIGURE_ENV= \
CPPFLAGS="-I${LOCALBASE}/include" \
CPPFLAGS="-I${LOCALBASE}/include -I${LOCALBASE}/include/opus" \
LDFLAGS="-L${LOCALBASE}/lib"
# requires: autoconf-2.69, automake-1.16, devel/libtool, textproc/groff and
# devel/autoconf-archive
dist:
ftp -o /tmp/sox-code-${GIT_COMMIT}.zip \
${GITWEB_URL}/s/so/sox/code.git/sox-code-${GIT_COMMIT}.zip; \
t=`mktemp -d /tmp/sox.XXXXXXXXXX`; \
f=$$t/sox-code-${GIT_COMMIT}/${DISTNAME}.tar.gz; \
ac_v=2.69; \
am_v=1.16; \
cd $$t; \
unzip /tmp/sox-code-${GIT_COMMIT}.zip; \
cd sox-code-${GIT_COMMIT}; \
echo "EXTRA_DIST += libsox.sym" >> ./src/Makefile.am; \
sed -ie "s/${GIT_V}/${V}/g" ./configure.ac; \
env -i AUTOCONF_VERSION=$$ac_v AUTOMAKE_VERSION=$$am_v \
autoreconf-$$ac_v -i && \
./configure && \
${MAKE_PROGRAM} dist; \
scp $$f train:source/; \
cd -; rm -rf $$t; rm -f /tmp/sox-code-${GIT_COMMIT}.zip;
post-install:
rm -f ${PREFIX}/lib/libsox.so
do-test:
@cd ${WRKSRC}/src && ${MAKE_PROGRAM} ${MAKE_FLAGS} \
-f ${MAKE_FILE} extras
@cd ${WRKSRC}/src && ./tests.sh && ./testall.sh
.include <bsd.port.mk>
+2 -2
View File
@@ -1,2 +1,2 @@
SHA256 (sox-14.4.2pl20210509.tar.gz) = SCj3mkHxutMo9TsSL4tp42jquTRfcMuEiE3hI9KDhm8=
SIZE (sox-14.4.2pl20210509.tar.gz) = 1013682
SHA256 (sox_ng-14.4.4.tar.gz) = wiI8+A4B7l2cBWIshRVDjDsibZ6jEpiowtMDZuB1ju0=
SIZE (sox_ng-14.4.4.tar.gz) = 1669531
-17
View File
@@ -1,17 +0,0 @@
https://marc.info/?l=oss-security&m=167571683504082&w=2
Index: src/aiff.c
--- src/aiff.c.orig
+++ src/aiff.c
@@ -619,6 +619,11 @@ int lsx_aiffstartwrite(sox_format_t * ft)
At 48 kHz, 16 bits stereo, this gives ~3 hours of audio.
Sorry, the AIFF format does not provide for an indefinite
number of samples. */
+ if (ft->signal.channels >= (0x7f000000 / (ft->encoding.bits_per_sample >> 3)))
+ {
+ lsx_fail_errno(ft, SOX_EOF, "too many channels for AIFF header");
+ return SOX_EOF;
+ }
return(aiffwriteheader(ft, (uint64_t) 0x7f000000 / ((ft->encoding.bits_per_sample>>3)*ft->signal.channels)));
}
+1 -20
View File
@@ -1,18 +1,7 @@
https://marc.info/?l=oss-security&m=167571683504082&w=2
Index: src/formats.c
--- src/formats.c.orig
+++ src/formats.c
@@ -360,7 +360,7 @@ static int sox_checkformat(sox_format_t * ft)
return SOX_SUCCESS;
}
-static sox_bool is_url(char const * text) /* detects only wget-supported URLs */
+static sox_bool is_url(char const * text)
{
return !(
strncasecmp(text, "http:" , (size_t)5) &&
@@ -442,7 +442,7 @@ static FILE * xfopen(char const * identifier, char con
@@ -392,7 +392,7 @@ static FILE * xfopen(char const * identifier, char con
else if (is_url(identifier)) {
FILE * f = NULL;
#ifdef HAVE_POPEN
@@ -21,11 +10,3 @@ Index: src/formats.c
char * command = lsx_malloc(strlen(command_format) + strlen(identifier));
sprintf(command, command_format, identifier);
f = popen(command, POPEN_MODE);
@@ -627,6 +627,7 @@ error:
free(ft->priv);
free(ft->filename);
free(ft->filetype);
+ sox_delete_comments(&ft->oob.comments);
free(ft);
return NULL;
}
-42
View File
@@ -1,42 +0,0 @@
https://marc.info/?l=oss-security&m=167571683504082&w=2
Index: src/formats_i.c
--- src/formats_i.c.orig
+++ src/formats_i.c
@@ -19,6 +19,7 @@
*/
#include "sox_i.h"
+#include <limits.h>
#include <string.h>
#include <sys/stat.h>
#include <stdarg.h>
@@ -60,13 +61,24 @@ int lsx_check_read_params(sox_format_t * ft, unsigned
if (ft->seekable)
ft->data_start = lsx_tell(ft);
- if (channels && ft->signal.channels && ft->signal.channels != channels)
+ if (channels && ft->signal.channels && ft->signal.channels != channels) {
lsx_warn("`%s': overriding number of channels", ft->filename);
- else ft->signal.channels = channels;
+ } else if (channels > SHRT_MAX) {
+ lsx_fail_errno(ft, EINVAL, "implausibly large number of channels");
+ return SOX_EOF;
+ } else {
+ ft->signal.channels = channels;
+ }
- if (rate && ft->signal.rate && ft->signal.rate != rate)
+ if (rate && ft->signal.rate && ft->signal.rate != rate) {
lsx_warn("`%s': overriding sample rate", ft->filename);
- else ft->signal.rate = rate;
+ /* Since NaN comparisons yield false, the negation rejects them. */
+ } else if (!(rate > 0)) {
+ lsx_fail_errno(ft, EINVAL, "invalid rate value");
+ return SOX_EOF;
+ } else {
+ ft->signal.rate = rate;
+ }
if (encoding && ft->encoding.encoding && ft->encoding.encoding != encoding)
lsx_warn("`%s': overriding encoding type", ft->filename);
-57
View File
@@ -1,57 +0,0 @@
https://marc.info/?l=oss-security&m=167571683504082&w=2
Index: src/hcom.c
--- src/hcom.c.orig
+++ src/hcom.c
@@ -141,6 +141,11 @@ static int startread(sox_format_t * ft)
return (SOX_EOF);
}
lsx_readw(ft, &dictsize);
+ if (dictsize == 0 || dictsize > 511)
+ {
+ lsx_fail_errno(ft, SOX_EHDR, "Implausible dictionary size in HCOM header");
+ return SOX_EOF;
+ }
/* Translate to sox parameters */
ft->encoding.encoding = SOX_ENCODING_HCOM;
@@ -161,13 +166,18 @@ static int startread(sox_format_t * ft)
p->dictionary[i].dict_rightson);
if (!dictvalid(i, dictsize, p->dictionary[i].dict_leftson,
p->dictionary[i].dict_rightson)) {
+ free(p->dictionary);
+ p->dictionary = NULL;
lsx_fail_errno(ft, SOX_EHDR, "Invalid dictionary");
return SOX_EOF;
}
}
rc = lsx_skipbytes(ft, (size_t) 1); /* skip pad byte */
- if (rc)
+ if (rc) {
+ free(p->dictionary);
+ p->dictionary = NULL;
return rc;
+ }
/* Initialized the decompression engine */
p->checksum = checksum;
@@ -249,6 +259,9 @@ static int stopread(sox_format_t * ft)
{
register priv_t *p = (priv_t *) ft->priv;
+ free(p->dictionary);
+ p->dictionary = NULL;
+
if (p->huffcount != 0)
{
lsx_fail_errno(ft,SOX_EFMT,"not all HCOM data read");
@@ -259,8 +272,7 @@ static int stopread(sox_format_t * ft)
lsx_fail_errno(ft,SOX_EFMT,"checksum error in HCOM data");
return (SOX_EOF);
}
- free(p->dictionary);
- p->dictionary = NULL;
+
return (SOX_SUCCESS);
}
-25
View File
@@ -1,25 +0,0 @@
https://marc.info/?l=oss-security&m=167571683504082&w=2
Index: src/sphere.c
--- src/sphere.c.orig
+++ src/sphere.c
@@ -63,7 +63,8 @@ static int start_read(sox_format_t * ft)
return (SOX_EOF);
}
- header_size -= (strlen(buf) + 1);
+ bytes_read = strlen(buf);
+ header_size -= bytes_read >= header_size ? header_size : bytes_read + 1;
while (strncmp(buf, "end_head", (size_t)8) != 0) {
if (strncmp(buf, "sample_n_bytes", (size_t)14) == 0)
@@ -105,7 +106,8 @@ static int start_read(sox_format_t * ft)
return (SOX_EOF);
}
- header_size -= (strlen(buf) + 1);
+ bytes_read = strlen(buf);
+ header_size -= bytes_read >= header_size ? header_size : bytes_read + 1;
}
if (!bytes_per_sample)
-16
View File
@@ -1,16 +0,0 @@
https://marc.info/?l=oss-security&m=167571683504082&w=2
Index: src/voc.c
--- src/voc.c.orig
+++ src/voc.c
@@ -625,6 +625,10 @@ static int getblock(sox_format_t * ft)
v->rate = new_rate_32;
ft->signal.rate = new_rate_32;
lsx_readb(ft, &uc);
+ if (uc <= 1) {
+ lsx_fail_errno(ft, SOX_EFMT, "2 bits per word required");
+ return (SOX_EOF);
+ }
v->size = uc;
lsx_readb(ft, &uc);
if (v->channels != -1 && uc != v->channels) {
-91
View File
@@ -1,91 +0,0 @@
https://marc.info/?l=oss-security&m=167571683504082&w=2
unbreak wav gsm
see:
https://marc.info/?l=oss-security&m=167882517702862&w=2
https://marc.info/?l=oss-security&m=168026419507884&w=2
Index: src/wav.c
--- src/wav.c.orig
+++ src/wav.c
@@ -654,6 +654,15 @@ static int wav_read_fmt(sox_format_t *ft, uint32_t len
if (err)
return SOX_EOF;
+ if (wav->bitsPerSample == 0
+#ifdef HAVE_LIBGSM
+ && wav->formatTag != WAVE_FORMAT_GSM610
+#endif
+ ){
+ lsx_fail_errno(ft, SOX_EHDR, "WAV file bits per sample is zero");
+ return SOX_EOF;
+ }
+
/* non-PCM formats except alaw and mulaw formats have extended fmt chunk.
* Check for those cases.
*/
@@ -963,7 +972,11 @@ static int startread(sox_format_t *ft)
#endif
}
- if (!wav->numSamples)
+ if (!wav->numSamples
+#ifdef HAVE_LIBGSM
+ && wav->formatTag != WAVE_FORMAT_GSM610
+#endif
+ )
wav->numSamples = div_bits(qwDataLength, ft->encoding.bits_per_sample)
/ ft->signal.channels;
@@ -1348,8 +1361,10 @@ static int wavwritehdr(sox_format_t * ft, int second_h
(dwSamplesWritten + wSamplesPerBlock - 1) / wSamplesPerBlock;
dwDataLength = blocksWritten * wBlockAlign;
+#ifdef HAVE_LIBGSM
if (wFormatTag == WAVE_FORMAT_GSM610)
dwDataLength = (dwDataLength+1) & ~1u; /* round up to even */
+#endif
if (wFormatTag == WAVE_FORMAT_PCM && (wBitsPerSample > 16 || wChannels > 2)
&& strcmp(ft->filetype, "wavpcm")) {
@@ -1444,9 +1459,11 @@ static int wavwritehdr(sox_format_t * ft, int second_h
lsx_writew(ft, (uint16_t)(lsx_ms_adpcm_i_coef[i][1]));
}
break;
+#ifdef HAVE_LIBGSM
case WAVE_FORMAT_GSM610:
lsx_writew(ft, wSamplesPerBlock);
break;
+#endif
default:
break;
}
@@ -1554,7 +1571,9 @@ static int stopwrite(sox_format_t * ft)
/* Add a pad byte if the number of data bytes is odd.
See wavwritehdr() above for the calculation. */
+#ifdef HAVE_LIBGSM
if (wav->formatTag != WAVE_FORMAT_GSM610)
+#endif
lsx_padbytes(ft, (size_t)((wav->numSamples + wav->samplesPerBlock - 1)/wav->samplesPerBlock*wav->blockAlign) % 2);
free(wav->packet);
@@ -1594,6 +1613,7 @@ static int seek(sox_format_t * ft, uint64_t offset)
if (ft->encoding.bits_per_sample & 7)
lsx_fail_errno(ft, SOX_ENOTSUP, "seeking not supported with this encoding");
+#ifdef HAVE_LIBGSM
else if (wav->formatTag == WAVE_FORMAT_GSM610) {
int alignment;
size_t gsmoff;
@@ -1613,7 +1633,9 @@ static int seek(sox_format_t * ft, uint64_t offset)
new_offset += (wav->samplesPerBlock - alignment);
wav->numSamples = ft->signal.length - (new_offset / ft->signal.channels);
}
- } else {
+ }
+#endif /* HAVE_LIBGSM */
+ else {
double wide_sample = offset - (offset % ft->signal.channels);
double to_d = wide_sample * ft->encoding.bits_per_sample / 8;
off_t to = to_d;
+17 -2
View File
@@ -2,18 +2,33 @@
@pkgpath audio/sox,mp3,vorbis
@pkgpath audio/sox,vorbis
bin/play
bin/play_ng
bin/rec
@bin bin/sox
bin/rec_ng
bin/sox
@bin bin/sox_ng
bin/soxi
bin/soxi_ng
include/sox.h
include/sox_ng.h
@static-lib lib/libsox.a
lib/libsox.la
@lib lib/libsox.so.${LIBsox_VERSION}
@static-lib lib/libsox_ng.a
lib/libsox_ng.la
@lib lib/libsox_ng.so.${LIBsox_ng_VERSION}
lib/pkgconfig/sox.pc
lib/pkgconfig/sox_ng.pc
@man man/man1/play.1
@man man/man1/play_ng.1
@man man/man1/rec.1
@man man/man1/rec_ng.1
@man man/man1/sox.1
@man man/man1/sox_ng.1
@man man/man1/soxi.1
@man man/man1/soxi_ng.1
@man man/man3/libsox.3
@man man/man3/libsox_ng.3
@man man/man7/soxeffect.7
@man man/man7/soxeffect_ng.7
@man man/man7/soxformat.7
@man man/man7/soxformat_ng.7