From: Greg Beaver Date: Thu, 9 Oct 2008 00:51:27 +0000 (+0000) Subject: MFB: fix bug #45907: undefined reference to PHP_SHA512Init X-Git-Tag: BEFORE_HEAD_NS_CHANGE~267 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a4f39f7fa4227b4982f3e42e1fb189f5058b6271;p=php MFB: fix bug #45907: undefined reference to PHP_SHA512Init --- diff --git a/ext/phar/config.m4 b/ext/phar/config.m4 index 831c397f50..fe8734281f 100644 --- a/ext/phar/config.m4 +++ b/ext/phar/config.m4 @@ -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 diff --git a/ext/phar/phar.c b/ext/phar/phar.c index 7ae4af4f26..ec608a84d3 100644 --- a/ext/phar/phar.c +++ b/ext/phar/phar.c @@ -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) { diff --git a/ext/phar/phar_internal.h b/ext/phar/phar_internal.h index ed042e9746..7e0a59c43b 100755 --- a/ext/phar/phar_internal.h +++ b/ext/phar/phar_internal.h @@ -66,7 +66,7 @@ #ifdef HAVE_STDINT_H #include #endif -#ifdef HAVE_HASH_EXT +#ifdef PHAR_HASH_OK #include "ext/hash/php_hash.h" #include "ext/hash/php_hash_sha.h" #endif diff --git a/ext/phar/phar_object.c b/ext/phar/phar_object.c index 2d9d028426..440017bd89 100755 --- a/ext/phar/phar_object.c +++ b/ext/phar/phar_object.c @@ -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: diff --git a/ext/phar/tests/phar_get_supported_signatures_002a.phpt b/ext/phar/tests/phar_get_supported_signatures_002a.phpt index ce907ff638..154d1806c6 100644 --- a/ext/phar/tests/phar_get_supported_signatures_002a.phpt +++ b/ext/phar/tests/phar_get_supported_signatures_002a.phpt @@ -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 diff --git a/ext/phar/tests/phar_setsignaturealgo2.phpt b/ext/phar/tests/phar_setsignaturealgo2.phpt index e3f858d5d6..66edb61222 100644 --- a/ext/phar/tests/phar_setsignaturealgo2.phpt +++ b/ext/phar/tests/phar_setsignaturealgo2.phpt @@ -4,7 +4,9 @@ Phar::setSupportedSignatures() with hash --INI-- phar.require_hash=0 diff --git a/ext/phar/tests/tar/phar_setsignaturealgo2.phpt b/ext/phar/tests/tar/phar_setsignaturealgo2.phpt index e9cbdb4a5d..422ca90e8a 100644 --- a/ext/phar/tests/tar/phar_setsignaturealgo2.phpt +++ b/ext/phar/tests/tar/phar_setsignaturealgo2.phpt @@ -2,8 +2,10 @@ Phar::setSupportedSignatures() with hash, tar-based --SKIPIF-- - - + --INI-- phar.require_hash=0 phar.readonly=0 diff --git a/ext/phar/tests/test_signaturealgos.phpt b/ext/phar/tests/test_signaturealgos.phpt index 2ef7ca109f..7cbf6c0513 100644 --- a/ext/phar/tests/test_signaturealgos.phpt +++ b/ext/phar/tests/test_signaturealgos.phpt @@ -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 diff --git a/ext/phar/util.c b/ext/phar/util.c index 0701cb8803..7e9c50ac64 100644 --- a/ext/phar/util.c +++ b/ext/phar/util.c @@ -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;