From: gmorris Date: Sun, 6 Mar 2005 16:27:36 +0000 (+0000) Subject: Fix bug [ 1157791 ] Segfault in mountd. X-Git-Tag: nfs-utils-1-0-7-post1~18 X-Git-Url: https://git.decadent.org.uk/gitweb/?a=commitdiff_plain;h=7d6fa6e153b26e0e9ad2dfdff3ce2168c46dd16b;p=nfs-utils.git Fix bug [ 1157791 ] Segfault in mountd. --- diff --git a/support/nfs/cacheio.c b/support/nfs/cacheio.c index 33231b0..d7ad429 100644 --- a/support/nfs/cacheio.c +++ b/support/nfs/cacheio.c @@ -205,16 +205,17 @@ int readline(int fd, char **buf, int *lenp) */ char *new; int nl; - *lenp += 128; + *lenp *= 2; new = realloc(*buf, *lenp); if (new == NULL) return 0; - nl = read(fd, *buf +len, *lenp - len); - if (nl <= 0 ) + *buf = new; + nl = read(fd, *buf + len, *lenp - len); + if (nl <= 0) return 0; - new += nl; + len += nl; } - (*buf)[len-1] = 0; + (*buf)[len-1] = '\0'; return 1; }