diff options
-rw-r--r-- | ext/openssl/openssl.c | 2 | ||||
-rw-r--r-- | ext/openssl/tests/bug68912.phpt | 20 |
2 files changed, 21 insertions, 1 deletions
diff --git a/ext/openssl/openssl.c b/ext/openssl/openssl.c index 5a0d4687de..98904cc38e 100644 --- a/ext/openssl/openssl.c +++ b/ext/openssl/openssl.c @@ -1545,7 +1545,7 @@ cleanup: efree(spkstr); } - if (s->len <= 0) { + if (s && s->len <= 0) { RETVAL_FALSE; } diff --git a/ext/openssl/tests/bug68912.phpt b/ext/openssl/tests/bug68912.phpt new file mode 100644 index 0000000000..7d763db8e9 --- /dev/null +++ b/ext/openssl/tests/bug68912.phpt @@ -0,0 +1,20 @@ +--TEST-- +Bug #68912 (Segmentation fault at openssl_spki_new) +--SKIPIF-- +<?php +if (!extension_loaded("openssl")) die("skip"); +if (!@openssl_pkey_new()) die("skip cannot create private key"); +?> +--FILE-- +<?php + +$var1=xml_parser_create_ns(); +$var2=2; +$var3=3; + +openssl_spki_new($var1, $var2, $var3); +?> +--EXPECTF-- +Warning: openssl_spki_new(): supplied resource is not a valid OpenSSL X.509/key resource in %sbug68912.php on line %d + +Warning: openssl_spki_new(): Unable to use supplied private key in %sbug68912.php on line %d |