Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 6 Mar 2015 22:34:09 +0000 (UTC)
From:      Jung-uk Kim <jkim@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org
Subject:   svn commit: r279714 - stable/9/libexec/rtld-elf
Message-ID:  <201503062234.t26MY9xR023411@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
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);
 }
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201503062234.t26MY9xR023411>