buffer: remove unreachable overflow check in atob#60161
Conversation
|
|
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #60161 +/- ##
==========================================
+ Coverage 88.53% 88.57% +0.03%
==========================================
Files 703 704 +1
Lines 207997 208125 +128
Branches 40015 40012 -3
==========================================
+ Hits 184150 184338 +188
+ Misses 15864 15815 -49
+ Partials 7983 7972 -11
🚀 New features to boost your workflow:
|
|
@nodejs/buffer please take a look at this PR when you have some time? |
Renegade334
left a comment
There was a problem hiding this comment.
I think the comment at the corresponding location in the C++ source should be changed to match:
Lines 1470 to 1477 in be7ea27
Just needs to comment that if the error code case is not recognised, then the function will return the "unrecognised error" value -3 to JS.
Thanks, updated the C++ comments to describe -3 as the unrecognized simdutf error value returned to JS. |
Signed-off-by: haramjeong <04harams77@gmail.com>
Signed-off-by: haramjeong <04harams77@gmail.com>
Signed-off-by: haramjeong <04harams77@gmail.com>
Signed-off-by: haramjeong <04harams77@gmail.com>
Signed-off-by: haramjeong <04harams77@gmail.com>
Signed-off-by: haramjeong <04harams77@gmail.com>
0c07ec6 to
ca418cc
Compare
|
@anonrig Could you also take a look since this addresses the |
This comment was marked as outdated.
This comment was marked as outdated.
|
It looks like the Jenkins failures are due to flaky tests rather than issues introduced by this PR. |
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
|
The remaining failures appear to be unrelated flaky CI issues. Since all feedback has been addressed, would it be possible to move this PR forward when CI allows? Thank you |
|
@Renegade334 @anonrig @gurgunday Sorry for the ping, but when you have a chance, could you please check the failing tests and re-run the CI if the failures are unrelated to this PR? Thanks! |
This commit resolves a TODO comment in lib/buffer.js by changing the error thrown by atob() during a potential overflow condition.
Modified lib/buffer.js to instantiate and throw new ERR_INVALID_ARG_VALUE('input', result, 'The string to be decoded is too long.'); for the overflow case (result === -3).
This change makes the atob implementation more robust and developer-friendly.
@anonrig
->
The case for a result of -3 was intended to handle a potential
buffer overflow error. However, the underlying C++ implementation using
simdutf::base64_to_binary does not perform bounds-checking and therefore
can never return an OUTPUT_BUFFER_TOO_SMALL error.
This makes the
case -3:block unreachable code. This commit removesthe dead code for correctness and clarity.