about summary refs log tree commit diff stats
path: root/lib/quickjs/cutils.c
diff options
context:
space:
mode:
authorCharlie Gordon <github@chqrlie.org>2024-03-03 14:05:40 +0100
committerbptato <nincsnevem662@gmail.com>2024-03-13 21:07:12 +0100
commit531bb1cc261be1e89e398417760fca1261583582 (patch)
treeb791e16868a9eb5a4dc0865b97dc1266b19e6fde /lib/quickjs/cutils.c
parent570a601e8f88d28d747a373cdb3db3405bb1c6fc (diff)
downloadchawan-531bb1cc261be1e89e398417760fca1261583582.tar.gz
Prevent UB on memcpy and floating point conversions
- add `memcpy_no_ub` that accepts null pointers for 0 count
- prevent 0 length allocation in `js_worker_postMessage`
- use safer test for `int` value in `JS_NewFloat64`,
  `JS_ToArrayLengthFree` and `js_typed_array_indexOf`
Diffstat (limited to 'lib/quickjs/cutils.c')
-rw-r--r--lib/quickjs/cutils.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/quickjs/cutils.c b/lib/quickjs/cutils.c
index b4960f9c..c0aacef6 100644
--- a/lib/quickjs/cutils.c
+++ b/lib/quickjs/cutils.c
@@ -140,7 +140,7 @@ int dbuf_put(DynBuf *s, const uint8_t *data, size_t len)
         if (dbuf_realloc(s, s->size + len))
             return -1;
     }
-    memcpy(s->buf + s->size, data, len);
+    memcpy_no_ub(s->buf + s->size, data, len);
     s->size += len;
     return 0;
 }