GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — ffi: validate fast pointer BigInt argument ranges by trivikr · Pull Request #65032 · nodejs/node

Conversation

@trivikr

@trivikr trivikr commented Aug 5, 2026

Copy link
Copy Markdown
Member

Fixes: #65031

Optimized V8 fast API calls truncate out-of-range pointer BigInts. Validate them against uintptrMax before invoking the raw function so optimized calls match the generic and shared-buffer paths.


Assisted-by: codex:gpt-5.6-sol

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@trivikr
ffi: validate fast pointer BigInt argument ranges
7f83e09
Optimized V8 fast API calls truncate out-of-range pointer BigInts.
Validate them against uintptrMax before invoking the raw function
so optimized calls match the generic and shared-buffer paths.

Signed-off-by: Kamat, Trivikram <[email protected]>
Assisted-by: codex:gpt-5.6-sol
@nodejs-github-bot

nodejs-github-bot commented Aug 5, 2026

Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/ffi
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. ffi Issues and PRs related to experimental Foreign Function Interface support. needs-ci PRs that need a full CI run. labels Aug 5, 2026
@trivikr trivikr added the request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. label Aug 5, 2026
@codecov

codecov Bot commented Aug 5, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.30%. Comparing base (c8fa0b1) to head (7f83e09).
⚠️ Report is 113 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #65032      +/-   ##
==========================================
- Coverage   92.04%   90.30%   -1.74%     
==========================================
  Files         399      759     +360     
  Lines      175810   247645   +71835     
  Branches    27119    46693   +19574     
==========================================
+ Hits       161816   223630   +61814     
- Misses      13682    15467    +1785     
- Partials      312     8548    +8236     
Files with missing lines Coverage Δ
lib/internal/ffi/fast-api.js 94.13% <100.00%> (+68.58%) ⬆️
src/node_ffi.cc 70.71% <ø> (ø)

... and 488 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

mcollina
mcollina approved these changes Aug 6, 2026
View reviewed changes

@mcollina mcollina left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@github-actions github-actions Bot removed the request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. label Aug 6, 2026
@nodejs-github-bot

This comment was marked as outdated.

Sign in to view
@nodejs-github-bot

nodejs-github-bot commented Aug 6, 2026

Copy link
Copy Markdown
Collaborator

CI: https://ci.nodejs.org/job/node-test-pull-request/75567/

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@trivikr trivikr added the commit-queue PRs queued for automated landing through the Commit Queue. label Aug 11, 2026
@nodejs-github-bot
nodejs-github-bot merged commit 2fbd056 into nodejs:main Aug 12, 2026
83 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@nodejs-github-bot

nodejs-github-bot commented Aug 12, 2026

Copy link
Copy Markdown
Collaborator

Landed in 2fbd056

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@nodejs-github-bot nodejs-github-bot removed the commit-queue PRs queued for automated landing through the Commit Queue. label Aug 12, 2026
aduh95 pushed a commit that referenced this pull request Aug 13, 2026
@trivikr @aduh95
ffi: validate fast pointer BigInt argument ranges
562f05f
Optimized V8 fast API calls truncate out-of-range pointer BigInts.
Validate them against uintptrMax before invoking the raw function
so optimized calls match the generic and shared-buffer paths.

Signed-off-by: Kamat, Trivikram <[email protected]>
Assisted-by: codex:gpt-5.6-sol
PR-URL: #65032
Fixes: #65031
Reviewed-By: Matteo Collina <[email protected]>
@trivikr
trivikr deleted the ffi-bigint-range-bypass branch August 16, 2026 16:01
This was referenced Aug 17, 2026
ffi: setFloat32()/setFloat64() coerce their value and discard a pending exception #65341
Closed
ffi: validate the value passed to the float setters #65342
Merged
nodejs-github-bot pushed a commit that referenced this pull request Aug 19, 2026
@soulee-dev
ffi: validate the value passed to the float setters
f3a8f1a
setInt8() through setUint64() require IsNumber() before any range check
and reject anything else with ERR_INVALID_ARG_VALUE, but setFloat32()
and setFloat64() call ToNumber() and write whatever it returns, so a
string, a boolean or a plain object is converted instead of rejected
and a typo such as '1,5' stores NaN in native memory with no error at
the call site. The same double is type-checked when it is passed as a
call argument: ToFFIArgument() requires IsNumber() and otherwise throws
"Argument %s must be a double".

The coercion also discards a pending exception. When ToNumber() fails
because the value has a valueOf() that throws, the branch throws
ERR_INVALID_ARG_VALUE on top of the exception V8 has already scheduled,
so the original error never reaches the caller, whereas
DataView.prototype.setFloat64() and Buffer.prototype.writeDoubleLE()
both propagate it.

Check IsNumber() instead, matching the wording of the integer setters
and of ToFFIArgument(). The check runs before any conversion, so
valueOf() is never invoked and there is no pending exception left to
discard. This was the only ToNumber(context) call in src/.

Signed-off-by: Soul Lee <[email protected]>
PR-URL: #65342
Fixes: #65341
Refs: #62858
Refs: #64614
Refs: #64691
Refs: #65032
Reviewed-By: Trivikram Kamat <[email protected]>
Reviewed-By: Paolo Insogna <[email protected]>
Reviewed-By: Juan José Arboleda <[email protected]>
aduh95 pushed a commit that referenced this pull request Aug 25, 2026
@soulee-dev @aduh95
ffi: validate the value passed to the float setters
938aad4
setInt8() through setUint64() require IsNumber() before any range check
and reject anything else with ERR_INVALID_ARG_VALUE, but setFloat32()
and setFloat64() call ToNumber() and write whatever it returns, so a
string, a boolean or a plain object is converted instead of rejected
and a typo such as '1,5' stores NaN in native memory with no error at
the call site. The same double is type-checked when it is passed as a
call argument: ToFFIArgument() requires IsNumber() and otherwise throws
"Argument %s must be a double".

The coercion also discards a pending exception. When ToNumber() fails
because the value has a valueOf() that throws, the branch throws
ERR_INVALID_ARG_VALUE on top of the exception V8 has already scheduled,
so the original error never reaches the caller, whereas
DataView.prototype.setFloat64() and Buffer.prototype.writeDoubleLE()
both propagate it.

Check IsNumber() instead, matching the wording of the integer setters
and of ToFFIArgument(). The check runs before any conversion, so
valueOf() is never invoked and there is no pending exception left to
discard. This was the only ToNumber(context) call in src/.

Signed-off-by: Soul Lee <[email protected]>
PR-URL: #65342
Fixes: #65341
Refs: #62858
Refs: #64614
Refs: #64691
Refs: #65032
Reviewed-By: Trivikram Kamat <[email protected]>
Reviewed-By: Paolo Insogna <[email protected]>
Reviewed-By: Juan José Arboleda <[email protected]>
aduh95 pushed a commit that referenced this pull request Aug 25, 2026
@trivikr @aduh95
ffi: validate fast pointer BigInt argument ranges
6f9e084
Optimized V8 fast API calls truncate out-of-range pointer BigInts.
Validate them against uintptrMax before invoking the raw function
so optimized calls match the generic and shared-buffer paths.

Signed-off-by: Kamat, Trivikram <[email protected]>
Assisted-by: codex:gpt-5.6-sol
PR-URL: #65032
Fixes: #65031
Reviewed-By: Matteo Collina <[email protected]>
aduh95 pushed a commit that referenced this pull request Aug 25, 2026
@soulee-dev @aduh95
ffi: validate the value passed to the float setters
1fe7a1c
setInt8() through setUint64() require IsNumber() before any range check
and reject anything else with ERR_INVALID_ARG_VALUE, but setFloat32()
and setFloat64() call ToNumber() and write whatever it returns, so a
string, a boolean or a plain object is converted instead of rejected
and a typo such as '1,5' stores NaN in native memory with no error at
the call site. The same double is type-checked when it is passed as a
call argument: ToFFIArgument() requires IsNumber() and otherwise throws
"Argument %s must be a double".

The coercion also discards a pending exception. When ToNumber() fails
because the value has a valueOf() that throws, the branch throws
ERR_INVALID_ARG_VALUE on top of the exception V8 has already scheduled,
so the original error never reaches the caller, whereas
DataView.prototype.setFloat64() and Buffer.prototype.writeDoubleLE()
both propagate it.

Check IsNumber() instead, matching the wording of the integer setters
and of ToFFIArgument(). The check runs before any conversion, so
valueOf() is never invoked and there is no pending exception left to
discard. This was the only ToNumber(context) call in src/.

Signed-off-by: Soul Lee <[email protected]>
PR-URL: #65342
Fixes: #65341
Refs: #62858
Refs: #64614
Refs: #64691
Refs: #65032
Reviewed-By: Trivikram Kamat <[email protected]>
Reviewed-By: Paolo Insogna <[email protected]>
Reviewed-By: Juan José Arboleda <[email protected]>
@github-actions github-actions Bot mentioned this pull request Aug 25, 2026
2026-08-26, Version 26.8.0 (Current) #65551
Merged
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@mcollina mcollina mcollina approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

c++ Issues and PRs that require attention from people who are familiar with C++. ffi Issues and PRs related to experimental Foreign Function Interface support. needs-ci PRs that need a full CI run.

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

ffi: optimized fast pointer BigInts bypass range validation

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@trivikr @nodejs-github-bot @mcollina
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.