Loading...
stdlib/FreeBSD/realpath.c.patch Libc-583 Libc-498.1.5
--- Libc/Libc-583/stdlib/FreeBSD/realpath.c.patch
+++ Libc/Libc-498.1.5/stdlib/FreeBSD/realpath.c.patch
@@ -1,6 +1,6 @@
---- realpath.c.orig	2008-04-04 14:39:39.000000000 -0700
-+++ realpath.c	2008-04-04 19:59:19.000000000 -0700
-@@ -35,13 +35,41 @@ __FBSDID("$FreeBSD: src/lib/libc/stdlib/
+--- realpath.c.orig	2006-09-16 19:12:28.000000000 -0700
++++ realpath.c	2006-09-16 20:18:25.000000000 -0700
+@@ -35,13 +35,41 @@
  #include "namespace.h"
  #include <sys/param.h>
  #include <sys/stat.h>
@@ -42,12 +42,9 @@
  /*
   * char *realpath(const char *path, char resolved[PATH_MAX]);
   *
-@@ -50,26 +78,67 @@ __FBSDID("$FreeBSD: src/lib/libc/stdlib/
-  * in which case the path which caused trouble is left in (resolved).
-  */
+@@ -52,24 +80,55 @@
  char *
--realpath(const char *path, char resolved[PATH_MAX])
-+realpath(const char *path, char inresolved[PATH_MAX])
+ realpath(const char *path, char resolved[PATH_MAX])
  {
 +	struct attrs attrs;
  	struct stat sb;
@@ -63,7 +60,6 @@
 +	static dev_t rootdev;
 +	static int rootdev_inited = 0;
 +	ino_t inode;
-+	char *resolved;
  
 +	if (path == NULL) {
 +		errno = EINVAL;
@@ -75,15 +71,6 @@
 +		return (NULL);
 +	}
 +#endif /* __DARWIN_UNIX03 */
-+	/*
-+	 * Extension to the standard; if inresolved == NULL, allocate memory
-+	 * (first on the stack, then use strdup())
-+	 */
-+	if (!inresolved) {
-+	    if ((resolved = alloca(PATH_MAX)) == NULL) return (NULL);
-+	} else {
-+	    resolved = inresolved;
-+	}
 +	if (!rootdev_inited) {
 +		rootdev_inited = 1;
 +		if (stat("/", &sb) < 0) {
@@ -115,7 +102,7 @@
  			strlcpy(resolved, ".", PATH_MAX);
  			return (NULL);
  		}
-@@ -80,6 +149,13 @@ realpath(const char *path, char resolved
+@@ -80,6 +139,13 @@
  		errno = ENAMETOOLONG;
  		return (NULL);
  	}
@@ -129,7 +116,7 @@
  
  	/*
  	 * Iterate over path components in `left'.
-@@ -127,6 +203,13 @@ realpath(const char *path, char resolved
+@@ -127,6 +193,13 @@
  		}
  
  		/*
@@ -143,7 +130,7 @@
  		 * Append the next path component and lstat() it. If
  		 * lstat() fails we still can return successfully if
  		 * there are no more path components left.
-@@ -136,25 +219,87 @@ realpath(const char *path, char resolved
+@@ -136,25 +209,87 @@
  			errno = ENAMETOOLONG;
  			return (NULL);
  		}
@@ -191,7 +178,7 @@
 +				 * that each component of the mountpoint
 +				 * is a directory (and not a symlink)
 +				 */
-+				char temp[sizeof(sfs.f_mntonname)];
++				char temp[MNAMELEN];
 +				char *cp;
 +				int ok = 1;
 +
@@ -234,7 +221,7 @@
  			} else if (resolved_len > 1) {
  				/* Strip the last path component. */
  				resolved[resolved_len - 1] = '\0';
-@@ -184,7 +329,30 @@ realpath(const char *path, char resolved
+@@ -184,7 +319,30 @@
  				}
  			}
  			left_len = strlcpy(left, symlink, sizeof(left));
@@ -265,10 +252,3 @@
  	}
  
  	/*
-@@ -193,5 +361,6 @@ realpath(const char *path, char resolved
- 	 */
- 	if (resolved_len > 1 && resolved[resolved_len - 1] == '/')
- 		resolved[resolved_len - 1] = '\0';
-+	if (!inresolved) resolved = strdup(resolved);
- 	return (resolved);
- }