1 From 6218ded6001ea330e589f92b6b2fa12777752b5d Mon Sep 17 00:00:00 2001
2 From: Daniel Stenberg <daniel@haxx.se>
3 Date: Thu, 16 Apr 2015 23:52:04 +0200
4 Subject: [PATCH] fix_hostname: zero length host name caused -1 index offset
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
9 If a URL is given with a zero-length host name, like in "http://:80" or
10 just ":80", `fix_hostname()` will index the host name pointer with a -1
11 offset (as it blindly assumes a non-zero length) and both read and
16 Bug: http://curl.haxx.se/docs/adv_20150422D.html
17 Reported-by: Hanno Böck
20 1 file changed, 1 insertion(+), 1 deletion(-)
24 @@ -3606,7 +3606,7 @@ static void fix_hostname(struct SessionH
25 host->dispname = host->name;
27 len = strlen(host->name);
28 - if(host->name[len-1] == '.')
29 + if(len && (host->name[len-1] == '.'))
30 /* strip off a single trailing dot if present, primarily for SNI but
31 there's no use for it */