]> granicus.if.org Git - php/commitdiff
Sync HAVE_HASH, HAVE_HASH_EXT, PHAR_HASH_OK symbols
authorPeter Kokot <peterkokot@gmail.com>
Wed, 26 Jun 2019 01:01:45 +0000 (03:01 +0200)
committerPeter Kokot <peterkokot@gmail.com>
Thu, 27 Jun 2019 21:25:33 +0000 (23:25 +0200)
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.

20 files changed:
ext/hash/config.m4
ext/hash/config.w32
ext/hash/hash.c
ext/hash/tests/new-context.phpt
ext/hash/tests/reuse.phpt
ext/phar/config.m4
ext/phar/config.w32
ext/phar/phar.c
ext/phar/phar_internal.h
ext/phar/phar_object.c
ext/phar/tests/phar_get_supported_signatures_002.phpt
ext/phar/tests/phar_get_supported_signatures_002a.phpt
ext/phar/tests/phar_setsignaturealgo2.phpt
ext/phar/tests/tar/phar_setsignaturealgo2.phpt
ext/phar/tests/test_signaturealgos.phpt
ext/phar/tests/zip/phar_setsignaturealgo2.phpt
ext/phar/util.c
ext/session/php_session.h
ext/session/tests/031.phpt
main/internal_functions_win32.c

index 91c5241b00755de0cd4d89daad6c356989cdc877..0fa45265013d42326ec14e972b6190a11298e0a5 100644 (file)
@@ -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
index bb3b33995264b277867f6e34c5c3041a152ba8c2..3ed785bfdaaa972b36c62bd44295dd405e984792 100644 (file)
@@ -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';
index 449665a2685bb9c1bb3830fc0952b8dbee1850e6..636e0be4c70d5243f74f4fd3b5466a5051b81eba 100644 (file)
@@ -1488,7 +1488,3 @@ zend_module_entry hash_module_entry = {
        STANDARD_MODULE_PROPERTIES
 };
 /* }}} */
-
-#ifdef COMPILE_DL_HASH
-ZEND_GET_MODULE(hash)
-#endif
index b8ada08357c5de3208d94e7ce7affa1014f808fa..d53ff066422b3a03d0a676b3089264bc7b7b1c94 100644 (file)
@@ -1,7 +1,5 @@
 --TEST--
 Hash: Attempt to instantiate a HashContext directly
---SKIPIF--
-<?php if (!extension_loaded('hash')) echo 'skip';
 --FILE--
 <?php
 
index 2955aac2c8a0b3fa53e2ff5ca8e7f2d4bca6966b..cd1419fd555ebb1d54a10725459e72bd2046ee08 100644 (file)
@@ -1,7 +1,5 @@
 --TEST--
 Hash: Attempt to reuse a closed hash context
---SKIPIF--
-<?php if (!extension_loaded('hash')) echo 'skip';
 --FILE--
 <?php
 
index 23e7f58c625c51b8e3232d4b79f67eb6dec22a8e..257d961faf51c37b000e3991db6d363128503f3e 100644 (file)
@@ -7,13 +7,6 @@ PHP_ARG_ENABLE([phar],
 if test "$PHP_PHAR" != "no"; then
   PHP_NEW_EXTENSION(phar, util.c tar.c zip.c stream.c func_interceptors.c dirstream.c phar.c phar_object.c phar_path_check.c, $ext_shared,, -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1)
   AC_MSG_CHECKING([for phar openssl support])
-  if test "$PHP_HASH_SHARED" != "yes"; then
-    if test "$PHP_HASH" != "no"; then
-      AC_DEFINE(PHAR_HASH_OK,1,[ ])
-    fi
-  else
-    AC_MSG_WARN([Phar: sha256/sha512 signature support disabled if ext/hash is built shared])
-  fi
   if test "$PHP_OPENSSL_SHARED" = "yes"; then
     AC_MSG_RESULT([no (shared openssl)])
   else
index e45e1af95463ed252cc5c7b4ffe2c9fabc73a9b0..c68ba08f2ca2b49fab37561bb55cd02cfc193da6 100644 (file)
@@ -34,13 +34,6 @@ if (PHP_PHAR != "no") {
                        STDOUT.WriteLine('        Native OpenSSL support in Phar disabled');
                }
        }
-       if (PHP_HASH != "no") {
-               if (!PHP_HASH_SHARED) {
-                       AC_DEFINE("PHAR_HASH_OK", 1);
-               } else {
-                       WARNING('Phar: sha256/sha512 signature support disabled if ext/hash is built shared');
-               }
-       }
        ADD_EXTENSION_DEP('phar', 'spl', true);
 
        ADD_MAKEFILE_FRAGMENT();
index cc949a6b6176422bc27c6b12c09fdec1b62552cb..3ff33d0697b4892889118e6634c95c51f237e6ef 100644 (file)
@@ -842,7 +842,6 @@ static int phar_parse_pharfile(php_stream *fp, char *fname, size_t fname_len, ch
                                efree(sig);
                        }
                        break;
-#if PHAR_HASH_OK
                        case PHAR_SIG_SHA512: {
                                unsigned char digest[64];
 
@@ -897,17 +896,6 @@ static int phar_parse_pharfile(php_stream *fp, char *fname, size_t fname_len, ch
                                }
                                break;
                        }
-#else
-                       case PHAR_SIG_SHA512:
-                       case PHAR_SIG_SHA256:
-                               efree(savebuf);
-                               php_stream_close(fp);
-
-                               if (error) {
-                                       spprintf(error, 0, "phar \"%s\" has a unsupported signature", fname);
-                               }
-                               return FAILURE;
-#endif
                        case PHAR_SIG_SHA1: {
                                unsigned char digest[20];
 
@@ -3122,18 +3110,6 @@ int phar_flush(phar_archive_data *phar, char *user_stub, zend_long len, int conv
                }
 
                switch(phar->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
 };
index 10be6d4d9538f50f33f25768006c3860d0c5286c..8b2f585161e29f612068bb024e8819c88f6bf1d2 100644 (file)
 #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"
index 72c7c4a535e8e609a7f0866628d12f01777a966a..cc53d94106c05a81842c4d2b8b4916bcbd6f5e15 100644 (file)
@@ -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:
index 3c5cf7f0f48763be3197cde7ff23d55b73a0ff7d..7e17aedca55a1afea7fa440cebc770db0d4b066a 100644 (file)
@@ -3,7 +3,6 @@ Phar::getSupportedSignatures()
 --SKIPIF--
 <?php
 if (!extension_loaded("phar")) die("skip");
-if (!extension_loaded("hash")) die("skip extension hash required");
 $arr = Phar::getSupportedSignatures();
 if (in_array("OpenSSL", $arr)) die("skip openssl support enabled");
 if (!in_array('SHA-256', $arr)) die("skip hash extension loaded shared");
index 32437a30a181d5c4966aa10e53407548de1f9ccb..7260607a1458b8fd54d0c1b2571e2accee737730 100644 (file)
@@ -3,7 +3,6 @@ Phar::getSupportedSignatures()
 --SKIPIF--
 <?php
 if (!extension_loaded("phar")) die("skip");
-if (!extension_loaded("hash")) die("skip extension hash required");
 $arr = Phar::getSupportedSignatures();
 if (!in_array("OpenSSL", $arr)) die("skip openssl support required");
 if (!in_array('SHA-256', $arr)) die("skip hash extension loaded shared");
index 80aa5311386c1864a95a99ffaddcc615c5c8e577..92b7b2dcf132cf151b12493c473cf4a6705d14cc 100644 (file)
@@ -3,7 +3,6 @@ Phar::setSupportedSignatures() with hash
 --SKIPIF--
 <?php
 if (!extension_loaded("phar")) die("skip");
-if (!extension_loaded("hash")) die("skip hash extension required");
 $arr = Phar::getSupportedSignatures();
 if (!in_array("OpenSSL", $arr)) die("skip openssl support required");
 if (!in_array('SHA-256', $arr)) die("skip hash extension loaded shared");
index 4fb558bd7205d1f7bc5294e965d7ae7cb1fb7cac..d854455df9b8ad8fd0d81a9b359b11c8d049d967 100644 (file)
@@ -2,7 +2,7 @@
 Phar::setSupportedSignatures() with hash, tar-based
 --SKIPIF--
 <?php if (!extension_loaded("phar")) die("skip"); ?>
-<?php if (!extension_loaded("hash")) die("skip extension hash required");
+<?php
 $arr = Phar::getSupportedSignatures();
 if (!in_array("OpenSSL", $arr)) die("skip openssl support required");
 if (!in_array('SHA-256', $arr)) die("skip hash extension loaded shared"); ?>
index e60554bd0c4b37271f7f2ae8277290c948a6f7a3..f94a02924efedf577596febeb0f33961c3a90ce1 100644 (file)
@@ -3,7 +3,6 @@ Phar: verify signature parsing works
 --SKIPIF--
 <?php
 if (!extension_loaded("phar")) die("skip");
-if (!extension_loaded("hash")) die("skip extension hash conflicts");
 $arr = Phar::getSupportedSignatures();
 if (!in_array("OpenSSL", $arr)) die("skip openssl support required");
 if (!in_array('SHA-256', $arr)) die("skip hash extension loaded shared");
index c3a5955c3f0a036b55344858a7cced111dae12c9..6ecceb98521541b66794e89c34237763d4766ba8 100644 (file)
@@ -2,7 +2,7 @@
 Phar::setSupportedSignatures() with hash, zip-based
 --SKIPIF--
 <?php if (!extension_loaded("phar")) die("skip"); ?>
-<?php if (!extension_loaded("hash")) die("skip extension hash required");
+<?php
 $arr = Phar::getSupportedSignatures();
 if (!in_array("OpenSSL", $arr)) die("skip openssl support required");
 if (!in_array('SHA-256', $arr)) die("skip hash extension loaded shared"); ?>
index ab5d3355ad358c809c3f142213dd6e12a0f700ba..59a6cd7c88abab990811265b357f86c5b71c23f2 100644 (file)
@@ -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
index 854110d8bc3779fec0b5a1d8c34a3e43306344ea..4c795fdb68a3d7f35c09e35b92951ef7d2254190 100644 (file)
 #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
 
index 7486c4b866ee5a7bf657676548a9b4f76553e933..e8deb3dac5d0e5af139c763c3105898fa373a55f 100644 (file)
@@ -2,7 +2,6 @@
 setting hash_function to sha512 and hash_bits_per_character > 4 should not crash
 --SKIPIF--
 <?php include('skipif.inc'); ?>
-<?php if (!extension_loaded('hash')) die('skip hash extension not available'); ?>
 --INI--
 session.use_cookies=0
 session.cache_limiter=
index 88e056f5d8a2cc8eca8ae9d946eb431207289c36..4a3301e49b6c40b91722c7341abdbbe2cf0678d6 100644 (file)
@@ -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