Loading...
--- Libc/Libc-583/gen/FreeBSD/getcwd.c.patch
+++ Libc/Libc-763.12/gen/FreeBSD/getcwd.c.patch
@@ -1,6 +1,6 @@
---- getcwd.c.orig 2006-06-07 17:42:52.000000000 -0700
-+++ getcwd.c 2006-06-07 17:44:47.000000000 -0700
-@@ -54,12 +54,87 @@
+--- getcwd.c.bsdnew 2009-11-08 15:25:00.000000000 -0800
++++ getcwd.c 2009-11-08 15:30:17.000000000 -0800
+@@ -50,12 +50,87 @@ __FBSDID("$FreeBSD: src/lib/libc/gen/get
(dp->d_name[0] == '.' && (dp->d_name[1] == '\0' || \
(dp->d_name[1] == '.' && dp->d_name[2] == '\0')))
@@ -91,11 +91,11 @@
{
struct dirent *dp;
DIR *dir = NULL;
-@@ -91,31 +166,25 @@
+@@ -87,33 +162,27 @@ getcwd(pt, size)
}
ept = pt + size;
} else {
-- if ((pt = malloc(ptsize = 1024 - 4)) == NULL)
+- if ((pt = malloc(ptsize = PATH_MAX)) == NULL)
+ if ((pt = malloc(ptsize = MAXPATHLEN)) == NULL)
return (NULL);
ept = pt + ptsize;
@@ -121,17 +121,20 @@
*bpt = '\0';
/*
-- * Allocate bytes (1024 - malloc space) for the string of "../"'s.
-+ * Allocate bytes MAXPATHLEN) for the string of "../"'s.
- * Should always be enough (it's 340 levels). If it's not, allocate
+- * Allocate 1024 bytes for the string of "../"'s.
++ * Allocate MAXPATHLEN bytes for the string of "../"'s.
+ * Should always be enough. If it's not, allocate
* as necessary. Special case the first stat, it's ".", not "..".
*/
-- if ((up = malloc(upsize = 1024 - 4)) == NULL)
+- if ((up = malloc(upsize = 1024)) == NULL)
+ if ((up = malloc(upsize = MAXPATHLEN)) == NULL)
goto err;
- eup = up + MAXPATHLEN;
+- eup = up + upsize;
++ eup = up + MAXPATHLEN;
bup = up;
-@@ -259,3 +328,11 @@
+ up[0] = '.';
+ up[1] = '\0';
+@@ -255,3 +324,11 @@ err:
errno = save_errno;
return (NULL);
}