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
Closed

Zero-byte allocation causes assertion failure #25247

tniessen opened this issue Dec 28, 2018 · 3 comments
Assignees
Labels
confirmed-bug Issues with confirmed bugs. crypto Issues and PRs related to the crypto subsystem. security Issues and PRs related to security.

Comments

@tniessen
Copy link
Member

  • 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 tniessen added confirmed-bug Issues with confirmed bugs. crypto Issues and PRs related to the crypto subsystem. security Issues and PRs related to security. labels Dec 28, 2018
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
Copy link
Member

Same in macOS high sierra

@ryzokuken
Copy link
Contributor

ryzokuken 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
Copy link
Contributor

cjihrig commented Dec 28, 2018

#25248

targos pushed 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 <[email protected]>
Reviewed-By: Ben Noordhuis <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
refack pushed 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 <[email protected]>
Reviewed-By: Ben Noordhuis <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
confirmed-bug Issues with confirmed bugs. crypto Issues and PRs related to the crypto subsystem. security Issues and PRs related to security.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants