From 6e3dd5adc6b835d7706c440507e8d1301ec9cbb6 Mon Sep 17 00:00:00 2001 From: Michael Wallner Date: Wed, 7 Dec 2005 21:13:19 +0000 Subject: [PATCH] - furl.scheme cannot be NULL at this stage - check for different port for other protos than http(s) --- http_url_api.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/http_url_api.c b/http_url_api.c index 163dec3..9e87bae 100644 --- a/http_url_api.c +++ b/http_url_api.c @@ -80,14 +80,14 @@ PHP_HTTP_API char *_http_absolute_url_ex( furl.port = port; } else if (purl->port) { furl.port = purl->port; - } else if ((!furl.scheme) || strncmp(furl.scheme, "http", 4)) { + } else if (strncmp(furl.scheme, "http", 4)) { #if defined(PHP_WIN32) || defined(HAVE_NETDB_H) if ((se = getservbyname(furl.scheme, "tcp"))) { furl.port = ntohs(se->s_port); } #endif } else { - furl.port = (furl.scheme && furl.scheme[4] == 's') ? 443 : 80; + furl.port = (furl.scheme[4] == 's') ? 443 : 80; } if (host && host_len) { @@ -134,7 +134,11 @@ PHP_HTTP_API char *_http_absolute_url_ex( HTTP_URI_STRLCATL(URL, full_len, furl.host); if ( (!strcmp(furl.scheme, "http") && (furl.port != 80)) || - (!strcmp(furl.scheme, "https") && (furl.port != 443))) { + (!strcmp(furl.scheme, "https") && (furl.port != 443)) +#if defined(PHP_WIN32) || defined(HAVE_NETDB_H) + || ((se = getservbyname(furl.scheme, "tcp")) && (ntohs(se->s_port) != furl.port)) +#endif + ) { char port_string[8] = {0}; snprintf(port_string, 7, ":%u", furl.port); HTTP_URI_STRLCATL(URL, full_len, port_string); -- 2.30.2