diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2018-02-28 18:45:41 -0800 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2018-02-28 18:45:41 -0800 |
commit | 92a40d9b424295ad8f62cad590b3862b1e6a54e0 (patch) | |
tree | db597493b2e0daaa3db46a1fba868cf41bba34a8 /buf.c | |
parent | aab8f74a731078f1ca974c31c783fe9cccebc5aa (diff) | |
download | txr-92a40d9b424295ad8f62cad590b3862b1e6a54e0.tar.gz txr-92a40d9b424295ad8f62cad590b3862b1e6a54e0.tar.bz2 txr-92a40d9b424295ad8f62cad590b3862b1e6a54e0.zip |
bugfix: buf-get-* not allowing last byte of buffer.
* buf.c (buf_get_bytes): Fix off-by-one test for reading past
end of buffer. This prevents, e.g. a buf-get-u32
from the last four bytes of a buffer (or from a four-byte-long
buffer, period).
Diffstat (limited to 'buf.c')
-rw-r--r-- | buf.c | 2 |
1 files changed, 1 insertions, 1 deletions
@@ -423,7 +423,7 @@ static void buf_get_bytes(val buf, val pos, mem_t *ptr, cnum size, val self) cnum e = p + size; cnum l = c_num(b->len); - if (e >= l || e < 0) + if (e > l || e < 0) uw_throwf(error_s, lit("~a: attempted read past buffer end"), self, nao); memcpy(ptr, b->data + p, size); |