com php-src: merged changes for bug #63297 from 5.3: NEWS ext/phar/util.c
| From: | Anatoliy Belsky | Date: | Thu, 25 Oct 2012 07:40:21 +0000 |
| Subject: | com php-src: merged changes for bug #63297 from 5.3: NEWS ext/phar/util.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-70458@lists.php.net to get a copy of this message | ||
Commit: f962260081c4341c768533c5fb23c83c6ca9b1ed
Author: Anatoliy Belsky <ab@php.net> Thu, 25 Oct 2012 09:40:21 +0200
Parents: 9a6d8e250aa8cd7502f20059ad7b686ac814fc9e
Branches: PHP-5.4 master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=f962260081c4341c768533c5fb23c83c6ca9b1ed
Log:
merged changes for bug #63297 from 5.3
Bugs:
https://bugs.php.net/63297
Changed paths:
M NEWS
M ext/phar/util.c
Diff:
diff --git a/NEWS b/NEWS
index a039615..8a322a9 100644
--- a/NEWS
+++ b/NEWS
@@ -18,6 +18,10 @@ PHP NEWS
(Dmitry, Laruence)
. Fixed bug #63284 (Upgrade PCRE to 8.31). (Anatoliy)
+- Phar:
+ . Fixed bug #63297 (Phar fails to write an openssl based signature).
+ (Anatoliy)
+
18 Oct 2012, PHP 5.4.8
- CLI server:
diff --git a/ext/phar/util.c b/ext/phar/util.c
index 5fcb2b6..f674bca 100644
--- a/ext/phar/util.c
+++ b/ext/phar/util.c
@@ -2118,8 +2118,7 @@ int phar_create_signature(phar_archive_data *phar, php_stream *fp, char
**signat
#ifdef PHAR_HAVE_OPENSSL
BIO *in;
EVP_PKEY *key;
- EVP_MD *mdtype = (EVP_MD *) EVP_sha1();
- EVP_MD_CTX md_ctx;
+ EVP_MD_CTX *md_ctx;
in = BIO_new_mem_buf(PHAR_G(openssl_privatekey), PHAR_G(openssl_privatekey_len));
@@ -2140,15 +2139,30 @@ int phar_create_signature(phar_archive_data *phar, php_stream *fp, char
**signat
return FAILURE;
}
+ md_ctx = EVP_MD_CTX_create();
+
siglen = EVP_PKEY_size(key);
sigbuf = emalloc(siglen + 1);
- EVP_SignInit(&md_ctx, mdtype);
+
+ if (!EVP_SignInit(md_ctx, EVP_sha1())) {
+ efree(sigbuf);
+ if (error) {
+ spprintf(error, 0, "unable to initialize openssl signature for phar
\"%s\"", phar->fname);
+ }
+ return FAILURE;
+ }
while ((sig_len = php_stream_read(fp, (char*)buf, sizeof(buf))) > 0) {
- EVP_SignUpdate(&md_ctx, buf, sig_len);
+ if (!EVP_SignUpdate(md_ctx, buf, sig_len)) {
+ efree(sigbuf);
+ if (error) {
+ spprintf(error, 0, "unable to update the openssl signature for phar
\"%s\"", phar->fname);
+ }
+ return FAILURE;
+ }
}
- if (!EVP_SignFinal (&md_ctx, sigbuf,(unsigned int *)&siglen, key)) {
+ if (!EVP_SignFinal (md_ctx, sigbuf,(unsigned int *)&siglen, key)) {
efree(sigbuf);
if (error) {
spprintf(error, 0, "unable to write phar \"%s\" with requested openssl
signature", phar->fname);
@@ -2157,7 +2171,7 @@ int phar_create_signature(phar_archive_data *phar, php_stream *fp, char
**signat
}
sigbuf[siglen] = '\0';
- EVP_MD_CTX_cleanup(&md_ctx);
+ EVP_MD_CTX_destroy(md_ctx);
#else
sigbuf = NULL;
siglen = 0;