summaryrefslogtreecommitdiff
path: root/libproxy
diff options
context:
space:
mode:
authornicolas.dufresne <nicolas.dufresne@c587cffe-e639-0410-9787-d7902ae8ed56>2010-10-06 17:23:13 +0000
committernicolas.dufresne <nicolas.dufresne@c587cffe-e639-0410-9787-d7902ae8ed56>2010-10-06 17:23:13 +0000
commit9eabf582d6dd8e11d21ab82afdfaa5a0340797e1 (patch)
tree0e25d95270ea93a6aaaa344b920a3c0ed73ef99e /libproxy
parentc75ad0cc9dc26f0abe4bf741afa94d3dc56a5bf2 (diff)
downloadlibproxy-9eabf582d6dd8e11d21ab82afdfaa5a0340797e1.tar.gz
Avoid to read the NULL character in strings
The URL parser whas assuming that we can read the NULL character in a string. This does not work on Windows platform, and is not standard. git-svn-id: http://libproxy.googlecode.com/svn/trunk@769 c587cffe-e639-0410-9787-d7902ae8ed56
Diffstat (limited to 'libproxy')
-rw-r--r--libproxy/url.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/libproxy/url.cpp b/libproxy/url.cpp
index b6f3fe4..1ad6ff1 100644
--- a/libproxy/url.cpp
+++ b/libproxy/url.cpp
@@ -173,7 +173,7 @@ url::url(const string &url) throw(parse_error)
* / path-empty
*/
- if (hier_part.size() > 2 && hier_part[0] == '/' && hier_part[1] == '/') {
+ if (hier_part.size() >= 2 && hier_part[0] == '/' && hier_part[1] == '/') {
size_t authority_start, authority_end;
size_t userinfo_start, userinfo_end;
size_t host_start, host_end;
@@ -211,7 +211,8 @@ url::url(const string &url) throw(parse_error)
host_start = userinfo_end + 1;
/* Check for IPv6 IP */
- if (hier_part[host_start] == '[') {
+ if (host_start < hier_part.size()
+ && hier_part[host_start] == '[') {
host_end = hier_part.find(']', host_start);
if (host_end == string::npos)
throw parse_error("Invalid URL: " + url);
@@ -232,7 +233,7 @@ url::url(const string &url) throw(parse_error)
/* Get port */
m_port = get_default_port(m_scheme);
- if (host_end != hier_part.size()
+ if (host_end < hier_part.size()
&& hier_part[host_end] == ':') {
size_t port_start = host_end + 1;
m_port = atoi(hier_part.c_str() + port_start);