only accept ports in range

http://example.com:-1 isn't a valid url
Esse commit está contido em:
Paul Tarjan
2013-06-11 19:44:44 -07:00
commit de sgolemon
commit 6d109c37c2
+12 -2
Ver Arquivo
@@ -144,7 +144,12 @@ bool url_parse(Url &output, const char *str, int length) {
if (pp-p < 6 && (*pp == '/' || *pp == '\0')) {
memcpy(port_buf, p, (pp-p));
port_buf[pp-p] = '\0';
output.port = atoi(port_buf);
auto port = atoi(port_buf);
if (port > 0 && port <= 65535) {
output.port = port;
} else {
return false;
}
} else {
goto just_path;
}
@@ -207,7 +212,12 @@ bool url_parse(Url &output, const char *str, int length) {
} else if (e - p > 0) {
memcpy(port_buf, p, (e-p));
port_buf[e-p] = '\0';
output.port = atoi(port_buf);
auto port = atoi(port_buf);
if (port > 0 && port <= 65535) {
output.port = port;
} else {
return false;
}
}
p--;
}