Date: Tue, 17 Aug 2021 14:17:44 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: ee3ca711a898 - main - libfetch: use more portable getline() interface Message-ID: <202108171417.17HEHifv012483@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=ee3ca711a898cf41330c320826ea1e0e6e451f1d commit ee3ca711a898cf41330c320826ea1e0e6e451f1d Author: Daniel Kolesa <daniel@octaforge.org> AuthorDate: 2021-08-17 14:01:46 +0000 Commit: Baptiste Daroussin <bapt@FreeBSD.org> CommitDate: 2021-08-17 14:17:22 +0000 libfetch: use more portable getline() interface this is for better portability in order to avoid using a function which is BSD-only or available via libbsd MFC after: 3 weeks --- lib/libfetch/http.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/libfetch/http.c b/lib/libfetch/http.c index e61e23b1425a..61f0f393ed98 100644 --- a/lib/libfetch/http.c +++ b/lib/libfetch/http.c @@ -1526,12 +1526,12 @@ http_get_proxy(struct url * url, const char *flags) static void http_print_html(FILE *out, FILE *in) { - size_t len; - char *line, *p, *q; + size_t len = 0; + char *line = NULL, *p, *q; int comment, tag; comment = tag = 0; - while ((line = fgetln(in, &len)) != NULL) { + while (getline(&line, &len, in) >= 0) { while (len && isspace((unsigned char)line[len - 1])) --len; for (p = q = line; q < line + len; ++q) { @@ -1559,6 +1559,8 @@ http_print_html(FILE *out, FILE *in) fwrite(p, q - p, 1, out); fputc('\n', out); } + + free(line); }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202108171417.17HEHifv012483>