diff options
author | 2014-10-08 22:38:51 -0400 | |
---|---|---|
committer | 2014-10-08 22:38:51 -0400 | |
commit | 24d22f45656fb88c63763ca319a2275b8f642d9e (patch) | |
tree | 26742acc4cccd4b7712733bc0608ee55eaadfc1b | |
parent | scripts/revdep-pax: rename 'maps' -> 'graph' (diff) | |
download | elfix-24d22f45656fb88c63763ca319a2275b8f642d9e.tar.gz elfix-24d22f45656fb88c63763ca319a2275b8f642d9e.tar.bz2 elfix-24d22f45656fb88c63763ca319a2275b8f642d9e.zip |
misc/install-xattr: correct potential fork bomb
The which() function compares portage_helper_path, to canpath
and skips it when appropriate:
if (portage_helper_path)
if (!strcmp(portage_helper_path, canpath))
goto skip;
However, portage_helper_path has not been canonicalized with
the realpath function, so strcmp can return false even though
the paths are equivalent. This may occurs when /usr/lib is a
symlink to /usr/lib64.
X-Gentoo-Bug: 523994
X-Gentoo-Bug-URL: https://bugs.gentoo.org/523994
-rw-r--r-- | misc/install-xattr/install-xattr.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/misc/install-xattr/install-xattr.c b/misc/install-xattr/install-xattr.c index 805c0a4..2f349df 100644 --- a/misc/install-xattr/install-xattr.c +++ b/misc/install-xattr/install-xattr.c @@ -325,6 +325,7 @@ main(int argc, char* argv[]) */ char *oldpwd = getenv("OLDPWD"); char *portage_helper_path = getenv("__PORTAGE_HELPER_PATH"); + char *portage_helper_canpath = NULL; if (portage_helper_path) chdir(oldpwd); @@ -334,8 +335,11 @@ main(int argc, char* argv[]) case 0: /* find system install avoiding mypath and portage_helper_path! */ - install = which(mypath, portage_helper_path); + if (portage_helper_path) + portage_helper_canpath = realpath(portage_helper_path, NULL); + install = which(mypath, portage_helper_canpath); free(mypath); + free(portage_helper_canpath); argv[0] = install; /* so coreutils' lib/program.c behaves */ execv(install, argv); /* The kernel will free(install). */ err(1, "execv() failed"); |