Date: Fri, 6 Mar 2015 22:31:35 +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-10@freebsd.org Subject: svn commit: r279713 - stable/10/libexec/rtld-elf Message-ID: <201503062231.t26MVZe6022741@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: jkim Date: Fri Mar 6 22:31:35 2015 New Revision: 279713 URL: https://svnweb.freebsd.org/changeset/base/279713 Log: MFC: r279364 Use realpath(3) to properly expand $ORIGIN to its absolute path. Modified: stable/10/libexec/rtld-elf/rtld.c Directory Properties: stable/10/ (props changed) Modified: stable/10/libexec/rtld-elf/rtld.c ============================================================================== --- stable/10/libexec/rtld-elf/rtld.c Fri Mar 6 22:22:57 2015 (r279712) +++ stable/10/libexec/rtld-elf/rtld.c Fri Mar 6 22:31:35 2015 (r279713) @@ -3420,17 +3420,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?201503062231.t26MVZe6022741>