Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Zero-byte allocation causes assertion failure #25247

Closed
tniessen opened this issue Dec 28, 2018 · 3 comments

Comments

@tniessen
Copy link
Member

commented Dec 28, 2018

  • Version: 11.6.0
  • Platform: Ubuntu, Windows
  • Subsystem: crypto

Passing an empty string to any function that parses a private key causes an assertion failure:

> crypto.createPrivateKey({ key: '' })
C:\WINDOWS\system32\cmd.exe - node[12104]: src\node_crypto.cc:2675: Assertion `(mem) != nullptr' failed.
tniessen added a commit to tniessen/node that referenced this issue Dec 28, 2018
When an empty string was passed, malloc might have returned a nullptr
depending on the platform, causing an assertion failure. This change
makes private key parsing behave as public key parsing does, causing
a BIO error instead that can be caught in JS.

Fixes: nodejs#25247
@juanarbol

This comment has been minimized.

Copy link
Contributor

commented Dec 28, 2018

Same in macOS high sierra

@ryzokuken

This comment has been minimized.

Copy link
Member

commented Dec 28, 2018

@tniessen are you looking into this or should I give it a swing?

P.S. should've seen the ref.

@cjihrig

This comment has been minimized.

Copy link
Contributor

commented Dec 28, 2018

#25248

@addaleax addaleax closed this in fe5b8dc Dec 30, 2018
targos added a commit that referenced this issue Jan 1, 2019
When an empty string was passed, malloc might have returned a nullptr
depending on the platform, causing an assertion failure. This change
makes private key parsing behave as public key parsing does, causing
a BIO error instead that can be caught in JS.

Fixes: #25247

PR-URL: #25248
Reviewed-By: Ujjwal Sharma <usharma1998@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
refack added a commit to refack/node that referenced this issue Jan 14, 2019
When an empty string was passed, malloc might have returned a nullptr
depending on the platform, causing an assertion failure. This change
makes private key parsing behave as public key parsing does, causing
a BIO error instead that can be caught in JS.

Fixes: nodejs#25247

PR-URL: nodejs#25248
Reviewed-By: Ujjwal Sharma <usharma1998@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants
You can’t perform that action at this time.