From bca05f6f39cdb5325cd89db20a3ab3959645f332 Mon Sep 17 00:00:00 2001 From: haramjeong <04harams77@gmail.com> Date: Wed, 8 Oct 2025 15:38:07 +0900 Subject: [PATCH 1/5] buffer: throw RangeError on atob overflow --- lib/buffer.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/buffer.js b/lib/buffer.js index c9f45d333886d3..0e7e9b7e33e2a8 100644 --- a/lib/buffer.js +++ b/lib/buffer.js @@ -37,6 +37,7 @@ const { ObjectDefineProperty, ObjectPrototypeHasOwnProperty, ObjectSetPrototypeOf, + RangeError, RegExpPrototypeSymbolReplace, StringPrototypeCharCodeAt, StringPrototypeSlice, @@ -1303,8 +1304,7 @@ function atob(input) { 'The string to be decoded is not correctly encoded.', 'InvalidCharacterError'); case -3: // Possible overflow - // TODO(@anonrig): Throw correct error in here. - throw lazyDOMException('The input causes overflow.', 'InvalidCharacterError'); + throw new RangeError('The string to be decoded is too long.'); default: return result; } From eb77eb7b46dbd32a5bc3439f608f57c073ecb843 Mon Sep 17 00:00:00 2001 From: haramjeong <04harams77@gmail.com> Date: Wed, 8 Oct 2025 15:50:31 +0900 Subject: [PATCH 2/5] buffer: fix lint-js --- lib/buffer.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/buffer.js b/lib/buffer.js index 0e7e9b7e33e2a8..655e3843e75acb 100644 --- a/lib/buffer.js +++ b/lib/buffer.js @@ -37,7 +37,6 @@ const { ObjectDefineProperty, ObjectPrototypeHasOwnProperty, ObjectSetPrototypeOf, - RangeError, RegExpPrototypeSymbolReplace, StringPrototypeCharCodeAt, StringPrototypeSlice, @@ -1304,7 +1303,7 @@ function atob(input) { 'The string to be decoded is not correctly encoded.', 'InvalidCharacterError'); case -3: // Possible overflow - throw new RangeError('The string to be decoded is too long.'); + throw new ERR_INVALID_ARG_VALUE('input', result, 'The string to be decoded is too long.'); default: return result; } From cb09cba602c87d99bf656e3b9a24ac54d82964a9 Mon Sep 17 00:00:00 2001 From: Haram Jeong <91401364+haramj@users.noreply.github.com> Date: Sun, 12 Oct 2025 14:41:06 +0900 Subject: [PATCH 3/5] buffer: remove unreachable overflow check in atob --- lib/buffer.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/lib/buffer.js b/lib/buffer.js index 655e3843e75acb..c955bb931bad69 100644 --- a/lib/buffer.js +++ b/lib/buffer.js @@ -1302,8 +1302,6 @@ function atob(input) { throw lazyDOMException( 'The string to be decoded is not correctly encoded.', 'InvalidCharacterError'); - case -3: // Possible overflow - throw new ERR_INVALID_ARG_VALUE('input', result, 'The string to be decoded is too long.'); default: return result; } From a54015abf1a8daa048c0a706603d965397970cec Mon Sep 17 00:00:00 2001 From: haramjeong <04harams77@gmail.com> Date: Mon, 13 Oct 2025 10:01:37 +0900 Subject: [PATCH 4/5] buffer: add assert.fail() --- lib/buffer.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/buffer.js b/lib/buffer.js index c955bb931bad69..af9d104f42786c 100644 --- a/lib/buffer.js +++ b/lib/buffer.js @@ -99,6 +99,8 @@ const { inspect: utilInspect, } = require('internal/util/inspect'); +const assert = require('internal/assert'); + const { codes: { ERR_BUFFER_OUT_OF_BOUNDS, @@ -1302,6 +1304,8 @@ function atob(input) { throw lazyDOMException( 'The string to be decoded is not correctly encoded.', 'InvalidCharacterError'); + case -3: + assert.fail('Unrecognized simdutf error'); default: return result; } From f5c78ba6d3755cccd968bef88259864b5baf987d Mon Sep 17 00:00:00 2001 From: haramjeong <04harams77@gmail.com> Date: Mon, 13 Oct 2025 10:08:52 +0900 Subject: [PATCH 5/5] buffer: fix lint error --- lib/buffer.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/buffer.js b/lib/buffer.js index af9d104f42786c..7cce07ddc5d410 100644 --- a/lib/buffer.js +++ b/lib/buffer.js @@ -1306,6 +1306,7 @@ function atob(input) { 'InvalidCharacterError'); case -3: assert.fail('Unrecognized simdutf error'); + break; default: return result; }