From 9bf79d32b2666584d043a05ad05d5f2d09d376c1 Mon Sep 17 00:00:00 2001 From: Stephane Bortzmeyer Date: Thu, 29 Mar 2007 20:27:50 +0000 Subject: [PATCH] Small precaution after strncpy --- SRC/http.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/SRC/http.c b/SRC/http.c index 0559f7b..e4b9662 100644 --- a/SRC/http.c +++ b/SRC/http.c @@ -26,8 +26,7 @@ make_http_sendline(char *url, char *host, int port, int nocache) cache_directive = "Pragma: no-cache\r\n"; /* RFC 1945, * "Hypertext * Transfer Protocol - * * * * -- - * HTTP/1.0" */ + * * -- HTTP/1.0" */ result = snprintf(sendline, size, "GET %s HTTP/1.0\r\nUser-Agent: Echoping/%s\r\n%s\r\n", url, VERSION, cache_directive); @@ -53,6 +52,7 @@ make_http_sendline(char *url, char *host, int port, int nocache) strncpy(hostname, HTParse(url, "", PARSE_HOST), size); /* See bug #1688940 * to see why we use * * strNcpy. */ + hostname[size] = '\0'; /* Not added automatically */ if (!strcmp(hostname, "")) snprintf(hostname, size, "%s:%d", host, sport); result = snprintf(sendline, size, @@ -149,8 +149,8 @@ read_from_server(CHANNEL fs, short ssl, boolean accept_redirects) */ if ((nr < 2) && (timeout_flag)) /* Probably a timeout */ return -1; - if (nr < 2) /* Hmm, if the body is empty, we'll get a * * * * - * meaningless error message */ + if (nr < 2) /* Hmm, if the body is empty, we'll get a * * * * * + * * meaningless error message */ err_sys("Error reading HTTP body"); total = total + nr; return total; /* How to do if we want only the body's size? */