NetBSD Problem Report #59666

From www@netbsd.org  Tue Sep 23 06:47:27 2025
Return-Path: <www@netbsd.org>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256
	 client-signature RSA-PSS (2048 bits) client-digest SHA256)
	(Client CN "mail.NetBSD.org", Issuer "mail.NetBSD.org CA" (not verified))
	by mollari.NetBSD.org (Postfix) with ESMTPS id EB6D81A9239
	for <gnats-bugs@gnats.NetBSD.org>; Tue, 23 Sep 2025 06:47:26 +0000 (UTC)
Message-Id: <20250923064725.B14851A923D@mollari.NetBSD.org>
Date: Tue, 23 Sep 2025 06:47:25 +0000 (UTC)
From: rvp@SDF.ORG
Reply-To: rvp@SDF.ORG
To: gnats-bugs@NetBSD.org
Subject: audioplay(1): volume (-v) not checked for valid integer
X-Send-Pr-Version: www-1.0

>Number:         59666
>Category:       bin
>Synopsis:       audioplay(1): volume (-v) not checked for valid integer
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    bin-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue Sep 23 06:50:00 +0000 2025
>Originator:     RVP
>Release:        HEAD, 11, 10, 9
>Organization:
>Environment:
NetBSD/amd64 11.99.3
>Description:
Screw up the argument to -v (I assumed -v was `verbose') like so:

$ audioplay -v x.wav

audioplay will now set volume to 0, then wait for input from stdin.
This is hella confusing.
>How-To-Repeat:
As above.
>Fix:
Validate argument to `-v'.

```
diff -urN audio.orig/play/play.c audio/play/play.c
--- audio.orig/play/play.c	2024-03-04 17:42:13.281628348 +0000
+++ audio/play/play.c	2025-09-23 06:40:09.131535140 +0000
@@ -154,7 +154,9 @@
 			verbose++;
 			break;
 		case 'v':
-			volume = atoi(optarg);
+			if (*optarg == '\0')
+				errx(1, "volume must be an integer");
+			decode_int(optarg, &volume);
 			if (volume < 0 || volume > 255)
 				errx(1, "volume must be between 0 and 255");
 			break;
```

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.47 2022/09/11 19:34:41 kim Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2025 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.