Skip to content

Commit 5f9be59

Browse files
committed
htp: checks a hostname does not begin with a slash
Ticket: 7851 If it does, it is an URI, not a valid host name
1 parent 314ca73 commit 5f9be59

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

htp/htp_util.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -623,6 +623,12 @@ htp_status_t htp_parse_hostport(bstr *hostport, bstr **hostname, bstr **port, in
623623
unsigned char *colon = memchr(data, ':', len);
624624
if (colon == NULL) {
625625
// Hostname alone, no port.
626+
if (data[0] == '/' && (len == 1 || data[1] != '/')) {
627+
//If it starts with "//", we should skip (might have parsed a scheme and no creds)
628+
//If it starts with '/', this is a path, not a hostname
629+
*invalid = 1;
630+
return HTP_OK;
631+
}
626632

627633
*hostname = bstr_dup_mem(data, len);
628634
if (*hostname == NULL) return HTP_ERROR;

0 commit comments

Comments
 (0)