From c9cddf51e757d8e59f0d5ead82a9d2414d61e9be Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Wed, 7 Jul 1999 12:30:38 +0000 Subject: Update. 1999-07-07 Ulrich Drepper * sysdeps/posix/getcwd.c: When resizing buffer make sure new size is large enough. --- sysdeps/posix/getcwd.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'sysdeps/posix/getcwd.c') diff --git a/sysdeps/posix/getcwd.c b/sysdeps/posix/getcwd.c index fe094b5a35..950ae613e7 100644 --- a/sysdeps/posix/getcwd.c +++ b/sysdeps/posix/getcwd.c @@ -135,6 +135,10 @@ extern void free (); # define memmove memcpy #endif /* Not ANSI_STRING. */ +#ifndef MAX +# define MAX(a, b) ((a) < (b) ? (b) : (a)) +#endif + #ifdef _LIBC # ifndef mempcpy # define mempcpy __mempcpy @@ -368,7 +372,7 @@ __getcwd (buf, size) { char *tmp; - size *= 2; + size = 2 * MAX (size, namlen); tmp = realloc (path, size); if (tmp == NULL) { -- cgit v1.2.3