From 2d67c94dd36b39e6768b8ed6a36af01c92165df4 Mon Sep 17 00:00:00 2001 From: Chris Duncan Date: Fri, 9 Oct 2026 22:44:24 -0700 Subject: [PATCH] Validate byte length prior to copying the entire view. --- src/lib/primordials.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lib/primordials.ts b/src/lib/primordials.ts index 8b4d0a4..dc5d515 100644 --- a/src/lib/primordials.ts +++ b/src/lib/primordials.ts @@ -224,14 +224,14 @@ export function normalize (name: string, byteLengthMin: number, byteLengthMax: n } if (isBytes(value)) { - const bytes = copy(value) - const byteLength = getByteLength(bytes) + const byteLength = getByteLength(value) if (byteLength < byteLengthMin) { throw new TypeError(`${name} must be at least ${byteLengthMin} bytes`) } if (byteLength > byteLengthMax) { throw new TypeError(`${name} must be no more than ${byteLengthMax} bytes`) } + const bytes = copy(value) return bytes } -- 2.52.0