diff options
author | Ondřej Surý <ondrej@sury.org> | 2014-05-05 10:13:25 +0200 |
---|---|---|
committer | Ondřej Surý <ondrej@sury.org> | 2014-05-05 10:13:25 +0200 |
commit | 0a16a96c45a8a3b2999106b025c9c61ff1fdeb31 (patch) | |
tree | a92b26e687223eb0c6965ea85334697eb6775d44 /ext/openssl/openssl.c | |
parent | 83681d9fae3e6fb96ab01e7a4166b7d9261a4e55 (diff) | |
download | php-upstream/5.5.12+dfsg.tar.gz |
New upstream version 5.5.12+dfsgupstream/5.5.12+dfsg
Diffstat (limited to 'ext/openssl/openssl.c')
-rwxr-xr-x | ext/openssl/openssl.c | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/ext/openssl/openssl.c b/ext/openssl/openssl.c index e887ca769..b2b8c0e56 100755 --- a/ext/openssl/openssl.c +++ b/ext/openssl/openssl.c @@ -4384,6 +4384,7 @@ PHP_FUNCTION(openssl_seal) if (!EVP_EncryptInit(&ctx,cipher,NULL,NULL)) { RETVAL_FALSE; + EVP_CIPHER_CTX_cleanup(&ctx); goto clean_exit; } @@ -4394,10 +4395,12 @@ PHP_FUNCTION(openssl_seal) #endif /* allocate one byte extra to make room for \0 */ buf = emalloc(data_len + EVP_CIPHER_CTX_block_size(&ctx)); + EVP_CIPHER_CTX_cleanup(&ctx); if (!EVP_SealInit(&ctx, cipher, eks, eksl, NULL, pkeys, nkeys) || !EVP_SealUpdate(&ctx, buf, &len1, (unsigned char *)data, data_len)) { RETVAL_FALSE; efree(buf); + EVP_CIPHER_CTX_cleanup(&ctx); goto clean_exit; } @@ -4430,6 +4433,7 @@ PHP_FUNCTION(openssl_seal) efree(buf); } RETVAL_LONG(len1 + len2); + EVP_CIPHER_CTX_cleanup(&ctx); clean_exit: for (i=0; i<nkeys; i++) { @@ -4488,25 +4492,21 @@ PHP_FUNCTION(openssl_open) if (EVP_OpenInit(&ctx, cipher, (unsigned char *)ekey, ekey_len, NULL, pkey) && EVP_OpenUpdate(&ctx, buf, &len1, (unsigned char *)data, data_len)) { if (!EVP_OpenFinal(&ctx, buf + len1, &len2) || (len1 + len2 == 0)) { efree(buf); - if (keyresource == -1) { - EVP_PKEY_free(pkey); - } - RETURN_FALSE; + RETVAL_FALSE; + } else { + zval_dtor(opendata); + buf[len1 + len2] = '\0'; + ZVAL_STRINGL(opendata, erealloc(buf, len1 + len2 + 1), len1 + len2, 0); + RETVAL_TRUE; } } else { efree(buf); - if (keyresource == -1) { - EVP_PKEY_free(pkey); - } - RETURN_FALSE; + RETVAL_FALSE; } if (keyresource == -1) { EVP_PKEY_free(pkey); } - zval_dtor(opendata); - buf[len1 + len2] = '\0'; - ZVAL_STRINGL(opendata, erealloc(buf, len1 + len2 + 1), len1 + len2, 0); - RETURN_TRUE; + EVP_CIPHER_CTX_cleanup(&ctx); } /* }}} */ |