You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
crypto test coverage - remaining blockers in crypto #17731
That if (ret === -1) check is simply wrong and can be removed. The synchronous version of PBKDF2() never returns that - it either returns a buffer or it throws an exception.
It shouldn't be possible to reach that if (mdctx_ == nullptr) branch. It can be removed or replaced with a CHECK_NE(mdctx_, nullptr).
Does code coverage see a CHECK as a branch without coverage? I'm guessing no because it's a termination point.
The original confusion here might come from the fact that C++ return values are not what gets returns to the JS land, those return values come from args.GetReturnValue().Set(value); calls.
Re: HashUpdate, I don't know this code nearly as well as @bnoordhuis but just following the logic there, it seems like one could reach the false state at the very least the following way:
Ah, so that was changed recently in 7124b46, before that it worked the way I described.
it seems like one could reach the false state at the very least the following way
That's not the line @Leko linked to, though. That line should be unreachable because it should never be possible to construct a Hash object that has mdctx_ == nullptr, the constructor should throw when initialization fails.
That's not the line @Leko linked to, though. That line should be unreachable because it should never be possible to construct a Hash object that has mdctx_ == nullptr, the constructor should throw when initialization fails.
Sorry, I'm just responding to the original premise of "Can't throw ERR_CRYPTO_HASH_UPDATE_FAILED" which is definitely possible. Didn't mean to disagree re: it not being possible to reach via the route presented.
Activity
[-]crypto test coverage - remaining blockers in PBKDF2[/-][+]crypto test coverage - remaining blockers in crypto[/+]bnoordhuis commentedon Dec 18, 2017
That
if (ret === -1)check is simply wrong and can be removed. The synchronous version ofPBKDF2()never returns that - it either returns a buffer or it throws an exception.It shouldn't be possible to reach that
if (mdctx_ == nullptr)branch. It can be removed or replaced with aCHECK_NE(mdctx_, nullptr).Does code coverage see a CHECK as a branch without coverage? I'm guessing no because it's a termination point.
apapirovski commentedon Dec 18, 2017
Re:
ret === -1, that is actually not correct. It returns -1 if an invaliddigestis passed. Seenode/src/node_crypto.cc
Lines 5598 to 5607 in efffcc2
The original confusion here might come from the fact that C++
returnvalues are not what gets returns to the JS land, those return values come fromargs.GetReturnValue().Set(value);calls.Re:
HashUpdate, I don't know this code nearly as well as @bnoordhuis but just following the logic there, it seems like one could reach thefalsestate at the very least the following way:node/src/node_crypto.cc
Lines 4149 to 4152 in efffcc2
bnoordhuis commentedon Dec 18, 2017
Ah, so that was changed recently in 7124b46, before that it worked the way I described.
That's not the line @Leko linked to, though. That line should be unreachable because it should never be possible to construct a Hash object that has
mdctx_ == nullptr, the constructor should throw when initialization fails.apapirovski commentedon Dec 18, 2017
Sorry, I'm just responding to the original premise of "Can't throw ERR_CRYPTO_HASH_UPDATE_FAILED" which is definitely possible. Didn't mean to disagree re: it not being possible to reach via the route presented.
Leko commentedon Dec 21, 2017
@bnoordhuis @apapirovski
Thank you for your information.
I didn't know that. I'd misunderstood.
I'll try to reach this condition.