summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorache <ache@FreeBSD.org>2005-09-18 17:50:58 +0000
committerache <ache@FreeBSD.org>2005-09-18 17:50:58 +0000
commit470e1e423668df42a3d7eb9bde35d09a9da372f6 (patch)
treee1660e0176d03e28773b1d6d4f28dff01bfdd71d
parent64eedb0310efb0ac8456dd7ad217d0bb521fb0fe (diff)
downloadFreeBSD-src-470e1e423668df42a3d7eb9bde35d09a9da372f6.zip
FreeBSD-src-470e1e423668df42a3d7eb9bde35d09a9da372f6.tar.gz
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); }
-rw-r--r--lib/libc/gen/getcwd.c4
1 files 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) {
OpenPOWER on IntegriCloud