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 — lib: fix max size check in Buffer constructor by bnoordhuis · Pull Request #657 · nodejs/node

Conversation

@bnoordhuis

@bnoordhuis bnoordhuis commented Jan 29, 2015

Copy link
Copy Markdown
Member

A logic error let buffer sizes larger than kMaxLength (0x3fffffff) slip
through. The .toString() operation (and possibly others as well) then
blew up because the buffer was larger than it could reasonably handle.

Fixes the following run-time assert:

#
# Fatal error in ../deps/v8/src/handles.h, line 48
# CHECK(location_ != NULL) failed
#

==== C stack trace ===============================

 1: V8_Fatal
 2: v8::String::NewFromUtf8(v8::Isolate*, char const*, v8::String::NewStringType, int)
 3: node::StringBytes::Encode(v8::Isolate*, char const*, unsigned long, node::encoding)
 4: node::Buffer::Utf8Slice(v8::FunctionCallbackInfo<v8::Value> const&)
 5: v8::internal::FunctionCallbackArguments::Call(void (*)(v8::FunctionCallbackInfo<v8::Value> const&))
 6: ??
 7: ??

Fixes: #649

R=@trevnorris?

Sorry, something went wrong.

Uh oh!

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

All reactions
@bnoordhuis bnoordhuis mentioned this pull request Jan 29, 2015
V8 Fatal Error when trying to convert a buffered integer to string #649
Closed
@bnoordhuis

bnoordhuis commented Jan 29, 2015

Copy link
Copy Markdown
Member Author

The commit log is admittedly a little weak. The failing CHECK is related to but not exclusively caused by the bad length check in lib/buffer.js.

All reactions

Sorry, something went wrong.

Uh oh!

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

@bnoordhuis
bnoordhuis force-pushed the fix-issue-649 branch from edda11f to fca484e Compare January 29, 2015 21:09
@trevnorris

trevnorris commented Jan 30, 2015

Copy link
Copy Markdown
Contributor

LGTM

All reactions

Sorry, something went wrong.

Uh oh!

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

@bnoordhuis
lib: fix max size check in Buffer constructor
0767c2f
A number -> uint32 type coercion bug made buffer sizes
larger than kMaxLength (0x3fffffff) wrap around.

Instead of rejecting the requested size with an exception,
the constructor created a buffer with the wrong size.

PR-URL: nodejs#657
Reviewed-By: Trevor Norris <[email protected]>
@bnoordhuis
bnoordhuis force-pushed the fix-issue-649 branch from fca484e to 0767c2f Compare January 31, 2015 09:15
@bnoordhuis
bnoordhuis merged commit 0767c2f into nodejs:v1.x Jan 31, 2015
@bnoordhuis
bnoordhuis deleted the fix-issue-649 branch January 31, 2015 09:15
feross added a commit to feross/buffer that referenced this pull request Feb 10, 2015
@feross
fix max size check in Buffer constructor
f77fa92
Copied from nodejs/node#657
trevnorris pushed a commit to nodejs/node-v0.x-archive that referenced this pull request Feb 10, 2015
@bnoordhuis @trevnorris
lib: fix max size check in Buffer constructor
04b63e0
A number -> uint32 type coercion bug made buffer sizes
larger than kMaxLength (0x3fffffff) wrap around.

Instead of rejecting the requested size with an exception,
the constructor created a buffer with the wrong size.

PR-URL: nodejs/node#657
Reviewed-By: Trevor Norris <[email protected]>
@joyeecheung joyeecheung mentioned this pull request Dec 5, 2016
test: fix test for buffer regression #649 #9924
Closed
2 tasks done
@aliscco aliscco mentioned this pull request Apr 28, 2023
[Snyk] Fix for 9 vulnerabilities aliscco/alisco-node#330
Open
@leonardoadame leonardoadame mentioned this pull request Feb 2, 2024
[Snyk] Security upgrade babel-eslint from 7.2.3 to 10.1.0 leonardoadame/node#633
Open
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

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

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

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

2 participants

@bnoordhuis @trevnorris
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 01402775 — 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.