Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.

Commit

Permalink
Prevent crash when Openssl's PKCS12_parse function fails.
Browse files Browse the repository at this point in the history
The output parameters were not getting cleared on failure, so freed native
pointers were being pushed up into managed handles.

Backport ec8080d to release/1.0.0
  • Loading branch information
bartonjs committed Aug 7, 2017
1 parent 12a4765 commit 3af071c
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/Native/System.Security.Cryptography.Native/pal_pkcs12.cpp
Expand Up @@ -55,6 +55,16 @@ extern "C" int32_t CryptoNative_Pkcs12Parse(PKCS12* p12, const char* pass, EVP_P
// error queue. If we're returning success, clear the error queue.
ERR_clear_error();
}
else
{
// If PKCS12_parse encounters an error it will free the handles it
// created, but it does not clear the output parameters they were
// placed in.
// If those handles make it back into managed code they will crash
// the coreclr when Disposed.
*pkey = nullptr;
*cert = nullptr;
}

return ret;
}

0 comments on commit 3af071c

Please sign in to comment.