From 531bb1cc261be1e89e398417760fca1261583582 Mon Sep 17 00:00:00 2001 From: Charlie Gordon Date: Sun, 3 Mar 2024 14:05:40 +0100 Subject: 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` --- lib/quickjs/cutils.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/quickjs/cutils.c') 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; } -- cgit 1.4.1-2-gfad0