Debian Bug report logs - #222434
amixer: Should reject invalid commands

version graph

Package: alsa-utils; Maintainer for alsa-utils is Debian ALSA Maintainers <[email protected]>; Source for alsa-utils is src:alsa-utils (PTS, buildd, popcon).

Reported by: Dan Jacobson <[email protected]>

Date: Sat, 29 Nov 2003 04:33:16 UTC

Severity: minor

Found in version 0.9.6-1

Reply or subscribe to this bug.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to [email protected], Debian-Alsa Psychos <[email protected]>:
Bug#222434; Package alsa-utils. (full text, mbox, link).


Acknowledgement sent to Dan Jacobson <[email protected]>:
New Bug report received and forwarded. Copy sent to Debian-Alsa Psychos <[email protected]>. (full text, mbox, link).


Message #5 received at [email protected] (full text, mbox, reply):

From: Dan Jacobson <[email protected]>
To: Debian Bug Tracking System <[email protected]>
Subject: /usr/bin/amixer: report errors for invalid commands
Date: Sat, 29 Nov 2003 10:16:34 +0800
Package: alsa-utils
Version: 0.9.6-1
Severity: normal
File: /usr/bin/amixer
Tags: upstream

The following proves that amixer accepts nonsense arguments with no
hint to the user that nothing was done,

$ amixer set Master,0 nocap; amixer|sum
Simple mixer control 'Master',0
  Capabilities: pvolume pswitch pswitch-joined
  Playback channels: Front Left - Front Right
  Limits: Playback 0 - 31
  Front Left: Playback 23 [74%] [on]
  Front Right: Playback 23 [74%] [on]
63938     6
$ amixer set Master,0 cap; amixer|sum
Simple mixer control 'Master',0
  Capabilities: pvolume pswitch pswitch-joined
  Playback channels: Front Left - Front Right
  Limits: Playback 0 - 31
  Front Left: Playback 23 [74%] [on]
  Front Right: Playback 23 [74%] [on]
63938     6

Furthermore, not even $? was set [shell error value].




Changed Bug title. Request was from Thomas Hood <[email protected]> to [email protected]. (full text, mbox, link).


Noted your statement that Bug has been forwarded to https://bugtrack.alsa-project.org/alsa-bug. Request was from Thomas Hood <[email protected]> to [email protected]. (full text, mbox, link).


Tags removed: upstream Request was from Thomas Hood <[email protected]> to [email protected]. (full text, mbox, link).


Severity set to `minor'. Request was from [email protected] (Thomas Hood) to [email protected]. (full text, mbox, link).


Forwarded-to-address changed from https://bugtrack.alsa-project.org/alsa-bug to https://bugtrack.alsa-project.org/alsa-bug/view.php?id=532. Request was from Thomas Hood <[email protected]> to [email protected]. (full text, mbox, link).


Information forwarded to [email protected], Debian ALSA Maintainers <[email protected]>:
Bug#222434; Package alsa-utils. (full text, mbox, link).


Acknowledgement sent to [email protected]:
Extra info received and forwarded to list. Copy sent to Debian ALSA Maintainers <[email protected]>. (full text, mbox, link).


Message #20 received at [email protected] (full text, mbox, reply):

From: [email protected]
To: [email protected]
Subject: Fix amixer to reject invalid commands
Date: Mon, 30 Jan 2006 10:04:07 +0100

Summary: Fix amixer to reject invalid commands 

The patch brings amixer to reject invalid commands, for example:	 "amixer set
Master,0 nocap" makes no sense, if there is no capture switch at the Master
Mixer Control. It also handles the invalid command, when more than 1 command is
submited. For example: "amixer set Master,0 nocap 50%,50%" does nothing. 

Additional it rejects commands like "amixer -c 1 get Line,0 80%,40% unmute cap"
where unnecessary options are submited.

Signed-off-by: Torsten Büchner <[email protected]>

Patch for alsa-utils-1.0.10:

--- amixer.orig.c	2005-09-22 14:47:02.000000000 +0200
+++ amixer.c	2006-01-30 08:01:58.000000000 +0100
@@ -1188,6 +1188,10 @@
 		fprintf(stderr, "Specify what you want to set...\n");
 		return 1;
 	}
+  if (roflag && !(argc < 2)) {
+    fprintf(stderr, "Unknown option: %s\n", argv[1]);
+    return 1;
+  }
 	if ((err = snd_mixer_open(&handle, 0)) < 0) {
 		error("Mixer %s open error: %s\n", card, snd_strerror(err));
 		return err;
@@ -1218,6 +1222,28 @@
 		goto __skip_write;
 	snd_mixer_selem_get_playback_volume_range(elem, &pmin, &pmax);
 	snd_mixer_selem_get_capture_volume_range(elem, &cmin, &cmax);
+  for (idx = 1; idx < argc; idx++) {
+    char *ptr = argv[idx];
+    channels = channels_mask(&ptr, channels);
+    if (*ptr == '\0')
+      continue;
+    dir = dir_mask(&ptr, dir);
+    if (*ptr == '\0')
+      continue;
+    for (chn = 0; chn <= SND_MIXER_SCHN_LAST; chn++) {
+      if (!(channels & (1 << chn)))
+        continue;
+      if ((!strncmp(ptr, "mute", 4) || !strncmp(ptr, "off", 3) || !strncmp(ptr,
"unmute", 6) || 
+         !strncmp(ptr, "on", 2) || !strncmp(ptr, "toggle", 6)) &&
snd_mixer_selem_has_playback_switch(elem)) continue;
+      if ((isdigit(*ptr) || *ptr == '-' || *ptr == '+') &&
snd_mixer_selem_has_playback_volume(elem)) continue;
+      
+      if ((!strncmp(ptr, "cap", 3) || !strncmp(ptr, "rec", 3) || !strncmp(ptr,
"nocap", 5) ||
+         !strncmp(ptr, "norec", 5) || !strncmp(ptr, "toggle", 6)) &&
snd_mixer_selem_has_capture_switch(elem)) continue;
+      if ((isdigit(*ptr) || *ptr == '-' || *ptr == '+') &&
snd_mixer_selem_has_capture_volume(elem)) continue;
+      fprintf(stderr, "Setup not available: %s\n",ptr);
+      return 1;
+    } 
+  }
 	for (idx = 1; idx < argc; idx++) {
 		char *ptr = argv[idx], *optr;
 		int multi, firstchn = 1;




Unset Bug forwarded-to-address Request was from Sandro Tosi <[email protected]> to [email protected]. (Tue, 29 Dec 2015 02:09:04 GMT) (full text, mbox, link).


Send a report that this bug log contains spam.


Debian bug tracking system administrator <[email protected]>. Last modified: Thu May 15 19:32:09 2025; Machine Name: bembo

Debian Bug tracking system

Debbugs is free software and licensed under the terms of the GNU General Public License version 2. The current version can be obtained from https://bugs.debian.org/debbugs-source/.

Copyright © 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson, 2005-2017 Don Armstrong, and many other contributors.