Skip to content

src: handle null backing store in ArrayBufferViewContents::Read#62343

Merged
nodejs-github-bot merged 1 commit intonodejs:mainfrom
mertcanaltin:mert/fix/ccm-zero-length-dataview
Mar 29, 2026
Merged

src: handle null backing store in ArrayBufferViewContents::Read#62343
nodejs-github-bot merged 1 commit intonodejs:mainfrom
mertcanaltin:mert/fix/ccm-zero-length-dataview

Conversation

@mertcanaltin
Copy link
Copy Markdown
Member

@mertcanaltin mertcanaltin commented Mar 19, 2026

added fallback stack_storage for null scenario

Fixes: #62342

@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. needs-ci PRs that need a full CI run. labels Mar 19, 2026
@mertcanaltin mertcanaltin force-pushed the mert/fix/ccm-zero-length-dataview branch from 664507a to 88f8f03 Compare March 19, 2026 20:58
@codecov
Copy link
Copy Markdown

codecov bot commented Mar 19, 2026

Codecov Report

❌ Patch coverage is 66.66667% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 89.69%. Comparing base (0998c37) to head (7d46389).
⚠️ Report is 53 commits behind head on main.

Files with missing lines Patch % Lines
src/util-inl.h 66.66% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #62343      +/-   ##
==========================================
- Coverage   91.60%   89.69%   -1.91%     
==========================================
  Files         337      676     +339     
  Lines      140741   206695   +65954     
  Branches    21797    39579   +17782     
==========================================
+ Hits       128923   185398   +56475     
- Misses      11594    13438    +1844     
- Partials      224     7859    +7635     
Files with missing lines Coverage Δ
src/util-inl.h 82.35% <66.66%> (ø)

... and 459 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.

Copy link
Copy Markdown
Member

@panva panva left a comment

Choose a reason for hiding this comment

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

With ArrayBufferViewContents being used broadly throughout node's codebase I wonder if we can be sure this is entirely without side effects. I cannot assess that.

That being said, it does fix the particular node:crypto issue reported.

@mertcanaltin
Copy link
Copy Markdown
Member Author

mertcanaltin commented Mar 20, 2026

With ArrayBufferViewContents being used broadly throughout node's codebase I wonder if we can be sure this is entirely without side effects. I cannot assess that.

That being said, it does fix the particular node:crypto issue reported.

I went through all 19 files that use ArrayBufferViewContents, every usage passes data() alongside length(), and none dereferences the pointer when length is 0. Currently data_ can already be null in this scenario, this fix just ensures it's a valid pointer instead, so it's strictly safer than the current behavior.

@panva
Copy link
Copy Markdown
Member

panva commented Mar 20, 2026

I went through all 19 files that use ArrayBufferViewContents, every usage passes data() alongside length(), and none dereferences the pointer when length is 0. Currently data_ can already be null in this scenario, this fix just ensures it's a valid pointer instead, so it's strictly safer than the current behavior.

Very well, can you update the commit message to src: handle null backing store in ArrayBufferViewContents::Read?

@mertcanaltin mertcanaltin force-pushed the mert/fix/ccm-zero-length-dataview branch from 88f8f03 to 8104939 Compare March 20, 2026 10:11
@mertcanaltin
Copy link
Copy Markdown
Member Author

I went through all 19 files that use ArrayBufferViewContents, every usage passes data() alongside length(), and none dereferences the pointer when length is 0. Currently data_ can already be null in this scenario, this fix just ensures it's a valid pointer instead, so it's strictly safer than the current behavior.

Very well, can you update the commit message to src: handle null backing store in ArrayBufferViewContents::Read?

sure, edited thanks

@panva panva changed the title src: ccm cipher update with zero-length dataView src: handle null backing store in ArrayBufferViewContents::Read Mar 20, 2026
@panva panva added author ready PRs that have at least one approval, no pending requests for changes, and a CI started. request-ci Add this label to start a Jenkins CI on a PR. labels Mar 20, 2026
@mertcanaltin mertcanaltin force-pushed the mert/fix/ccm-zero-length-dataview branch 3 times, most recently from cf77348 to 71b8c2a Compare March 20, 2026 20:58
Fixes: nodejs#62342

src: handle null backing store in ArrayBufferViewContents::Read
@mertcanaltin mertcanaltin force-pushed the mert/fix/ccm-zero-length-dataview branch from 71b8c2a to 7d46389 Compare March 20, 2026 21:18
Copy link
Copy Markdown
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

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

lgtm

@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Mar 26, 2026
@nodejs-github-bot

This comment was marked as outdated.

@nodejs-github-bot

This comment was marked as outdated.

@nodejs-github-bot
Copy link
Copy Markdown
Collaborator

@nodejs-github-bot
Copy link
Copy Markdown
Collaborator

@mcollina mcollina added the commit-queue Add this label to land a pull request using GitHub Actions. label Mar 29, 2026
@nodejs-github-bot nodejs-github-bot removed the commit-queue Add this label to land a pull request using GitHub Actions. label Mar 29, 2026
@nodejs-github-bot nodejs-github-bot merged commit bdf75a6 into nodejs:main Mar 29, 2026
62 of 63 checks passed
@nodejs-github-bot
Copy link
Copy Markdown
Collaborator

Landed in bdf75a6

@Renegade334 Renegade334 added lts-watch-v20.x PRs that may need to be released in v20.x lts-watch-v22.x PRs that may need to be released in v22.x lts-watch-v24.x PRs that may need to be released in v24.x labels Mar 29, 2026
Renegade334 added a commit to Renegade334/node that referenced this pull request Mar 29, 2026
When ABVC receives a view on an array buffer with a null data pointer,
it sets its own data pointer to uninitialized stack memory. While V8
_should_ always have the view length set to zero in this case, it's
worth double-checking.

Refs: nodejs#62343
RafaelGSS pushed a commit to RafaelGSS/node that referenced this pull request Mar 30, 2026
Fixes: nodejs#62342

src: handle null backing store in ArrayBufferViewContents::Read
PR-URL: nodejs#62343
Fixes: nodejs#62342
Reviewed-By: René <contact.9a5d6388@renegade334.me.uk>
Reviewed-By: Filip Skokan <panva.ip@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author ready PRs that have at least one approval, no pending requests for changes, and a CI started. c++ Issues and PRs that require attention from people who are familiar with C++. lts-watch-v20.x PRs that may need to be released in v20.x lts-watch-v22.x PRs that may need to be released in v22.x lts-watch-v24.x PRs that may need to be released in v24.x needs-ci PRs that need a full CI run.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

cipher.update() fails for CCM mode with zero-length ArrayBufferView backed by explicit ArrayBuffer

6 participants