Date: Fri, 6 Mar 2015 22:35:01 +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-8@freebsd.org Subject: svn commit: r279715 - stable/8/libexec/rtld-elf Message-ID: <201503062235.t26MZ1WQ023604@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: jkim Date: Fri Mar 6 22:35:01 2015 New Revision: 279715 URL: https://svnweb.freebsd.org/changeset/base/279715 Log: MFC: r279364 Use realpath(3) to properly expand $ORIGIN to its absolute path. Modified: stable/8/libexec/rtld-elf/rtld.c Directory Properties: stable/8/libexec/rtld-elf/ (props changed) Modified: stable/8/libexec/rtld-elf/rtld.c ============================================================================== --- stable/8/libexec/rtld-elf/rtld.c Fri Mar 6 22:34:09 2015 (r279714) +++ stable/8/libexec/rtld-elf/rtld.c Fri Mar 6 22:35:01 2015 (r279715) @@ -2563,17 +2563,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?201503062235.t26MZ1WQ023604>