aboutsummaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorGene Cumm <gene.cumm@gmail.com>2015-10-10 10:00:02 -0400
committerGene Cumm <gene.cumm@gmail.com>2015-10-10 10:00:02 -0400
commitd04e8b2ffd982e58111e03e413136f3b7ec4b9dc (patch)
treee3cbfdee7e5caa0e7feff70e252a926c41a1c0c8 /core
parentd27385b833820d1b9d0df5d4b9e3feea84b86cdc (diff)
downloadsyslinux-d04e8b2ffd982e58111e03e413136f3b7ec4b9dc.tar.gz
syslinux-d04e8b2ffd982e58111e03e413136f3b7ec4b9dc.tar.xz
syslinux-d04e8b2ffd982e58111e03e413136f3b7ec4b9dc.zip
core/http: Append port number to Host field if needed
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>
Diffstat (limited to 'core')
-rw-r--r--core/fs/pxe/http.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/core/fs/pxe/http.c b/core/fs/pxe/http.c
index bd18f3cb..f5f49e2b 100644
--- a/core/fs/pxe/http.c
+++ b/core/fs/pxe/http.c
@@ -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 */