From 4f92df742afb02d4038cec97da7eb94da8494cb3 Mon Sep 17 00:00:00 2001 From: alfred Date: Fri, 20 Sep 2002 21:50:57 +0000 Subject: Fix an infinite loop when _fetch_read() can return 0 (if the connection is broken), take this into account and return at this point. --- lib/libfetch/common.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'lib/libfetch/common.c') diff --git a/lib/libfetch/common.c b/lib/libfetch/common.c index 4b2e6ea..07434c6 100644 --- a/lib/libfetch/common.c +++ b/lib/libfetch/common.c @@ -406,6 +406,7 @@ _fetch_getln(conn_t *conn) char *tmp; size_t tmpsize; char c; + int error; if (conn->buf == NULL) { if ((conn->buf = malloc(MIN_BUF_SIZE)) == NULL) { @@ -419,8 +420,11 @@ _fetch_getln(conn_t *conn) conn->buflen = 0; do { - if (_fetch_read(conn, &c, 1) == -1) + error = _fetch_read(conn, &c, 1); + if (error == -1) return (-1); + else if (error == 0) + break; conn->buf[conn->buflen++] = c; if (conn->buflen == conn->bufsize) { tmp = conn->buf; -- cgit v1.1