From: Peter Kokot Date: Wed, 26 Jun 2019 01:01:45 +0000 (+0200) Subject: Sync HAVE_HASH, HAVE_HASH_EXT, PHAR_HASH_OK symbols X-Git-Tag: php-7.4.0alpha3~156 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=033cafacbd8b184260c91a74ea7956b302857706;p=php Sync HAVE_HASH, HAVE_HASH_EXT, PHAR_HASH_OK symbols The hash extension is always available since PHP-7.4. The symbol HAVE_HASH_EXT is kept for BC reasons and removed in PHP-8.0. This patch also removes the PHAR_HASH_OK since it is no longer relevant. --- diff --git a/ext/hash/config.m4 b/ext/hash/config.m4 index 91c5241b00..0fa4526501 100644 --- a/ext/hash/config.m4 +++ b/ext/hash/config.m4 @@ -11,6 +11,7 @@ if test "$PHP_MHASH" != "no"; then AC_DEFINE(PHP_MHASH_BC, 1, [ ]) fi +dnl Defined for BC. AC_DEFINE(HAVE_HASH_EXT,1,[Have HASH Extension]) if test $ac_cv_c_bigendian_php = yes; then diff --git a/ext/hash/config.w32 b/ext/hash/config.w32 index bb3b339952..3ed785bfda 100644 --- a/ext/hash/config.w32 +++ b/ext/hash/config.w32 @@ -6,6 +6,7 @@ if (PHP_MHASH != 'no') { AC_DEFINE('PHP_MHASH_BC', 1); } +// Defined for BC. AC_DEFINE('HAVE_HASH_EXT', 1); PHP_HASH = 'yes'; diff --git a/ext/hash/hash.c b/ext/hash/hash.c index 449665a268..636e0be4c7 100644 --- a/ext/hash/hash.c +++ b/ext/hash/hash.c @@ -1488,7 +1488,3 @@ zend_module_entry hash_module_entry = { STANDARD_MODULE_PROPERTIES }; /* }}} */ - -#ifdef COMPILE_DL_HASH -ZEND_GET_MODULE(hash) -#endif diff --git a/ext/hash/tests/new-context.phpt b/ext/hash/tests/new-context.phpt index b8ada08357..d53ff06642 100644 --- a/ext/hash/tests/new-context.phpt +++ b/ext/hash/tests/new-context.phpt @@ -1,7 +1,5 @@ --TEST-- Hash: Attempt to instantiate a HashContext directly ---SKIPIF-- -sig_flags) { -#ifndef PHAR_HASH_OK - case PHAR_SIG_SHA512: - case PHAR_SIG_SHA256: - if (closeoldfile) { - php_stream_close(oldfile); - } - php_stream_close(newfile); - if (error) { - spprintf(error, 0, "unable to write contents of file \"%s\" to new phar \"%s\" with requested hash type", entry->filename, phar->fname); - } - return EOF; -#endif default: { char *digest = NULL; size_t digest_len; @@ -3624,9 +3600,7 @@ static const zend_module_dep phar_deps[] = { ZEND_MOD_OPTIONAL("openssl") ZEND_MOD_OPTIONAL("zlib") ZEND_MOD_OPTIONAL("standard") -#if defined(HAVE_HASH) && !defined(COMPILE_DL_HASH) ZEND_MOD_REQUIRED("hash") -#endif ZEND_MOD_REQUIRED("spl") ZEND_MOD_END }; diff --git a/ext/phar/phar_internal.h b/ext/phar/phar_internal.h index 10be6d4d95..8b2f585161 100644 --- a/ext/phar/phar_internal.h +++ b/ext/phar/phar_internal.h @@ -59,10 +59,8 @@ #include "ext/spl/spl_exceptions.h" #include "ext/spl/spl_iterators.h" #include "php_phar.h" -#ifdef PHAR_HASH_OK #include "ext/hash/php_hash.h" #include "ext/hash/php_hash_sha.h" -#endif /* PHP_ because this is public information via MINFO */ #define PHP_PHAR_API_VERSION "1.1.1" diff --git a/ext/phar/phar_object.c b/ext/phar/phar_object.c index 72c7c4a535..cc53d94106 100644 --- a/ext/phar/phar_object.c +++ b/ext/phar/phar_object.c @@ -1275,10 +1275,8 @@ PHP_METHOD(Phar, getSupportedSignatures) add_next_index_stringl(return_value, "MD5", 3); add_next_index_stringl(return_value, "SHA-1", 5); -#ifdef PHAR_HASH_OK add_next_index_stringl(return_value, "SHA-256", 7); add_next_index_stringl(return_value, "SHA-512", 7); -#endif #if PHAR_HAVE_OPENSSL add_next_index_stringl(return_value, "OpenSSL", 7); #else @@ -3061,11 +3059,6 @@ PHP_METHOD(Phar, setSignatureAlgorithm) switch (algo) { case PHAR_SIG_SHA256: case PHAR_SIG_SHA512: -#ifndef PHAR_HASH_OK - zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0, - "SHA-256 and SHA-512 signatures are only supported if the hash extension is enabled and built non-shared"); - return; -#endif case PHAR_SIG_MD5: case PHAR_SIG_SHA1: case PHAR_SIG_OPENSSL: diff --git a/ext/phar/tests/phar_get_supported_signatures_002.phpt b/ext/phar/tests/phar_get_supported_signatures_002.phpt index 3c5cf7f0f4..7e17aedca5 100644 --- a/ext/phar/tests/phar_get_supported_signatures_002.phpt +++ b/ext/phar/tests/phar_get_supported_signatures_002.phpt @@ -3,7 +3,6 @@ Phar::getSupportedSignatures() --SKIPIF-- - diff --git a/ext/phar/tests/test_signaturealgos.phpt b/ext/phar/tests/test_signaturealgos.phpt index e60554bd0c..f94a02924e 100644 --- a/ext/phar/tests/test_signaturealgos.phpt +++ b/ext/phar/tests/test_signaturealgos.phpt @@ -3,7 +3,6 @@ Phar: verify signature parsing works --SKIPIF-- - diff --git a/ext/phar/util.c b/ext/phar/util.c index ab5d3355ad..59a6cd7c88 100644 --- a/ext/phar/util.c +++ b/ext/phar/util.c @@ -19,9 +19,7 @@ */ #include "phar_internal.h" -#ifdef PHAR_HASH_OK #include "ext/hash/php_hash_sha.h" -#endif #ifdef PHAR_HAVE_OPENSSL /* OpenSSL includes */ @@ -1598,7 +1596,6 @@ int phar_verify_signature(php_stream *fp, size_t end_of_phar, uint32_t sig_type, *signature_len = phar_hex_str((const char*)sig, sig_len, signature); } break; -#ifdef PHAR_HASH_OK case PHAR_SIG_SHA512: { unsigned char digest[64]; PHP_SHA512_CTX context; @@ -1679,14 +1676,6 @@ int phar_verify_signature(php_stream *fp, size_t end_of_phar, uint32_t sig_type, *signature_len = phar_hex_str((const char*)digest, sizeof(digest), signature); break; } -#else - case PHAR_SIG_SHA512: - case PHAR_SIG_SHA256: - if (error) { - spprintf(error, 0, "unsupported signature"); - } - return FAILURE; -#endif case PHAR_SIG_SHA1: { unsigned char digest[20]; PHP_SHA1_CTX context; @@ -1790,7 +1779,6 @@ int phar_create_signature(phar_archive_data *phar, php_stream *fp, char **signat } switch(phar->sig_flags) { -#ifdef PHAR_HASH_OK case PHAR_SIG_SHA512: { unsigned char digest[64]; PHP_SHA512_CTX context; @@ -1821,15 +1809,6 @@ int phar_create_signature(phar_archive_data *phar, php_stream *fp, char **signat *signature_length = 32; break; } -#else - case PHAR_SIG_SHA512: - case PHAR_SIG_SHA256: - if (error) { - spprintf(error, 0, "unable to write to phar \"%s\" with requested hash type", phar->fname); - } - - return FAILURE; -#endif case PHAR_SIG_OPENSSL: { unsigned char *sigbuf; #ifdef PHAR_HAVE_OPENSSL diff --git a/ext/session/php_session.h b/ext/session/php_session.h index 854110d8bc..4c795fdb68 100644 --- a/ext/session/php_session.h +++ b/ext/session/php_session.h @@ -20,10 +20,7 @@ #define PHP_SESSION_H #include "ext/standard/php_var.h" - -#if defined(HAVE_HASH_EXT) && !defined(COMPILE_DL_HASH) -# include "ext/hash/php_hash.h" -#endif +#include "ext/hash/php_hash.h" #define PHP_SESSION_API 20161017 diff --git a/ext/session/tests/031.phpt b/ext/session/tests/031.phpt index 7486c4b866..e8deb3dac5 100644 --- a/ext/session/tests/031.phpt +++ b/ext/session/tests/031.phpt @@ -2,7 +2,6 @@ setting hash_function to sha512 and hash_bits_per_character > 4 should not crash --SKIPIF-- - --INI-- session.use_cookies=0 session.cache_limiter= diff --git a/main/internal_functions_win32.c b/main/internal_functions_win32.c index 88e056f5d8..4a3301e49b 100644 --- a/main/internal_functions_win32.c +++ b/main/internal_functions_win32.c @@ -116,9 +116,7 @@ static zend_module_entry * const php_builtin_extensions[] = { #if HAVE_FTP ,phpext_ftp_ptr #endif -#if HAVE_HASH ,phpext_hash_ptr -#endif #if HAVE_ICONV ,phpext_iconv_ptr #endif