diff options
author | Alfred Perlstein <alfred@FreeBSD.org> | 2002-09-20 21:50:57 +0000 |
---|---|---|
committer | Alfred Perlstein <alfred@FreeBSD.org> | 2002-09-20 21:50:57 +0000 |
commit | a6756ecc226415c5f8b5de185943adb5f2bc6837 (patch) | |
tree | 16af1fa4ab687ba00892c9b2cd87897607c04e24 /lib | |
parent | 15b23bddd9886d67631aff39d095af47415771dc (diff) | |
download | src-a6756ecc226415c5f8b5de185943adb5f2bc6837.tar.gz src-a6756ecc226415c5f8b5de185943adb5f2bc6837.zip |
Fix an infinite loop when _fetch_read() can return 0 (if the
connection is broken), take this into account and return at this
point.
Notes
Notes:
svn path=/head/; revision=103718
Diffstat (limited to 'lib')
-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 4b2e6ea3fdfa..07434c6301ea 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; |