Skip to content

Commit d7bcfcb

Browse files
committed
ext/soap: Refactor implementation of in_domain()
1 parent 6e9dd76 commit d7bcfcb

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

ext/soap/php_http.c

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -308,18 +308,16 @@ static php_stream* http_connect(zval* this_ptr, php_url *phpurl, int use_ssl, ph
308308
return stream;
309309
}
310310

311-
static int in_domain(const char *host, const char *domain)
311+
static bool in_domain(const zend_string *host, const zend_string *domain)
312312
{
313-
if (domain[0] == '.') {
314-
int l1 = strlen(host);
315-
int l2 = strlen(domain);
316-
if (l1 > l2) {
317-
return strcmp(host+l1-l2,domain) == 0;
313+
if (ZSTR_VAL(domain)[0] == '.') {
314+
if (ZSTR_LEN(host) > ZSTR_LEN(domain)) {
315+
return strcmp(ZSTR_VAL(host)+ZSTR_LEN(host)-ZSTR_LEN(domain), ZSTR_VAL(domain)) == 0;
318316
} else {
319317
return 0;
320318
}
321319
} else {
322-
return strcmp(host,domain) == 0;
320+
return zend_string_equals(host,domain);
323321
}
324322
}
325323

@@ -852,7 +850,7 @@ int make_http_soap_request(zval *this_ptr,
852850
strncmp(phpurl->path?ZSTR_VAL(phpurl->path):"/",Z_STRVAL_P(tmp),Z_STRLEN_P(tmp)) == 0) &&
853851
((tmp = zend_hash_index_find(Z_ARRVAL_P(data), 2)) == NULL ||
854852
Z_TYPE_P(tmp) != IS_STRING ||
855-
in_domain(ZSTR_VAL(phpurl->host),Z_STRVAL_P(tmp))) &&
853+
in_domain(phpurl->host, Z_STR_P(tmp))) &&
856854
(use_ssl || (tmp = zend_hash_index_find(Z_ARRVAL_P(data), 3)) == NULL)) {
857855
if (!first_cookie) {
858856
smart_str_appends(&soap_headers, "; ");

0 commit comments

Comments
 (0)