projects
/
m6w6
/
ext-http
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
|
github
raw
|
inline
| side by side
- fix possible leak and unitiliazed port
[m6w6/ext-http]
/
http_url_api.c
diff --git
a/http_url_api.c
b/http_url_api.c
index 9e87bae42496e3bc887b8eaac8d1f4f8abcd2db4..882c390549f284cfda18d883fb95310058978faa 100644
(file)
--- a/
http_url_api.c
+++ b/
http_url_api.c
@@
-51,13
+51,15
@@
PHP_HTTP_API char *_http_absolute_url_ex(
return NULL;
}
return NULL;
}
- URL = ecalloc(1, HTTP_URI_MAXLEN + 1);
uri = estrndup(url, url_len);
if (!(purl = php_url_parse(uri))) {
uri = estrndup(url, url_len);
if (!(purl = php_url_parse(uri))) {
+ efree(uri);
http_error_ex(HE_WARNING, HTTP_E_URL, "Could not parse supplied URL: %s", url);
return NULL;
}
http_error_ex(HE_WARNING, HTTP_E_URL, "Could not parse supplied URL: %s", url);
return NULL;
}
+ URL = ecalloc(1, HTTP_URI_MAXLEN + 1);
+
furl.user = purl->user;
furl.pass = purl->pass;
furl.path = purl->path;
furl.user = purl->user;
furl.pass = purl->pass;
furl.path = purl->path;
@@
-86,6
+88,7
@@
PHP_HTTP_API char *_http_absolute_url_ex(
furl.port = ntohs(se->s_port);
}
#endif
furl.port = ntohs(se->s_port);
}
#endif
+ furl.port = 0;
} else {
furl.port = (furl.scheme[4] == 's') ? 443 : 80;
}
} else {
furl.port = (furl.scheme[4] == 's') ? 443 : 80;
}
@@
-133,12
+136,12
@@
PHP_HTTP_API char *_http_absolute_url_ex(
HTTP_URI_STRLCATL(URL, full_len, furl.host);
HTTP_URI_STRLCATL(URL, full_len, furl.host);
- if (
(!strcmp(furl.scheme, "http") && (furl.port != 80)) ||
+ if (
(
(!strcmp(furl.scheme, "http") && (furl.port != 80)) ||
(!strcmp(furl.scheme, "https") && (furl.port != 443))
#if defined(PHP_WIN32) || defined(HAVE_NETDB_H)
(!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))
+ || ((
!(se = getservbyname(furl.scheme, "tcp"))) ||
(ntohs(se->s_port) != furl.port))
#endif
#endif
- ) {
+ )
&& furl.port)
{
char port_string[8] = {0};
snprintf(port_string, 7, ":%u", furl.port);
HTTP_URI_STRLCATL(URL, full_len, port_string);
char port_string[8] = {0};
snprintf(port_string, 7, ":%u", furl.port);
HTTP_URI_STRLCATL(URL, full_len, port_string);