handle bogus values passed to SOUND_PCM_WRITE_CHANNELS/SNDCTL_DSP_CHANNELS

ioctls better- if 0 is passed, return the current setting.  if 1 or 2 are
passed, behave accordingly.  treat values >2 as 2.

PR:		kern/29964
This commit is contained in:
Cameron Grant 2001-08-23 12:21:12 +00:00
parent 48875621e1
commit 334326a17f

View File

@ -700,9 +700,9 @@ dsp_ioctl(dev_t i_dev, u_long cmd, caddr_t arg, int mode, struct proc *p)
case SOUND_PCM_WRITE_CHANNELS:
/* case SNDCTL_DSP_CHANNELS: ( == SOUND_PCM_WRITE_CHANNELS) */
if (*arg_i == 1 || *arg_i == 2) {
if (*arg_i != 0) {
tmp = 0;
*arg_i = (*arg_i == 2)? AFMT_STEREO : 0;
*arg_i = (*arg_i != 1)? AFMT_STEREO : 0;
if (wrch) {
CHN_LOCK(wrch);
ret = chn_setformat(wrch, (wrch->format & ~AFMT_STEREO) | *arg_i);
@ -717,8 +717,9 @@ dsp_ioctl(dev_t i_dev, u_long cmd, caddr_t arg, int mode, struct proc *p)
CHN_UNLOCK(rdch);
}
*arg_i = tmp;
} else
*arg_i = 0;
} else {
*arg_i = ((wrch? wrch->format : rdch->format) & AFMT_STEREO)? 2 : 1;
}
break;
case SOUND_PCM_READ_CHANNELS: