Skip to content

Commit

Permalink
core/http: Append port number to Host field if needed
Browse files Browse the repository at this point in the history
HTTP/1.1 header Host must contain the port number if not default for the
protocol.  Host isn't a part of HTTP/1.0 but let's implement it right.

Reported-By: Michael DeCandia <michael.decandia@gmail.com>
Signed-off-by: Gene Cumm <gene.cumm@gmail.com>
  • Loading branch information
geneC committed Oct 10, 2015
1 parent d27385b commit d04e8b2
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions core/fs/pxe/http.c
Expand Up @@ -211,12 +211,25 @@ void http_open(struct url_info *url, int flags, struct inode *inode,
header_bytes += snprintf(header_buf + header_bytes,
header_len - header_bytes,
" HTTP/1.0\r\n"
"Host: %s\r\n"
"Host: %s",
url->host);
if (header_bytes >= header_len)
goto fail; /* Buffer overflow */
if (url->port != HTTP_PORT) {
header_bytes += snprintf(header_buf + header_bytes,
header_len - header_bytes,
":%d", url->port);
if (header_bytes >= header_len)
goto fail; /* Buffer overflow */
}
header_bytes += snprintf(header_buf + header_bytes,
header_len - header_bytes,
"\r\n"
"User-Agent: Syslinux/" VERSION_STR "\r\n"
"Connection: close\r\n"
"%s"
"\r\n",
url->host, cookie_buf ? cookie_buf : "");
cookie_buf ? cookie_buf : "");
if (header_bytes >= header_len)
goto fail; /* Buffer overflow */

Expand Down

0 comments on commit d04e8b2

Please sign in to comment.