diff options
author | Alexandre Ratchov <ratchov@cvs.openbsd.org> | 2021-07-05 08:30:00 +0000 |
---|---|---|
committer | Alexandre Ratchov <ratchov@cvs.openbsd.org> | 2021-07-05 08:30:00 +0000 |
commit | e705188ae4173be816a2cc1f3506d566d215a407 (patch) | |
tree | d33c93f3f2164093bee734a8bf3f8f957d5d4df5 /usr.bin/sndiod/dsp.c | |
parent | 516cab0c4548626697d795bb84506411479d303b (diff) |
Fix off-by-one array access when 64 channel stream is resampled
Diffstat (limited to 'usr.bin/sndiod/dsp.c')
-rw-r--r-- | usr.bin/sndiod/dsp.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/usr.bin/sndiod/dsp.c b/usr.bin/sndiod/dsp.c index 9b0a477a596..6c963f14d79 100644 --- a/usr.bin/sndiod/dsp.c +++ b/usr.bin/sndiod/dsp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dsp.c,v 1.17 2021/01/12 15:46:53 naddy Exp $ */ +/* $OpenBSD: dsp.c,v 1.18 2021/07/05 08:29:59 ratchov Exp $ */ /* * Copyright (c) 2008-2012 Alexandre Ratchov <alex@caoua.org> * @@ -321,7 +321,7 @@ resamp_do(struct resamp *p, adata_t *in, adata_t *out, int todo) todo--; } else { - for (c = nch; c > 0; c--) + for (c = 0; c < nch; c++) f[c] = 0; q = diff * p->filt_step; @@ -334,7 +334,7 @@ resamp_do(struct resamp *p, adata_t *in, adata_t *out, int todo) ds = resamp_filt[qi + 1] - s; s += (int64_t)qf * ds >> RESAMP_STEP_BITS; ctx = ctxbuf; - for (c = nch; c > 0; c--) { + for (c = 0; c < nch; c++) { f[c] += (int64_t)ctx[n] * s; ctx += RESAMP_NCTX; } @@ -342,7 +342,7 @@ resamp_do(struct resamp *p, adata_t *in, adata_t *out, int todo) n = (n + 1) & (RESAMP_NCTX - 1); } - for (c = nch; c > 0; c--) { + for (c = 0; c < nch; c++) { s = f[c] >> RESAMP_BITS; s = (int64_t)s * p->filt_cutoff >> RESAMP_BITS; #if ADATA_BITS == 16 |