ref: b31dfe049794b3fcf6ce2c05a0896ab1927dc3c7
parent: eb7c19d8d04c872c41c397803ea8f97a9a73a82f
author: qwx <qwx@sciops.net>
date: Thu Nov 24 14:46:40 EST 2022
fix read buffer overflow, more sensible io size
--- a/cmd.c
+++ b/cmd.c
@@ -451,7 +451,10 @@
rc = newchunk(Iochunksz);
for(off=0, m=0, c=rc;; m+=n, off+=n){
- if(off == Iochunksz){
+ if(off + Ioreadsz > Iochunksz){
+ if(off != Iochunksz)
+ resizechunk(c, off);
+ c->bufsz = off;
nc = newchunk(Iochunksz);
linkchunk(c, nc);
c = nc;
--- a/dat.h
+++ b/dat.h
@@ -9,7 +9,7 @@
Sampsz = 2 * 2,
Outsz = WriteDelay * Sampsz,
Iochunksz = 4*1024*1024, /* ≈ 24 sec. at 44.1 kHz */
- Ioreadsz = Iochunksz / 32,
+ Ioreadsz = 64*1024,
};
struct Chunk{
uchar *buf;