Mixer device bounds checking.
Analysis by Ilja van Sprundel.
This commit is contained in:
parent
64d02c8415
commit
60fa90dcac
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: auconv.c,v 1.29 2017/07/27 23:39:37 nat Exp $ */
|
||||
/* $NetBSD: auconv.c,v 1.30 2017/07/28 01:36:40 nat Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1996 The NetBSD Foundation, Inc.
|
||||
@ -35,7 +35,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: auconv.c,v 1.29 2017/07/27 23:39:37 nat Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: auconv.c,v 1.30 2017/07/28 01:36:40 nat Exp $");
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/audioio.h>
|
||||
@ -1391,7 +1391,7 @@ int
|
||||
auconv_query_encoding(const struct audio_encoding_set *encodings,
|
||||
audio_encoding_t *aep)
|
||||
{
|
||||
if (aep->index >= encodings->size)
|
||||
if (aep->index < 0 || aep->index >= encodings->size)
|
||||
return EINVAL;
|
||||
strlcpy(aep->name, encodings->items[aep->index].name,
|
||||
MAX_AUDIO_DEV_LEN);
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: audio.c,v 1.371 2017/07/27 08:37:27 isaki Exp $ */
|
||||
/* $NetBSD: audio.c,v 1.372 2017/07/28 01:36:40 nat Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2016 Nathanial Sloss <nathanialsloss@yahoo.com.au>
|
||||
@ -148,7 +148,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.371 2017/07/27 08:37:27 isaki Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.372 2017/07/28 01:36:40 nat Exp $");
|
||||
|
||||
#ifdef _KERNEL_OPT
|
||||
#include "audio.h"
|
||||
@ -5127,7 +5127,7 @@ mixer_ioctl(struct audio_softc *sc, u_long cmd, void *addr, int flag,
|
||||
|
||||
if (device_is_active(sc->sc_dev))
|
||||
error = audio_get_port(sc, mc);
|
||||
else if (mc->dev >= sc->sc_nmixer_states)
|
||||
else if (mc->dev < 0 || mc->dev >= sc->sc_nmixer_states)
|
||||
error = ENXIO;
|
||||
else {
|
||||
int dev = mc->dev;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: ac97.c,v 1.96 2015/04/04 15:09:45 christos Exp $ */
|
||||
/* $NetBSD: ac97.c,v 1.97 2017/07/28 01:36:40 nat Exp $ */
|
||||
/* $OpenBSD: ac97.c,v 1.8 2000/07/19 09:01:35 csapuntz Exp $ */
|
||||
|
||||
/*
|
||||
@ -63,7 +63,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: ac97.c,v 1.96 2015/04/04 15:09:45 christos Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: ac97.c,v 1.97 2017/07/28 01:36:40 nat Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
@ -1677,7 +1677,7 @@ ac97_query_devinfo(struct ac97_codec_if *codec_if, mixer_devinfo_t *dip)
|
||||
const char *name;
|
||||
|
||||
as = (struct ac97_softc *)codec_if;
|
||||
if (dip->index < as->num_source_info) {
|
||||
if (dip->index >= 0 && dip->index < as->num_source_info) {
|
||||
si = &as->source_info[dip->index];
|
||||
dip->type = si->type;
|
||||
dip->mixer_class = si->mixer_class;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: azalia_codec.c,v 1.80 2017/06/01 02:45:11 chs Exp $ */
|
||||
/* $NetBSD: azalia_codec.c,v 1.81 2017/07/28 01:36:41 nat Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2005, 2008 The NetBSD Foundation, Inc.
|
||||
@ -30,7 +30,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: azalia_codec.c,v 1.80 2017/06/01 02:45:11 chs Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: azalia_codec.c,v 1.81 2017/07/28 01:36:41 nat Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/device.h>
|
||||
@ -2062,7 +2062,7 @@ generic_set_port(codec_t *this, mixer_ctrl_t *mc)
|
||||
{
|
||||
const mixer_item_t *m;
|
||||
|
||||
if (mc->dev >= this->nmixers)
|
||||
if (mc->dev < 0 || mc->dev >= this->nmixers)
|
||||
return ENXIO;
|
||||
m = &this->mixers[mc->dev];
|
||||
if (mc->type != m->devinfo.type)
|
||||
@ -2077,7 +2077,7 @@ generic_get_port(codec_t *this, mixer_ctrl_t *mc)
|
||||
{
|
||||
const mixer_item_t *m;
|
||||
|
||||
if (mc->dev >= this->nmixers)
|
||||
if (mc->dev < 0 || mc->dev >= this->nmixers)
|
||||
return ENXIO;
|
||||
m = &this->mixers[mc->dev];
|
||||
mc->type = m->devinfo.type;
|
||||
@ -2312,7 +2312,7 @@ alc260_set_port(codec_t *this, mixer_ctrl_t *mc)
|
||||
uint32_t value;
|
||||
int err;
|
||||
|
||||
if (mc->dev >= this->nmixers)
|
||||
if (mc->dev < 0 || mc->dev >= this->nmixers)
|
||||
return ENXIO;
|
||||
m = &this->mixers[mc->dev];
|
||||
if (mc->type != m->devinfo.type)
|
||||
@ -2370,7 +2370,7 @@ alc260_get_port(codec_t *this, mixer_ctrl_t *mc)
|
||||
{
|
||||
const mixer_item_t *m;
|
||||
|
||||
if (mc->dev >= this->nmixers)
|
||||
if (mc->dev < 0 || mc->dev >= this->nmixers)
|
||||
return ENXIO;
|
||||
m = &this->mixers[mc->dev];
|
||||
mc->type = m->devinfo.type;
|
||||
@ -2871,7 +2871,7 @@ alc882_set_port(codec_t *this, mixer_ctrl_t *mc)
|
||||
uint32_t mask, bit;
|
||||
int i, err;
|
||||
|
||||
if (mc->dev >= this->nmixers)
|
||||
if (mc->dev < 0 || mc->dev >= this->nmixers)
|
||||
return ENXIO;
|
||||
m = &this->mixers[mc->dev];
|
||||
if (mc->type != m->devinfo.type)
|
||||
@ -2905,7 +2905,7 @@ alc882_get_port(codec_t *this, mixer_ctrl_t *mc)
|
||||
uint32_t mask, bit, result;
|
||||
int i, err;
|
||||
|
||||
if (mc->dev >= this->nmixers)
|
||||
if (mc->dev < 0 || mc->dev >= this->nmixers)
|
||||
return ENXIO;
|
||||
m = &this->mixers[mc->dev];
|
||||
mc->type = m->devinfo.type;
|
||||
|
Loading…
Reference in New Issue
Block a user