amixer beeps on argv[] processing errors.

Bug #18272 reported by Ralph Corderoy
4
Affects Status Importance Assigned to Milestone
alsa-utils (Debian)
New
Unknown
alsa-utils (Ubuntu)
Fix Released
Low
Daniel T Chen

Bug Description

$ pwd
alsa-utils-1.0.8
$ find -name '*.c' | xargs grep '\\0[0-9]'
./alsamixer/alsamixer.c: case '\014':
./amixer/amixer.c: fprintf(stderr,
"\07Invalid card number.\n");
./amixer/amixer.c: fprintf(stderr, "\07Invalid switch or
option needs an argument.\n");
$

alsa-utils's amixer beeps on a couple of argv[] related error messages.
It should be silent, like /bin/false. shutdown(8) has good reason to
beep.

What makes this particularly annoying is this fresh install of 5.04's
/etc/init.d/alsa cause amixer with illegal arguments about a dozen times
on start and stop causing much loud beeping. I'll open another bug on
that as I continue to investigate but amixer shouldn't beep regardless.

Revision history for this message
In , Thomas Hood (jdthood-yahoo) wrote : retitle 222434 to amixer: Should reject invalid commands

# Automatically generated email from bts, devscripts version 2.8.4
retitle 222434 amixer: Should reject invalid commands

Revision history for this message
In , Thomas Hood (jdthood-yahoo) wrote : bug 222434 is forwarded to https://bugtrack.alsa-project.org/alsa-bug

# Automatically generated email from bts, devscripts version 2.8.4
forwarded 222434 https://bugtrack.alsa-project.org/alsa-bug

Revision history for this message
In , Thomas Hood (jdthood-yahoo) wrote : tagging 222434

# Automatically generated email from bts, devscripts version 2.8.4
tags 222434 - upstream

Revision history for this message
In , Thomas Hood (jdthood-yahoo) wrote : severity of 222434 is minor

severity 222434 minor

Revision history for this message
In , Thomas Hood (jdthood-yahoo) wrote : bug 222434 is forwarded to https://bugtrack.alsa-project.org/alsa-bug/view.php?id=532

# Automatically generated email from bts, devscripts version 2.8.5
forwarded 222434 https://bugtrack.alsa-project.org/alsa-bug/view.php?id=532

Revision history for this message
Ralph Corderoy (ralph-inputplus) wrote :

$ pwd
alsa-utils-1.0.8
$ find -name '*.c' | xargs grep '\\0[0-9]'
./alsamixer/alsamixer.c: case '\014':
./amixer/amixer.c: fprintf(stderr,
"\07Invalid card number.\n");
./amixer/amixer.c: fprintf(stderr, "\07Invalid switch or
option needs an argument.\n");
$

alsa-utils's amixer beeps on a couple of argv[] related error messages.
It should be silent, like /bin/false. shutdown(8) has good reason to
beep.

What makes this particularly annoying is this fresh install of 5.04's
/etc/init.d/alsa cause amixer with illegal arguments about a dozen times
on start and stop causing much loud beeping. I'll open another bug on
that as I continue to investigate but amixer shouldn't beep regardless.

Revision history for this message
Thomas Hood (jdthood) wrote :
Revision history for this message
In , Buechi (buechi) wrote : Fix amixer to reject invalid commands

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 address hidden>

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;

Revision history for this message
Ralph Corderoy (ralph-inputplus) wrote :

Still present in Dapper, 6.06.

    $ pwd
    /tmp/alsa-utils-1.0.10
    $ find -name '*.c' | xargs grep '\\0[0-9]'
    ./alsamixer/alsamixer.c: case '\014':
    ./amixer/amixer.c: fprintf(stderr, "\07Invalid card number.\n");
    ./amixer/amixer.c: fprintf(stderr, "\07Invalid switch or option needs an argument.\n");
    $

Changed in alsa-utils:
status: Unconfirmed → Confirmed
Changed in alsa-utils:
status: Unknown → Confirmed
Revision history for this message
Daniel T Chen (crimsun) wrote :
Changed in alsa-utils:
status: Confirmed → Fix Committed
Revision history for this message
Daniel T Chen (crimsun) wrote :
Changed in alsa-utils:
assignee: jdthood → crimsun
status: Fix Committed → Fix Released
Changed in alsa-utils (Debian):
status: Confirmed → New
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.