PR pkg/56800 hitting v or V during sox's play command causes a segfault from Onno van der Lindendiff -r1.69 -r1.70 pkgsrc/audio/sox/Makefile
(nia)
@@ -1,17 +1,17 @@ | @@ -1,17 +1,17 @@ | |||
1 | # $NetBSD: Makefile,v 1.69 2022/03/28 10:43:39 tnn Exp $ | 1 | # $NetBSD: Makefile,v 1.70 2022/04/24 09:39:46 nia Exp $ | |
2 | 2 | |||
3 | DISTNAME= sox-14.4.2 | 3 | DISTNAME= sox-14.4.2 | |
4 | PKGREVISION= 4 | 4 | PKGREVISION= 5 | |
5 | CATEGORIES= audio | 5 | CATEGORIES= audio | |
6 | MASTER_SITES= ${MASTER_SITE_SOURCEFORGE:=sox/} | 6 | MASTER_SITES= ${MASTER_SITE_SOURCEFORGE:=sox/} | |
7 | 7 | |||
8 | MAINTAINER= pkgsrc-users@NetBSD.org | 8 | MAINTAINER= pkgsrc-users@NetBSD.org | |
9 | HOMEPAGE= http://sox.sourceforge.net/ | 9 | HOMEPAGE= http://sox.sourceforge.net/ | |
10 | COMMENT= SOund eXchange - universal sound sample translator | 10 | COMMENT= SOund eXchange - universal sound sample translator | |
11 | LICENSE= gnu-lgpl-v2.1 AND gnu-gpl-v2 | 11 | LICENSE= gnu-lgpl-v2.1 AND gnu-gpl-v2 | |
12 | 12 | |||
13 | #USE_CMAKE= yes | 13 | #USE_CMAKE= yes | |
14 | USE_LANGUAGES= c c++ | 14 | USE_LANGUAGES= c c++ | |
15 | USE_LIBTOOL= yes | 15 | USE_LIBTOOL= yes | |
16 | USE_TOOLS+= pkg-config | 16 | USE_TOOLS+= pkg-config | |
17 | GNU_CONFIGURE= yes | 17 | GNU_CONFIGURE= yes |
@@ -1,10 +1,10 @@ | @@ -1,10 +1,10 @@ | |||
1 | $NetBSD: distinfo,v 1.30 2021/10/26 09:59:30 nia Exp $ | 1 | $NetBSD: distinfo,v 1.31 2022/04/24 09:39:46 nia Exp $ | |
2 | 2 | |||
3 | BLAKE2s (sox-14.4.2.tar.gz) = a995d9682dad17ae557248bc008e16309537b49e3229390478e432882445b6d2 | 3 | BLAKE2s (sox-14.4.2.tar.gz) = a995d9682dad17ae557248bc008e16309537b49e3229390478e432882445b6d2 | |
4 | SHA512 (sox-14.4.2.tar.gz) = b5c6203f4f5577503a034fe5b3d6a033ee97fe4d171c533933e2b036118a43a14f97c9668433229708609ccf9ee16abdeca3fc7501aa0aafe06baacbba537eca | 4 | SHA512 (sox-14.4.2.tar.gz) = b5c6203f4f5577503a034fe5b3d6a033ee97fe4d171c533933e2b036118a43a14f97c9668433229708609ccf9ee16abdeca3fc7501aa0aafe06baacbba537eca | |
5 | Size (sox-14.4.2.tar.gz) = 1134299 bytes | 5 | Size (sox-14.4.2.tar.gz) = 1134299 bytes | |
6 | SHA1 (patch-aa) = e6f3d06450862795648622a017b2c696328872f5 | |||
7 | SHA1 (patch-ak) = 28675f56a0e2969d0facd98282667c53eb10c0ed | 6 | SHA1 (patch-ak) = 28675f56a0e2969d0facd98282667c53eb10c0ed | |
8 | SHA1 (patch-src_coreaudio.c) = baee5596ec5efdc12f99ea9dab9e9c691a17b08d | 7 | SHA1 (patch-src_coreaudio.c) = baee5596ec5efdc12f99ea9dab9e9c691a17b08d | |
9 | SHA1 (patch-src_oss.c) = dca4dcf55d4bfa1da80b789cbddb48a9302e694b | 8 | SHA1 (patch-src_oss.c) = dca4dcf55d4bfa1da80b789cbddb48a9302e694b | |
10 | SHA1 (patch-src_sunaudio.c) = 286ad890a32d69d499f76faa255473889b091d56 | 9 | SHA1 (patch-src_sox.c) = 2ac1ec7157a1cd9581d07fea5093f49df2dd7b7f | |
10 | SHA1 (patch-src_sunaudio.c) = 9f6a67b09c46cbc8298c226d972c43e86aeaae26 |
$NetBSD: patch-src_sox.c,v 1.1 2022/04/24 09:39:46 nia Exp $
PR pkg/56800 hitting v or V during sox's play command causes a
segfault
https://sourceforge.net/p/sox/code/ci/4b17639fb7591153dbd3e234eea21b1a2a29fcfa/
from more than 10 years ago changed the sun audio driver for the 14.4 release
to not use stdio (among others) while adjust_volume() in sox.c still used
fileno under the assumption that stdio was being used in the audio driver.
output_muted is not defined on NetBSD.
--- src/sox.c.orig 2014-10-06 02:02:30.000000000 +0000
+++ src/sox.c
@@ -1313,7 +1313,8 @@ static void adjust_volume(int delta)
#elif defined(HAVE_AUDIOIO_H)
static void adjust_volume(int delta)
{
- int vol1 = 0, vol2 = 0, fd = fileno((FILE*)ofile->ft->fp);
+ int vol1 = 0, vol2 = 0, fd;
+ fd = ofile->ft->fp != NULL ? *((int *)ofile->ft->fp) : -1;
if (fd >= 0) {
audio_info_t audio_info;
if (ioctl(fd, AUDIO_GETINFO, &audio_info) >= 0) {
@@ -1321,7 +1322,9 @@ static void adjust_volume(int delta)
vol2 = range_limit(vol1 + delta, 0, 100);
AUDIO_INITINFO(&audio_info);
audio_info.play.gain = (vol2 * AUDIO_MAX_GAIN + 50) / 100;
+#if defined(__sun)
audio_info.output_muted = 0;
+#endif
lsx_debug("%04x %04x", vol1, vol2);
if (vol1 != vol2 && ioctl(fd, AUDIO_SETINFO, &audio_info) < 0)
vol2 = vol1;
@@ -1,14 +1,37 @@ | @@ -1,14 +1,37 @@ | |||
1 | $NetBSD: patch-src_sunaudio.c,v 1.1 2015/05/25 19:06:24 bsiegert Exp $ | 1 | $NetBSD: patch-src_sunaudio.c,v 1.2 2022/04/24 09:39:46 nia Exp $ | |
2 | 2 | |||
3 | Fix segfault when playing (PR pkg/49929). | 3 | - Make the now unused (in the audio driver's case) void *fp member of the | |
4 | --- src/sunaudio.c.orig 2015-05-25 19:00:39.000000000 +0000 | 4 | sox_format_t structure a pointer to the filedescriptor of the audio | |
5 | device in the driver and reference it in adjust_volume() with an | |||
6 | additional check for NULL. (PR pkg/56800) | |||
7 | ||||
8 | - Fix segfault when playing (PR pkg/49929). | |||
9 | ||||
10 | --- src/sunaudio.c.orig 2014-10-06 01:59:34.000000000 +0000 | |||
5 | +++ src/sunaudio.c | 11 | +++ src/sunaudio.c | |
6 | @@ -443,7 +443,7 @@ static size_t sunwrite( | 12 | @@ -336,6 +336,8 @@ static int sunstartwrite(sox_format_t * | |
13 | pPriv->cOutput = sox_globals.bufsiz >> pPriv->sample_shift; | |||
14 | pPriv->pOutput = lsx_malloc((size_t)pPriv->cOutput << pPriv->sample_shift); | |||
15 | ||||
16 | + ft->fp = &pPriv->device; | |||
17 | + | |||
18 | return (SOX_SUCCESS); | |||
19 | } | |||
20 | ||||
21 | @@ -348,6 +350,7 @@ static int sunstop(sox_format_t* ft) | |||
22 | if (pPriv->pOutput) { | |||
23 | free(pPriv->pOutput); | |||
24 | } | |||
25 | + ft->fp = NULL; | |||
26 | return SOX_SUCCESS; | |||
27 | } | |||
28 | ||||
29 | @@ -443,7 +446,7 @@ static size_t sunwrite( | |||
7 | size_t cbStride; | 30 | size_t cbStride; | |
8 | int cbWritten; | 31 | int cbWritten; | |
9 | 32 | |||
10 | - cStride = cInput; | 33 | - cStride = cInput; | |
11 | + cStride = cInputRemaining; | 34 | + cStride = cInputRemaining; | |
12 | if (cStride > pPriv->cOutput) { | 35 | if (cStride > pPriv->cOutput) { | |
13 | cStride = pPriv->cOutput; | 36 | cStride = pPriv->cOutput; | |
14 | } | 37 | } |