svn commit: r279714 - stable/9/libexec/rtld-elf

Jung-uk Kim jkim at FreeBSD.org
Fri Mar 6 22:34:10 UTC 2015


Author: jkim
Date: Fri Mar  6 22:34:09 2015
New Revision: 279714
URL: https://svnweb.freebsd.org/changeset/base/279714

Log:
  MFC:	r279713
  
  Use realpath(3) to properly expand $ORIGIN to its absolute path.

Modified:
  stable/9/libexec/rtld-elf/rtld.c
Directory Properties:
  stable/9/libexec/rtld-elf/   (props changed)

Modified: stable/9/libexec/rtld-elf/rtld.c
==============================================================================
--- stable/9/libexec/rtld-elf/rtld.c	Fri Mar  6 22:31:35 2015	(r279713)
+++ stable/9/libexec/rtld-elf/rtld.c	Fri Mar  6 22:34:09 2015	(r279714)
@@ -3415,17 +3415,16 @@ rtld_dirname(const char *path, char *bna
 static int
 rtld_dirname_abs(const char *path, char *base)
 {
-	char base_rel[PATH_MAX];
+	char *last;
 
-	if (rtld_dirname(path, base) == -1)
+	if (realpath(path, base) == NULL)
 		return (-1);
-	if (base[0] == '/')
-		return (0);
-	if (getcwd(base_rel, sizeof(base_rel)) == NULL ||
-	    strlcat(base_rel, "/", sizeof(base_rel)) >= sizeof(base_rel) ||
-	    strlcat(base_rel, base, sizeof(base_rel)) >= sizeof(base_rel))
+	dbg("%s -> %s", path, base);
+	last = strrchr(base, '/');
+	if (last == NULL)
 		return (-1);
-	strcpy(base, base_rel);
+	if (last != base)
+		*last = '\0';
 	return (0);
 }
 


More information about the svn-src-stable-9 mailing list