ref: bedfd8f3617c47460c29907abb675e8fe1d842b2
parent: 45a5074b10266b82a03c9fd7a636672c34eb1f39
author: cinap_lenrek <[email protected]>
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;