diff options
author | alfred <alfred@FreeBSD.org> | 2002-09-20 21:50:57 +0000 |
---|---|---|
committer | alfred <alfred@FreeBSD.org> | 2002-09-20 21:50:57 +0000 |
commit | 4f92df742afb02d4038cec97da7eb94da8494cb3 (patch) | |
tree | 16af1fa4ab687ba00892c9b2cd87897607c04e24 | |
parent | f49cc792fa5d17dbf8150e52c9a16284a12bc2c2 (diff) | |
download | FreeBSD-src-4f92df742afb02d4038cec97da7eb94da8494cb3.zip FreeBSD-src-4f92df742afb02d4038cec97da7eb94da8494cb3.tar.gz |
Fix an infinite loop when _fetch_read() can return 0 (if the
connection is broken), take this into account and return at this
point.
-rw-r--r-- | lib/libfetch/common.c | 6 |
1 files changed, 5 insertions, 1 deletions
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; |