summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2025-05-06 18:32:36 -0700
committerKaz Kylheku <kaz@kylheku.com>2025-05-06 18:32:36 -0700
commitd59e9a479ac74b8addc96c4bceeb3845464a05f8 (patch)
tree9db464d046a0b91d96b13315f6e53d34373047f1
parenta14047894ed3368c80fae349a1499b7d0b4d16db (diff)
downloadtxr-d59e9a479ac74b8addc96c4bceeb3845464a05f8.tar.gz
txr-d59e9a479ac74b8addc96c4bceeb3845464a05f8.tar.bz2
txr-d59e9a479ac74b8addc96c4bceeb3845464a05f8.zip
buf: buf_ash: fix buffer overrrun.
* buf.c (buf_ash): Loop must be clamped the smaller length of the result, cnlen.
-rw-r--r--buf.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/buf.c b/buf.c
index e83eb121..0bb21a5c 100644
--- a/buf.c
+++ b/buf.c
@@ -1456,7 +1456,7 @@ val buf_ash(val buf, val bits)
struct buf *nbh = buf_handle(nbuf, self);
ucnum i;
- for (i = 0; i < len; i++) {
+ for (i = 0; i < cnlen; i++) {
unsigned by = bh->data[i + v];
nbh->data[i] = (by | acc) >> r;
acc = by << 8;