]> granicus.if.org Git - php/commitdiff
MFB: fix bug #45907: undefined reference to PHP_SHA512Init
authorGreg Beaver <cellog@php.net>
Thu, 9 Oct 2008 00:51:27 +0000 (00:51 +0000)
committerGreg Beaver <cellog@php.net>
Thu, 9 Oct 2008 00:51:27 +0000 (00:51 +0000)
ext/phar/config.m4
ext/phar/phar.c
ext/phar/phar_internal.h
ext/phar/phar_object.c
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/util.c

index 831c397f50f11e0113850d682326c15800ca258c..fe8734281f64cced196a08b06d5b561a24d795ad 100644 (file)
@@ -7,6 +7,11 @@ PHP_ARG_ENABLE(phar, for phar archive support,
 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)
   AC_MSG_CHECKING([for phar openssl support])
+  if test "$PHP_HASH_SHARED" != "yes"; then
+    AC_DEFINE(PHAR_HASH_OK,1,[ ])
+  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 7ae4af4f265ed19e6cc78ddb82423aa1d8183093..ec608a84d3873d076f241503f5815f3d30abdd38 100644 (file)
@@ -838,7 +838,7 @@ static int phar_parse_pharfile(php_stream *fp, char *fname, int fname_len, char
                                efree(sig);
                        }
                        break;
-#if HAVE_HASH_EXT
+#if PHAR_HASH_OK
                        case PHAR_SIG_SHA512: {
                                unsigned char digest[64];
 
@@ -3108,7 +3108,7 @@ int phar_flush(phar_archive_data *phar, char *user_stub, long len, int convert,
                }
 
                switch(phar->sig_flags) {
-#ifndef HAVE_HASH_EXT
+#ifndef PHAR_HASH_OK
                        case PHAR_SIG_SHA512:
                        case PHAR_SIG_SHA256:
                                if (closeoldfile) {
index ed042e97465b7b6fde708bf1dd43b89abbee0e8d..7e0a59c43be1639682b5dffe044b2ab468ce5ecc 100755 (executable)
@@ -66,7 +66,7 @@
 #ifdef HAVE_STDINT_H
 #include <stdint.h>
 #endif
-#ifdef HAVE_HASH_EXT
+#ifdef PHAR_HASH_OK
 #include "ext/hash/php_hash.h"
 #include "ext/hash/php_hash_sha.h"
 #endif
index 2d9d028426f0bf9956e71c162964e150e91ca60a..440017bd89e6d093be7d8a631a3ee10a3b818640 100755 (executable)
@@ -1271,7 +1271,7 @@ PHP_METHOD(Phar, getSupportedSignatures)
 
        add_next_index_stringl(return_value, "MD5", 3, 1);
        add_next_index_stringl(return_value, "SHA-1", 5, 1);
-#ifdef HAVE_HASH_EXT
+#ifdef PHAR_HASH_OK
        add_next_index_stringl(return_value, "SHA-256", 7, 1);
        add_next_index_stringl(return_value, "SHA-512", 7, 1);
 #endif
@@ -2939,9 +2939,9 @@ PHP_METHOD(Phar, setSignatureAlgorithm)
        switch (algo) {
                case PHAR_SIG_SHA256:
                case PHAR_SIG_SHA512:
-#ifndef HAVE_HASH_EXT
+#ifndef PHAR_HASH_OK
                        zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC,
-                               "SHA-256 and SHA-512 signatures are only supported if the hash extension is enabled");
+                               "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:
index ce907ff6388056abc79172ca56f1eec3e68d7576..154d1806c6b62c70592666ea3240e01f633f781e 100644 (file)
@@ -6,6 +6,7 @@ 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");
 ?>
 --INI--
 phar.require_hash=0
index e3f858d5d626224ac629fe02fc7172e6ce7420b5..66edb61222e35388520ce1981cab1ff0685b3a29 100644 (file)
@@ -4,7 +4,9 @@ Phar::setSupportedSignatures() with hash
 <?php
 if (!extension_loaded("phar")) die("skip");
 if (!extension_loaded("hash")) die("skip hash extension required");
-if (!extension_loaded("openssl")) die("skip openssl 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");
 ?>
 --INI--
 phar.require_hash=0
index e9cbdb4a5d1f94f51f2ad7ad0c03c52c2746cff0..422ca90e8af16e8e8f97367793e8e51db9f67dd4 100644 (file)
@@ -2,8 +2,10 @@
 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 if (!extension_loaded("openssl")) die("skip extension openssl required"); ?>
+<?php 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"); ?>
 --INI--
 phar.require_hash=0
 phar.readonly=0
index 2ef7ca109fb2b600f640d02f41a06e0d43ec95f5..7cbf6c05137d33a410f38fdc3522925e9391729b 100644 (file)
@@ -6,6 +6,7 @@ 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");
 ?>
 --INI--
 phar.require_hash=0
index 0701cb88030997c2d29f109c3c3f2ed42775df48..7e9c50ac643a4305e087622faf4c7da09b212d4b 100644 (file)
@@ -1875,7 +1875,7 @@ int phar_verify_signature(php_stream *fp, size_t end_of_phar, php_uint32 sig_typ
                        *signature_len = phar_hex_str((const char*)sig, sig_len, signature TSRMLS_CC);
                }
                break;
-#ifdef HAVE_HASH_EXT
+#ifdef PHAR_HASH_OK
                case PHAR_SIG_SHA512: {
                        unsigned char digest[64];
                        PHP_SHA512_CTX context;
@@ -2039,7 +2039,7 @@ int phar_create_signature(phar_archive_data *phar, php_stream *fp, char **signat
        }
 
        switch(phar->sig_flags) {
-#ifdef HAVE_HASH_EXT
+#ifdef PHAR_HASH_OK
                case PHAR_SIG_SHA512: {
                        unsigned char digest[64];
                        PHP_SHA512_CTX context;