From 7bd9bb82eed3064c241aa4d20212aadb769130cc Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Wed, 7 May 2025 07:52:56 -0700 Subject: buf: int-buf: unsigned multiplication overflow. * buf.c (int_buf): Do not multiply the buffer length by 8 as a built-in unsigned integer. Use the mul function instead on the original Lisp integer length. sign-extend handles bignum values for the bit width. --- buf.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/buf.c b/buf.c index f5f27b39..906a800a 100644 --- a/buf.c +++ b/buf.c @@ -1305,12 +1305,11 @@ static val int_buf(val buf) val self = lit("int-buf"); struct buf *b = buf_handle(buf, self); ucnum size = c_unum(b->len, self); - ucnum bits = size * 8; val ubn = make_bignum(); mp_err mpe = mp_read_unsigned_bin(mp(ubn), b->data, size); if (mpe != MP_OKAY) do_mp_error(self, mpe); - return sign_extend(normalize(ubn), unum(bits)); + return sign_extend(normalize(ubn), mul(b->len, num_fast(8))); } static val uint_buf(val buf) -- cgit v1.2.3