summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorFedor Indutny <fedor.indutny@gmail.com>2014-01-26 20:09:14 +0400
committerFedor Indutny <fedor.indutny@gmail.com>2014-01-26 22:24:57 +0400
commitb4c4e0bbaa19616f41857e20c2dc2824c780baf4 (patch)
tree6b764ba2c94d8eeb303f87a8485d8ee043b5a62e /src
parent00efcb4cd7609dcefad8acba915d850480436457 (diff)
downloadnode-b4c4e0bbaa19616f41857e20c2dc2824c780baf4.tar.gz
crypto: throw on SignFinal failure
fix #6963
Diffstat (limited to 'src')
-rw-r--r--src/node_crypto.cc13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/node_crypto.cc b/src/node_crypto.cc
index 87025dd6b..d9eda59b8 100644
--- a/src/node_crypto.cc
+++ b/src/node_crypto.cc
@@ -3005,9 +3005,15 @@ class Sign : public ObjectWrap {
if(!BIO_write(bp, key_pem, key_pemLen)) return 0;
pkey = PEM_read_bio_PrivateKey( bp, NULL, NULL, NULL );
- if (pkey == NULL) return 0;
+ if (pkey == NULL) {
+ ERR_print_errors_fp(stderr);
+ return 0;
+ }
- EVP_SignFinal(&mdctx, *md_value, md_len, pkey);
+ if (!EVP_SignFinal(&mdctx, *md_value, md_len, pkey)) {
+ ERR_print_errors_fp(stderr);
+ return 0;
+ }
EVP_MD_CTX_cleanup(&mdctx);
initialised_ = false;
EVP_PKEY_free(pkey);
@@ -3107,8 +3113,11 @@ class Sign : public ObjectWrap {
int r = sign->SignFinal(&md_value, &md_len, buf, len);
if (r == 0) {
+ delete [] buf;
+ delete [] md_value;
md_value = NULL;
md_len = r;
+ return ThrowException(Exception::Error(String::New("SignFinal error")));
}
delete [] buf;