From: Chris Duncan Date: Sat, 10 Oct 2026 05:44:24 +0000 (-0700) Subject: Validate byte length prior to copying the entire view. X-Git-Tag: v2.0.0~1^2~44 X-Git-Url: https://git.codecow.com/?a=commitdiff_plain;h=2d67c94dd36b39e6768b8ed6a36af01c92165df4;p=nano25519.git Validate byte length prior to copying the entire view. --- 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 }