Skip to content

Commit

Permalink
fix_hostname: zero length host name caused -1 index offset
Browse files Browse the repository at this point in the history
If a URL is given with a zero-length host name, like in "http://:80" or
just ":80", `fix_hostname()` will index the host name pointer with a -1
offset (as it blindly assumes a non-zero length) and both read and
assign that address.

CVE-2015-3144

Bug: http://curl.haxx.se/docs/adv_20150422D.html
Reported-by: Hanno Böck
  • Loading branch information
bagder committed Apr 21, 2015
1 parent b5f947b commit 0583e87
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/url.c
Expand Up @@ -3627,7 +3627,7 @@ static void fix_hostname(struct SessionHandle *data,
host->dispname = host->name;

len = strlen(host->name);
if(host->name[len-1] == '.')
if(len && (host->name[len-1] == '.'))
/* strip off a single trailing dot if present, primarily for SNI but
there's no use for it */
host->name[len-1]=0;
Expand Down

0 comments on commit 0583e87

Please sign in to comment.