From 635eb7ac7990a2bb29e1992b739617a9db012bf2 Mon Sep 17 00:00:00 2001 From: Baptiste Daroussin Date: Thu, 9 Sep 2021 16:48:21 +0200 Subject: [PATCH] fetch: do not confuse capacity and length The patch converting fetch to getline (ee3ca711a898cf41330c320826ea1e0e6e451f1d), did confuse the capacity of the line buffer with the actual len of the read line confusing fetch -v. --- lib/libfetch/http.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/libfetch/http.c b/lib/libfetch/http.c index 61f0f393ed9..bcb089dc0fc 100644 --- a/lib/libfetch/http.c +++ b/lib/libfetch/http.c @@ -1526,12 +1526,13 @@ http_get_proxy(struct url * url, const char *flags) static void http_print_html(FILE *out, FILE *in) { - size_t len = 0; + ssize_t len = 0; + size_t cap; char *line = NULL, *p, *q; int comment, tag; comment = tag = 0; - while (getline(&line, &len, in) >= 0) { + while ((len = getline(&line, &cap, in)) >= 0) { while (len && isspace((unsigned char)line[len - 1])) --len; for (p = q = line; q < line + len; ++q) {