X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;f=support%2Fnfs%2Fcacheio.c;h=d7ad4293762f4b6dd583fec668cb0ea9df47b733;hb=aa2d7a1e352a6c2190452ebc3c638b66a2cf6f9b;hp=33231b01e1daae34cbff3933224b307978b7be37;hpb=83e21e0398d4aa4028fb14586a7726da9088b65f;p=nfs-utils.git 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; }