summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKevin Dalley <kevin@seti.org>1998-09-26 23:08:36 +0000
committerKevin Dalley <kevin@seti.org>1998-09-26 23:08:36 +0000
commit93389453ef9b846ed02c949b1ce6005d17f79e7d (patch)
tree467696c3f1cfee5001b9dc21494faac5a2078f38
parent2dea4952ab52eb2c4fe86960b75cf11f0e4ba0cb (diff)
downloadfindutils-93389453ef9b846ed02c949b1ce6005d17f79e7d.tar.gz
* fix getstr so that it correctly handles long file paths
-rw-r--r--lib/getline.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/lib/getline.c b/lib/getline.c
index d2273185..3a1f4f52 100644
--- a/lib/getline.c
+++ b/lib/getline.c
@@ -82,12 +82,14 @@ getstr (lineptr, n, stream, terminator, offset)
* 2. always make *n a multiple of MIN_CHUNK just larger
* than condition 1 requires
*/
- *n = ((read_pos - *lineptr + 1) + 1)/MIN_CHUNK * MIN_CHUNK;
- nchars_avail = *n + *lineptr - read_pos;
+ int nchars_read;
+ nchars_read = read_pos - *lineptr;
+ *n = ((*n)/MIN_CHUNK + 1) * MIN_CHUNK;
*lineptr = realloc (*lineptr, *n);
if (!*lineptr)
return -1;
- read_pos = *n - nchars_avail + *lineptr;
+ read_pos = *lineptr + nchars_read;
+ nchars_avail = *n + *lineptr - read_pos;
assert(*n - nchars_avail == read_pos - *lineptr);
}