From 470e1e423668df42a3d7eb9bde35d09a9da372f6 Mon Sep 17 00:00:00 2001 From: ache Date: Sun, 18 Sep 2005 17:50:58 +0000 Subject: Just by allocating size*2 bytes we can't be sure that new size will be enough, so change two if (size not enough) { reallocf(size*2); } into while (size not enough) { reallocf(size*2); } --- lib/libc/gen/getcwd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/libc/gen/getcwd.c b/lib/libc/gen/getcwd.c index 6e0eda5..b18921b 100644 --- a/lib/libc/gen/getcwd.c +++ b/lib/libc/gen/getcwd.c @@ -157,7 +157,7 @@ getcwd(pt, size) * as necessary. Max length is 3 for "../", the largest * possible component name, plus a trailing NUL. */ - if (bup + 3 + MAXNAMLEN + 1 >= eup) { + while (bup + 3 + MAXNAMLEN + 1 >= eup) { if ((up = reallocf(up, upsize *= 2)) == NULL) goto err; bup = up; @@ -211,7 +211,7 @@ getcwd(pt, size) * Check for length of the current name, preceding slash, * leading slash. */ - if (bpt - pt < dp->d_namlen + (first ? 1 : 2)) { + while (bpt - pt < dp->d_namlen + (first ? 1 : 2)) { size_t len, off; if (!ptsize) { -- cgit v1.1