git: 9front

Download patch

ref: 687ab76e05bcc1556dedd9fbcc9f3d52664b8ee5
parent: e47668b4c47700936da972a50746970ef2109243
author: cinap_lenrek <cinap_lenrek@gmx.de>
date: Tue Dec 11 16:02:14 EST 2012

audio/pcmconv: check number of input channels

--- a/sys/src/cmd/audio/pcmconv/pcmconv.c
+++ b/sys/src/cmd/audio/pcmconv/pcmconv.c
@@ -421,6 +421,9 @@
 		exits(0);
 	}
 
+	if(i.channels > nelem(ch))
+		sysfatal("too many input channels %d", i.channels);
+
 	switch(i.fmt){
 	case 's': iconv = siconv; break;
 	case 'u': iconv = uiconv; break;
@@ -444,7 +447,7 @@
 	obuf = sbrk(o.framesz * m);
 
 	memset(ch, 0, sizeof(ch));
-	for(k=0; k < i.channels && k < nelem(ch); k++)
+	for(k=0; k < i.channels; k++)
 		chaninit(&ch[k], i.rate, o.rate, n);
 
 	for(;;){
@@ -451,7 +454,7 @@
 		if(l >= 0 && l < r)
 			r = l;
 		n = cread(0, ibuf, r, i.framesz);
-		if(n < 0 || n > sizeof(ibuf))
+		if(n < 0)
 			sysfatal("read: %r");
 		if(l > 0)
 			l -= n;
--