Skip to content

Commit 6f8bda0

Browse files
icy17nielsdos
authored andcommitted
Fix potential NULL pointer dereference before calling EVP_SignInit
Closes phpGH-13870.
1 parent af098ac commit 6f8bda0

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

NEWS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ PHP NEWS
2222
filename causes a NULL pointer dereference). (nielsdos)
2323
. Fixed bug GH-13833 (Applying zero offset to null pointer in zend_hash.c).
2424
(nielsdos)
25+
. Fix potential NULL pointer dereference before calling EVP_SignInit. (icy17)
2526

2627
- PHPDBG:
2728
. Fixed bug GH-13827 (Null pointer access of type 'zval' in phpdbg_frame).

ext/phar/util.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1884,6 +1884,13 @@ int phar_create_signature(phar_archive_data *phar, php_stream *fp, char **signat
18841884
}
18851885

18861886
md_ctx = EVP_MD_CTX_create();
1887+
if (md_ctx == NULL) {
1888+
EVP_PKEY_free(key);
1889+
if (error) {
1890+
spprintf(error, 0, "unable to initialize openssl signature for phar \"%s\"", phar->fname);
1891+
}
1892+
return FAILURE;
1893+
}
18871894

18881895
siglen = EVP_PKEY_size(key);
18891896
sigbuf = emalloc(siglen + 1);

0 commit comments

Comments
 (0)