From 4348b08f56cfc0a11020c995e08688e1c9dc26fd Mon Sep 17 00:00:00 2001 From: Rimvydas Zilinskas Date: Sat, 10 Aug 2019 18:16:13 +0100 Subject: [PATCH 1/2] Add openssl stubs --- ext/openssl/openssl.c | 49 +---------------------------------- ext/openssl/openssl.stub.php | 24 +++++++++++++++++ ext/openssl/openssl_arginfo.h | 49 +++++++++++++++++++++++++++++++++++ 3 files changed, 74 insertions(+), 48 deletions(-) create mode 100644 ext/openssl/openssl.stub.php create mode 100644 ext/openssl/openssl_arginfo.h diff --git a/ext/openssl/openssl.c b/ext/openssl/openssl.c index 5e9528afd55fe..caff996573a5b 100644 --- a/ext/openssl/openssl.c +++ b/ext/openssl/openssl.c @@ -27,6 +27,7 @@ #include "php.h" #include "php_ini.h" +#include "openssl_arginfo.h" #include "php_openssl.h" #include "zend_exceptions.h" @@ -131,54 +132,6 @@ PHP_FUNCTION(openssl_pkey_derive); PHP_FUNCTION(openssl_random_pseudo_bytes); /* {{{ arginfo */ -ZEND_BEGIN_ARG_INFO_EX(arginfo_openssl_x509_export_to_file, 0, 0, 2) - ZEND_ARG_INFO(0, x509) - ZEND_ARG_INFO(0, outfilename) - ZEND_ARG_INFO(0, notext) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_openssl_x509_export, 0, 0, 2) - ZEND_ARG_INFO(0, x509) - ZEND_ARG_INFO(1, out) - ZEND_ARG_INFO(0, notext) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_openssl_x509_fingerprint, 0, 0, 1) - ZEND_ARG_INFO(0, x509) - ZEND_ARG_INFO(0, method) - ZEND_ARG_INFO(0, raw_output) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO(arginfo_openssl_x509_check_private_key, 0) - ZEND_ARG_INFO(0, cert) - ZEND_ARG_INFO(0, key) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO(arginfo_openssl_x509_verify, 0) - ZEND_ARG_INFO(0, cert) - ZEND_ARG_INFO(0, key) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_openssl_x509_parse, 0, 0, 1) - ZEND_ARG_INFO(0, x509) - ZEND_ARG_INFO(0, shortname) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_openssl_x509_checkpurpose, 0, 0, 2) - ZEND_ARG_INFO(0, x509cert) - ZEND_ARG_INFO(0, purpose) - ZEND_ARG_INFO(0, cainfo) /* array */ - ZEND_ARG_INFO(0, untrustedfile) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO(arginfo_openssl_x509_read, 0) - ZEND_ARG_INFO(0, cert) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO(arginfo_openssl_x509_free, 0) - ZEND_ARG_INFO(0, x509) -ZEND_END_ARG_INFO() - ZEND_BEGIN_ARG_INFO_EX(arginfo_openssl_pkcs12_export_to_file, 0, 0, 4) ZEND_ARG_INFO(0, x509) ZEND_ARG_INFO(0, filename) diff --git a/ext/openssl/openssl.stub.php b/ext/openssl/openssl.stub.php new file mode 100644 index 0000000000000..b6278ae8aa9b8 --- /dev/null +++ b/ext/openssl/openssl.stub.php @@ -0,0 +1,24 @@ + Date: Sat, 10 Aug 2019 20:52:55 +0100 Subject: [PATCH 2/2] Updated based on feedback --- ext/openssl/openssl.stub.php | 8 ++++---- ext/openssl/openssl_arginfo.h | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/ext/openssl/openssl.stub.php b/ext/openssl/openssl.stub.php index b6278ae8aa9b8..23acc5f47c85f 100644 --- a/ext/openssl/openssl.stub.php +++ b/ext/openssl/openssl.stub.php @@ -2,23 +2,23 @@ function openssl_x509_export_to_file($x509, string $outfilename, bool $notext = true): bool {} -function openssl_x509_export($x509 , string &$out, bool $notext = true): bool {} +function openssl_x509_export($x509 , &$out, bool $notext = true): bool {} /** @return string|false */ function openssl_x509_fingerprint($x509, string $method = 'sha1', bool $raw_output = false) {} function openssl_x509_check_private_key($cert, $key): bool {} -function openssl_x509_verify($cert, $key) {} +function openssl_x509_verify($cert, $key): int {} /** @return array|false */ function openssl_x509_parse($x509, bool $shortname = true) {} /** @return bool|int */ -function openssl_x509_checkpurpose($x509cert, int $purpose, array $cainfo, string $untrustedfile) {} +function openssl_x509_checkpurpose($x509cert, int $purpose, ?array $cainfo = [], string $untrustedfile = UNKNOWN) {} /** @return resource|false */ function openssl_x509_read($cert) {} /** @return false|void */ -function openssl_x509_free($x509){} +function openssl_x509_free($x509) {} diff --git a/ext/openssl/openssl_arginfo.h b/ext/openssl/openssl_arginfo.h index ac0335395dc73..ed104a2ffaea7 100644 --- a/ext/openssl/openssl_arginfo.h +++ b/ext/openssl/openssl_arginfo.h @@ -8,7 +8,7 @@ ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_openssl_x509_export, 0, 2, _IS_BOOL, 0) ZEND_ARG_INFO(0, x509) - ZEND_ARG_TYPE_INFO(1, out, IS_STRING, 0) + ZEND_ARG_INFO(1, out) ZEND_ARG_TYPE_INFO(0, notext, _IS_BOOL, 0) ZEND_END_ARG_INFO() @@ -23,7 +23,7 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_openssl_x509_check_private_key, ZEND_ARG_INFO(0, key) ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_INFO_EX(arginfo_openssl_x509_verify, 0, 0, 2) +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_openssl_x509_verify, 0, 2, IS_LONG, 0) ZEND_ARG_INFO(0, cert) ZEND_ARG_INFO(0, key) ZEND_END_ARG_INFO() @@ -33,10 +33,10 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_openssl_x509_parse, 0, 0, 1) ZEND_ARG_TYPE_INFO(0, shortname, _IS_BOOL, 0) ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_INFO_EX(arginfo_openssl_x509_checkpurpose, 0, 0, 4) +ZEND_BEGIN_ARG_INFO_EX(arginfo_openssl_x509_checkpurpose, 0, 0, 2) ZEND_ARG_INFO(0, x509cert) ZEND_ARG_TYPE_INFO(0, purpose, IS_LONG, 0) - ZEND_ARG_TYPE_INFO(0, cainfo, IS_ARRAY, 0) + ZEND_ARG_TYPE_INFO(0, cainfo, IS_ARRAY, 1) ZEND_ARG_TYPE_INFO(0, untrustedfile, IS_STRING, 0) ZEND_END_ARG_INFO()