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/aucat/dsp.c | |
parent | 516cab0c4548626697d795bb84506411479d303b (diff) |
Fix off-by-one array access when 64 channel stream is resampled
Diffstat (limited to 'usr.bin/aucat/dsp.c')
-rw-r--r-- | usr.bin/aucat/dsp.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/usr.bin/aucat/dsp.c b/usr.bin/aucat/dsp.c index 4b62f1d5e97..149f05a46c8 100644 --- a/usr.bin/aucat/dsp.c +++ b/usr.bin/aucat/dsp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dsp.c,v 1.16 2021/01/12 15:46:53 naddy Exp $ */ +/* $OpenBSD: dsp.c,v 1.17 2021/07/05 08:29:59 ratchov Exp $ */ /* * Copyright (c) 2008-2012 Alexandre Ratchov <alex@caoua.org> * @@ -429,7 +429,7 @@ resamp_do(struct resamp *p, adata_t *in, adata_t *out, int icnt, int ocnt) if (ofr == 0) break; - for (c = nch; c > 0; c--) + for (c = 0; c < nch; c++) f[c] = 0; q = diff * p->filt_step; @@ -442,7 +442,7 @@ resamp_do(struct resamp *p, adata_t *in, adata_t *out, int icnt, int ocnt) 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; } @@ -450,7 +450,7 @@ resamp_do(struct resamp *p, adata_t *in, adata_t *out, int icnt, int ocnt) 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 |