Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 9 Sep 2021 14:51:37 GMT
From:      Baptiste Daroussin <bapt@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: 635eb7ac7990 - main - fetch: do not confuse capacity and length
Message-ID:  <202109091451.189Epbbu069816@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by bapt:

URL: https://cgit.FreeBSD.org/src/commit/?id=635eb7ac7990a2bb29e1992b739617a9db012bf2

commit 635eb7ac7990a2bb29e1992b739617a9db012bf2
Author:     Baptiste Daroussin <bapt@FreeBSD.org>
AuthorDate: 2021-09-09 14:48:21 +0000
Commit:     Baptiste Daroussin <bapt@FreeBSD.org>
CommitDate: 2021-09-09 14:51:26 +0000

    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 61f0f393ed98..bcb089dc0fc4 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) {



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202109091451.189Epbbu069816>