Module Name: src
Committed By: snj
Date: Wed Aug 9 06:20:10 UTC 2017
Modified Files:
src/sys/dev [netbsd-7-0]: auconv.c
src/sys/dev/ic [netbsd-7-0]: ac97.c
src/sys/dev/pci [netbsd-7-0]: azalia_codec.c
Log Message:
Pull up following revision(s) (requested by nat in ticket #1460):
sys/dev/auconv.c: revision 1.30 via patch
sys/dev/ic/ac97.c: revision 1.97 via patch
sys/dev/pci/azalia_codec.c: revision 1.81 via patch
Mixer device bounds checking.
Analysis by Ilja van Sprundel.
To generate a diff of this commit:
cvs rdiff -u -r1.25 -r1.25.28.1 src/sys/dev/auconv.c
cvs rdiff -u -r1.95.12.1 -r1.95.12.1.2.1 src/sys/dev/ic/ac97.c
cvs rdiff -u -r1.79 -r1.79.28.1 src/sys/dev/pci/azalia_codec.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/dev/auconv.c
diff -u src/sys/dev/auconv.c:1.25 src/sys/dev/auconv.c:1.25.28.1
--- src/sys/dev/auconv.c:1.25 Wed Nov 23 23:07:31 2011
+++ src/sys/dev/auconv.c Wed Aug 9 06:20:10 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: auconv.c,v 1.25 2011/11/23 23:07:31 jmcneill Exp $ */
+/* $NetBSD: auconv.c,v 1.25.28.1 2017/08/09 06:20:10 snj Exp $ */
/*
* Copyright (c) 1996 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: auconv.c,v 1.25 2011/11/23 23:07:31 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: auconv.c,v 1.25.28.1 2017/08/09 06:20:10 snj Exp $");
#include <sys/types.h>
#include <sys/audioio.h>
@@ -1162,7 +1162,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);
Index: src/sys/dev/ic/ac97.c
diff -u src/sys/dev/ic/ac97.c:1.95.12.1 src/sys/dev/ic/ac97.c:1.95.12.1.2.1
--- src/sys/dev/ic/ac97.c:1.95.12.1 Sun Jul 5 20:37:01 2015
+++ src/sys/dev/ic/ac97.c Wed Aug 9 06:20:10 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: ac97.c,v 1.95.12.1 2015/07/05 20:37:01 snj Exp $ */
+/* $NetBSD: ac97.c,v 1.95.12.1.2.1 2017/08/09 06:20:10 snj 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.95.12.1 2015/07/05 20:37:01 snj Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ac97.c,v 1.95.12.1.2.1 2017/08/09 06:20:10 snj Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -1677,7 +1677,7 @@ ac97_query_devinfo(struct ac97_codec_if
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;
Index: src/sys/dev/pci/azalia_codec.c
diff -u src/sys/dev/pci/azalia_codec.c:1.79 src/sys/dev/pci/azalia_codec.c:1.79.28.1
--- src/sys/dev/pci/azalia_codec.c:1.79 Wed Nov 23 23:07:35 2011
+++ src/sys/dev/pci/azalia_codec.c Wed Aug 9 06:20:10 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: azalia_codec.c,v 1.79 2011/11/23 23:07:35 jmcneill Exp $ */
+/* $NetBSD: azalia_codec.c,v 1.79.28.1 2017/08/09 06:20:10 snj 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.79 2011/11/23 23:07:35 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: azalia_codec.c,v 1.79.28.1 2017/08/09 06:20:10 snj Exp $");
#include <sys/param.h>
#include <sys/device.h>
@@ -2074,7 +2074,7 @@ generic_set_port(codec_t *this, mixer_ct
{
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)
@@ -2089,7 +2089,7 @@ generic_get_port(codec_t *this, mixer_ct
{
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;
@@ -2328,7 +2328,7 @@ alc260_set_port(codec_t *this, mixer_ctr
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)
@@ -2386,7 +2386,7 @@ alc260_get_port(codec_t *this, mixer_ctr
{
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;
@@ -2895,7 +2895,7 @@ alc882_set_port(codec_t *this, mixer_ctr
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)
@@ -2929,7 +2929,7 @@ alc882_get_port(codec_t *this, mixer_ctr
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;