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

[v8.x backport] crypto: do not reach into OpenSSL internals for ThrowCryptoError #18327

Closed

Conversation

yhwang
Copy link
Member

@yhwang yhwang commented Jan 23, 2018

There is a perfectly serviceable ERR_get_error function which avoids
having to sniff through the OpenSSL ring buffer like that. It does
return the errors in the opposite order, but that's easily fixed with
std::reverse.

Note this behavior is slightly different in that an ERR_get_error loop
will ultimately clear the error queue, but this is desirable. Leaving
the error queue uncleared means errors in subsequent operations may get
mixed up and cause issues.

Original PR-URL: #16701
Reviewed-By: Ben Noordhuis info@bnoordhuis.nl

@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. crypto Issues and PRs related to the crypto subsystem. v8.x labels Jan 23, 2018
@@ -5422,7 +5413,7 @@ void PBKDF2(const FunctionCallbackInfo<Value>& args) {
}

raw_keylen = args[3]->NumberValue();
if (raw_keylen < 0.0 || isnan(raw_keylen) || isinf(raw_keylen) ||
if (raw_keylen < 0.0 || std::isnan(raw_keylen) || std::isinf(raw_keylen) ||
Copy link
Member Author

Choose a reason for hiding this comment

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

Since algorithm header is added above and cmath is included in algorithm, the standard isnan and isinf macros are undefined and new functions are introduced under std namespace. Therefore, need to use std namespace for these 2 functions.
You can see more detailed information in cmath header.

@gibfahn gibfahn requested a review from bnoordhuis January 23, 2018 22:57
@gibfahn
Copy link
Member

gibfahn commented Jan 23, 2018

@bnoordhuis could you confirm that this makes sense?

@gibfahn
Copy link
Member

gibfahn commented Jan 23, 2018

@gibfahn gibfahn force-pushed the v8.x-staging branch 2 times, most recently from 68a631f to aff27a1 Compare January 24, 2018 02:46
@yhwang yhwang force-pushed the backport-16701-to-v8.x-staging branch from ad97c44 to 357ea02 Compare January 24, 2018 18:00
@yhwang
Copy link
Member Author

yhwang commented Jan 24, 2018

rebased my branch to upstream/v8.x-staging.

and 2 test cases failed in windows:

not ok 407 parallel/test-tls-server-verify
not ok 506 sequential/test-inspector-bindings # TODO : Fix flaky test

I saw another v8.x backport PR also has the same failures.

@gibfahn
Copy link
Member

gibfahn commented Jan 24, 2018

@yhwang
Copy link
Member Author

yhwang commented Jan 24, 2018

CI 2: https://ci.nodejs.org/job/node-test-commit/15662/

The results are the same as the first one. These 2 test cases still failed in Windows:

not ok 407 parallel/test-tls-server-verify
not ok 505 sequential/test-inspector-async-call-stack # TODO : Fix flaky test

@bnoordhuis
Copy link
Member

@yhwang Can you rebase? The test failures are known flakes.

@yhwang yhwang force-pushed the backport-16701-to-v8.x-staging branch from 357ea02 to 08bad94 Compare January 25, 2018 19:03
@yhwang
Copy link
Member Author

yhwang commented Jan 25, 2018

@bnoordhuis I just rebased. Please kick off another CI to verify it. Thanks.

@gibfahn
Copy link
Member

gibfahn commented Jan 26, 2018

@bnoordhuis
Copy link
Member

@yhwang I'm afraid this needs another rebase.

@yhwang yhwang force-pushed the backport-16701-to-v8.x-staging branch from 08bad94 to de47005 Compare February 2, 2018 17:24
@yhwang
Copy link
Member Author

yhwang commented Feb 2, 2018

@bnoordhuis sure thing and it's done.

[Edit] Please kick off a CI to verify it it

@yhwang yhwang force-pushed the backport-16701-to-v8.x-staging branch from de47005 to d13ac52 Compare February 7, 2018 18:49
@yhwang
Copy link
Member Author

yhwang commented Feb 7, 2018

Rebase again because of the conflict and please kick off a CI. Thanks.

@mhdawson
Copy link
Member

mhdawson commented Feb 9, 2018

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

@yhwang
Copy link
Member Author

yhwang commented Feb 12, 2018

failed on windows-test. it complains about cctest.exe not found. However, the windows build task passed, I downloaded the binary.tar.gz and the cctest.exe and node.exe inside the tarball work well.

@gibfahn
Copy link
Member

gibfahn commented Feb 18, 2018

Sorry @yhwang , looks like this needs (yet another) rebase after the V8 update.

@yhwang
Copy link
Member Author

yhwang commented Feb 19, 2018

rebase failed and need to solve lots of conflict in v8. Let me use a new branch which is from the latest v8.x-staging. that's will be easier.

There is a perfectly serviceable ERR_get_error function which avoids
having to sniff through the OpenSSL ring buffer like that. It does
return the errors in the opposite order, but that's easily fixed with
std::reverse.

Note this behavior is slightly different in that an ERR_get_error loop
will ultimately clear the error queue, but this is desirable. Leaving
the error queue uncleared means errors in subsequent operations may get
mixed up and cause issues.

PR-URL: nodejs#16701
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
@yhwang yhwang force-pushed the backport-16701-to-v8.x-staging branch from d13ac52 to c96e3c9 Compare February 19, 2018 18:04
@yhwang
Copy link
Member Author

yhwang commented Feb 19, 2018

@gibfahn
Copy link
Member

gibfahn commented Feb 20, 2018

rebase failed and need to solve lots of conflict in v8. Let me use a new branch which is from the latest v8.x-staging. that's will be easier.

Yeah I frequently just do reset --hard up/v8.x-staging; git cherry-pick mybranch instead of actually rebasing.

@gibfahn
Copy link
Member

gibfahn commented Feb 20, 2018

@bnoordhuis would you mind taking a quick look?

gibfahn pushed a commit that referenced this pull request Feb 20, 2018
There is a perfectly serviceable ERR_get_error function which avoids
having to sniff through the OpenSSL ring buffer like that. It does
return the errors in the opposite order, but that's easily fixed with
std::reverse.

Note this behavior is slightly different in that an ERR_get_error loop
will ultimately clear the error queue, but this is desirable. Leaving
the error queue uncleared means errors in subsequent operations may get
mixed up and cause issues.

PR-URL: #16701
Backport-PR-URL: #18327
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
@gibfahn
Copy link
Member

gibfahn commented Feb 20, 2018

Landed in 8cc0ea7

@gibfahn gibfahn closed this Feb 20, 2018
@yhwang yhwang deleted the backport-16701-to-v8.x-staging branch February 20, 2018 19:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c++ Issues and PRs that require attention from people who are familiar with C++. crypto Issues and PRs related to the crypto subsystem.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants