[php-src] master: Fix potential NULL pointer dereference before calling EVP_SignInit
| From: | icy17 via Niels Dossche | Date: | Mon, 08 Apr 2024 17:31:21 +0000 |
| Subject: | [php-src] master: Fix potential NULL pointer dereference before calling EVP_SignInit | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-127985@lists.php.net to get a copy of this message | ||
Author: icy17 (icy17)
Committer: Niels Dossche (nielsdos)
Date: 2024-04-08T19:30:26+02:00
Commit: https://github.com/php/php-src/commit/6f8bda0582087fa04666dd1e9f460fc72a3cc306
Raw diff: https://github.com/php/php-src/commit/6f8bda0582087fa04666dd1e9f460fc72a3cc306.diff
Fix potential NULL pointer dereference before calling EVP_SignInit
Closes GH-13870.
Changed paths:
M NEWS
M ext/phar/util.c
Diff:
diff --git a/NEWS b/NEWS
index 87b5472d850d9..47b3f5efb3a58 100644
--- a/NEWS
+++ b/NEWS
@@ -22,6 +22,7 @@ PHP NEWS
filename causes a NULL pointer dereference). (nielsdos)
. Fixed bug GH-13833 (Applying zero offset to null pointer in zend_hash.c).
(nielsdos)
+ . Fix potential NULL pointer dereference before calling EVP_SignInit. (icy17)
- PHPDBG:
. Fixed bug GH-13827 (Null pointer access of type 'zval' in phpdbg_frame).
diff --git a/ext/phar/util.c b/ext/phar/util.c
index 003d579bb9a5e..352819bc9348b 100644
--- a/ext/phar/util.c
+++ b/ext/phar/util.c
@@ -1884,6 +1884,13 @@ int phar_create_signature(phar_archive_data *phar, php_stream *fp, char
**signat
}
md_ctx = EVP_MD_CTX_create();
+ if (md_ctx == NULL) {
+ EVP_PKEY_free(key);
+ if (error) {
+ spprintf(error, 0, "unable to initialize openssl signature for phar
\"%s\"", phar->fname);
+ }
+ return FAILURE;
+ }
siglen = EVP_PKEY_size(key);
sigbuf = emalloc(siglen + 1);