buffer: fix end parameter bugs in indexOf/lastIndexOf - #62711
Conversation
81afd27 to
927c25a
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #62711 +/- ##
==========================================
+ Coverage 88.93% 89.62% +0.68%
==========================================
Files 699 706 +7
Lines 216379 219221 +2842
Branches 41281 42003 +722
==========================================
+ Hits 192434 196471 +4037
+ Misses 15976 14674 -1302
- Partials 7969 8076 +107
🚀 New features to boost your workflow:
|
927c25a to
7d46b35
Compare
- Fix FastIndexOfNumber parameter order mismatch (end_i64 and is_forward were swapped vs the JS call site and slow path) - Clamp negative end values to 0 to prevent size_t overflow in IndexOfString, IndexOfBuffer, and IndexOfNumberImpl - Clamp empty needle result to search_end Signed-off-by: Robert Nagy <ronagy@icloud.com> Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
7d46b35 to
e4bbd84
Compare
|
This is an important bug fix which is unable to get reviews. @nodejs/tsc |
|
I don't think this has a place on the TSC agenda. I'm happy to review but at this point this can't land anyway on the account of having formatting issues. |
Co-authored-by: Robert Nagy <ronagy@icloud.com>
I guess it's gray zone. Being unable to land an important (security related) fix falls IMHO under the TSC. Formatting issues resolve. PTAL |
But there's no |
Failed to start CI[SyntaxError: Unexpected token '<', "https://github.com/nodejs/node/actions/runs/24897465125 |
Commit Queue failed- Loading data for nodejs/node/pull/62711 ✔ Done loading data for nodejs/node/pull/62711 ----------------------------------- PR info ------------------------------------ Title buffer: fix end parameter bugs in indexOf/lastIndexOf (#62711) Author Robert Nagy <ronagy@icloud.com> (@ronag) Branch ronag:buffer-index-of-end2 -> nodejs:main Labels buffer, c++, author ready, needs-ci Commits 2 - buffer: fix end parameter bugs in indexOf/lastIndexOf - Apply suggestions from code review Committers 2 - Robert Nagy <ronagy@icloud.com> - GitHub <noreply@github.com> PR-URL: https://github.com/nodejs/node/pull/62711 Fixes: https://github.com/nodejs/node/issues/62873 Reviewed-By: Filip Skokan <panva.ip@gmail.com> ------------------------------ Generated metadata ------------------------------ PR-URL: https://github.com/nodejs/node/pull/62711 Fixes: https://github.com/nodejs/node/issues/62873 Reviewed-By: Filip Skokan <panva.ip@gmail.com> -------------------------------------------------------------------------------- ℹ This PR was created on Sun, 12 Apr 2026 20:18:11 GMT ✔ Approvals: 1 ✔ - Filip Skokan (@panva) (TSC): https://github.com/nodejs/node/pull/62711#pullrequestreview-4171398766 ✔ Last GitHub CI successful ℹ Last Full PR CI on 2026-04-24T17:16:45Z: https://ci.nodejs.org/job/node-test-pull-request/72904/ - Querying data for job/node-test-pull-request/72904/ ✔ Build data downloaded ✔ Last Jenkins CI successful -------------------------------------------------------------------------------- ✔ No git cherry-pick in progress ✔ No git am in progress ✔ No git rebase in progress -------------------------------------------------------------------------------- - Bringing origin/main up to date... From https://github.com/nodejs/node * branch main -> FETCH_HEAD ✔ origin/main is now up-to-date - Downloading patch for 62711 From https://github.com/nodejs/node * branch refs/pull/62711/merge -> FETCH_HEAD ✔ Fetched commits as 9c4ca0a12d1c..1d34d6bdb97c -------------------------------------------------------------------------------- [main cd8d9d00c1] buffer: fix end parameter bugs in indexOf/lastIndexOf Author: Robert Nagy <ronagy@icloud.com> Date: Sun Apr 12 22:16:34 2026 +0200 2 files changed, 52 insertions(+), 11 deletions(-) [main 1d3743e568] Apply suggestions from code review Author: Robert Nagy <ronagy@icloud.com> Date: Fri Apr 24 16:25:08 2026 +0200 1 file changed, 2 insertions(+), 4 deletions(-) ✔ Patches applied There are 2 commits in the PR. Attempting autorebase. (node:339) [DEP0190] DeprecationWarning: Passing args to a child process with shell option true can lead to security vulnerabilities, as the arguments are not escaped, only concatenated. (Use `node --trace-deprecation ...` to show where the warning was created) Rebasing (2/4) Executing: git node land --amend --yes --------------------------------- New Message ---------------------------------- buffer: fix end parameter bugs in indexOf/lastIndexOf
Signed-off-by: Robert Nagy <ronagy@icloud.com>
|
|
Landed in 8176c2c |
- Fix FastIndexOfNumber parameter order mismatch (end_i64 and is_forward were swapped vs the JS call site and slow path) - Clamp negative end values to 0 to prevent size_t overflow in IndexOfString, IndexOfBuffer, and IndexOfNumberImpl - Clamp empty needle result to search_end Signed-off-by: Robert Nagy <ronagy@icloud.com> Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com> PR-URL: #62711 Fixes: #62873 Reviewed-By: Filip Skokan <panva.ip@gmail.com> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
- Fix FastIndexOfNumber parameter order mismatch (end_i64 and is_forward were swapped vs the JS call site and slow path) - Clamp negative end values to 0 to prevent size_t overflow in IndexOfString, IndexOfBuffer, and IndexOfNumberImpl - Clamp empty needle result to search_end Signed-off-by: Robert Nagy <ronagy@icloud.com> Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com> PR-URL: nodejs#62711 Fixes: nodejs#62873 Reviewed-By: Filip Skokan <panva.ip@gmail.com> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Signed-off-by: Stewart X Addison <sxa@ibm.com>
- Fix FastIndexOfNumber parameter order mismatch (end_i64 and is_forward were swapped vs the JS call site and slow path) - Clamp negative end values to 0 to prevent size_t overflow in IndexOfString, IndexOfBuffer, and IndexOfNumberImpl - Clamp empty needle result to search_end Signed-off-by: Robert Nagy <ronagy@icloud.com> Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com> PR-URL: #62711 Fixes: #62873 Reviewed-By: Filip Skokan <panva.ip@gmail.com> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
The frame parser called indexOf(value, 'hex', startingIndex). Node up to 24.18.1 treated the string byteOffset as the encoding and ignored the third argument, so it worked by accident. Node 24.20.0 (nodejs/node#62711) now honours the argument positions, and the suffix search returned -1 for every frame: the parser waited forever for more data, no inbound packet was dispatched, and every ping timed out while the device answered normally.
The frame parser called indexOf(value, 'hex', startingIndex). Node up to 24.18.1 treated the string byteOffset as the encoding and ignored the third argument, so it worked by accident. Node 24.20.0 (nodejs/node#62711) now honours the argument positions, and the suffix search returned -1 for every frame: the parser waited forever for more data, no inbound packet was dispatched, and every ping timed out while the device answered normally.
Fixes: #62873