com php-src: Merge branch 'PHP-5.6': NEWS ext/openssl/xp_ssl .c

From: Date: Wed, 04 Mar 2015 19:50:35 +0000
Subject: com php-src: Merge branch 'PHP-5.6': NEWS ext/openssl/xp_ssl .c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-85210@lists.php.net to get a copy of this message
Commit: 5de64a29e6104b2d3e1fcf9e3d8ea3ba6a87f22d Author: Daniel Lowrey <rdlowrey@php.net> Wed, 4 Mar 2015 12:50:35 -0700 Parents: 01ccfb7cc91e652a6c93ec8c62817d4ed95bbc19 241f3c34b89ab55432d5af3fd1e4217540e161a3 Branches: master Link: http://git.php.net/?p=php-src..git;a=commitdiff;h=5de64a29e6104b2d3e1fcf9e3d8ea3ba6a87f22d Log: Merge branch 'PHP-5.6' * PHP-5.6: Fixed bug #68920 (use strict peer_fingerprint input checks) Conflicts: ext/openssl/xp_ssl.c Bugs: https://bugs.php.net/68920 Changed paths: MM NEWS MM ext/openssl/xp_ssl.c Diff: diff --cc ext/openssl/xp_ssl.c index 2165091,54f0435..aac84b4 --- a/ext/openssl/xp_ssl.c +++ b/ext/openssl/xp_ssl.c @@@ -294,20 -297,42 +294,31 @@@ static zend_bool php_x509_fingerprint_m break; } - return method && php_x509_fingerprint_cmp(peer, method, Z_STRVAL_P(val) TSRMLS_CC) == 0; - + return method && php_x509_fingerprint_cmp(peer, method, Z_STRVAL_P(val)) == 0; } else if (Z_TYPE_P(val) == IS_ARRAY) { - HashPosition pos; - zval **current; - char *key; - uint key_len; - ulong key_index; + zval *current; + zend_string *key; + if (!zend_hash_num_elements(Z_ARRVAL_P(val))) { + php_error_docref(NULL, E_WARNING, "Invalid peer_fingerprint array; [algo => fingerprint] form required"); + return 0; + } + - for (zend_hash_internal_pointer_reset_ex(Z_ARRVAL_P(val), &pos); - zend_hash_get_current_data_ex(Z_ARRVAL_P(val), (void **)&current, &pos) == SUCCESS; - zend_hash_move_forward_ex(Z_ARRVAL_P(val), &pos) - ) { - int key_type = zend_hash_get_current_key_ex(Z_ARRVAL_P(val), &key, &key_len, &key_index, 0, &pos); - - if (!(key_type == HASH_KEY_IS_STRING && Z_TYPE_PP(current) == IS_STRING)) { + ZEND_HASH_FOREACH_STR_KEY_VAL(Z_ARRVAL_P(val), key, current) { - if (key && Z_TYPE_P(current) == IS_STRING - && php_x509_fingerprint_cmp(peer, key->val, Z_STRVAL_P(current)) != 0 - ) { ++ if (key == NULL || Z_TYPE_P(current) != IS_STRING) { + php_error_docref(NULL, E_WARNING, "Invalid peer_fingerprint array; [algo => fingerprint] form required"); + return 0; + } - if (php_x509_fingerprint_cmp(peer, key, Z_STRVAL_PP(current) TSRMLS_CC) != 0) { ++ if (php_x509_fingerprint_cmp(peer, key->val, Z_STRVAL_P(current)) != 0) { return 0; } - } + } ZEND_HASH_FOREACH_END(); + return 1; - + } else { - php_error_docref(NULL, E_WARNING, - "Invalid peer_fingerprint value; fingerprint string or array of the form [algo => fingerprint] required"); ++ php_error_docref(NULL, E_WARNING, "Invalid peer_fingerprint value; fingerprint string or array of the form [algo => fingerprint] required"); } + return 0; } @@@ -425,13 -449,13 +436,13 @@@ static int apply_peer_verification_poli has_cnmatch_ctx_opt = GET_VER_OPT("CN_match"); must_verify_peer_name = (has_cnmatch_ctx_opt || GET_VER_OPT("verify_peer_name")) - ? zend_is_true(*val) + ? zend_is_true(val) : sslsock->is_client; - must_verify_fingerprint = (GET_VER_OPT("peer_fingerprint") && zend_is_true(val)); + must_verify_fingerprint = GET_VER_OPT("peer_fingerprint"); if ((must_verify_peer || must_verify_peer_name || must_verify_fingerprint) && peer == NULL) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Could not get peer certificate"); + php_error_docref(NULL, E_WARNING, "Could not get peer certificate"); return FAILURE; } @@@ -460,17 -484,18 +471,18 @@@ /* If a peer_fingerprint match is required this trumps peer and peer_name verification */ if (must_verify_fingerprint) { - if (Z_TYPE_PP(val) == IS_STRING || Z_TYPE_PP(val) == IS_ARRAY) { - if (!php_x509_fingerprint_match(peer, *val TSRMLS_CC)) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, + if (Z_TYPE_P(val) == IS_STRING || Z_TYPE_P(val) == IS_ARRAY) { + if (!php_x509_fingerprint_match(peer, val)) { + php_error_docref(NULL, E_WARNING, - "Peer fingerprint doesn't match" + "peer_fingerprint match failure" ); return FAILURE; } } else { - php_error_docref(NULL TSRMLS_CC, E_WARNING, + php_error_docref(NULL, E_WARNING, "Expected peer fingerprint must be a string or an array" ); + return FAILURE; } }

« previous php.cvs (#85210) next »