Skip to content

Commit a40dd6e

Browse files
committed
Changed return types to zend_bool, renamed test
1 parent 1970b96 commit a40dd6e

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

ext/openssl/openssl.c

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4951,7 +4951,7 @@ static int verify_callback(int preverify_ok, X509_STORE_CTX *ctx) /* {{{ */
49514951
}
49524952
/* }}} */
49534953

4954-
static int matches_wildcard_name(const char *subjectname, const char *certname)
4954+
static zend_bool matches_wildcard_name(const char *subjectname, const char *certname)
49554955
{
49564956
char *wildcard;
49574957
int prefix_len, suffix_len, subject_len;
@@ -4983,10 +4983,12 @@ static int matches_wildcard_name(const char *subjectname, const char *certname)
49834983
return 0;
49844984
}
49854985

4986-
static int matches_san_list(X509 *peer, const char *subject_name)
4986+
static zend_bool matches_san_list(X509 *peer, const char *subject_name)
49874987
{
4988-
int is_match, i;
4988+
int i;
4989+
zend_bool is_match = 0;
49894990
unsigned char *cert_name;
4991+
49904992
GENERAL_NAMES *alt_names = X509_get_ext_d2i(peer, NID_subject_alt_name, 0, 0);
49914993
int alt_name_count = sk_GENERAL_NAME_num(alt_names);
49924994

@@ -5007,25 +5009,26 @@ static int matches_san_list(X509 *peer, const char *subject_name)
50075009
return is_match;
50085010
}
50095011

5010-
static int matches_common_name(X509 *peer, const char *subject_name)
5012+
static zend_bool matches_common_name(X509 *peer, const char *subject_name)
50115013
{
50125014
char buf[1024];
50135015
X509_NAME *cert_name;
5016+
zend_bool is_match = 0;
5017+
50145018
cert_name = X509_get_subject_name(peer);
50155019
int cert_name_len = X509_NAME_get_text_by_NID(cert_name, NID_commonName, buf, sizeof(buf));
50165020

50175021
if (cert_name_len == -1) {
50185022
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to locate peer certificate CN");
5019-
return 0;
50205023
} else if (cert_name_len != strlen(buf)) {
50215024
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Peer certificate CN=`%.*s' is malformed", cert_name_len, buf);
5022-
return 0;
50235025
} else if (matches_wildcard_name(subject_name, buf)) {
5024-
return 1;
5026+
is_match = 1;
50255027
} else {
50265028
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Peer certificate CN=`%.*s' did not match expected CN=`%s'", cert_name_len, buf, subject_name);
5027-
return 0;
50285029
}
5030+
5031+
return is_match;
50295032
}
50305033

50315034
int php_openssl_apply_verification_policy(SSL *ssl, X509 *peer, php_stream *stream TSRMLS_DC) /* {{{ */

0 commit comments

Comments
 (0)