diff options
author | thomas <thomas@FreeBSD.org> | 2002-09-10 13:56:30 +0000 |
---|---|---|
committer | thomas <thomas@FreeBSD.org> | 2002-09-10 13:56:30 +0000 |
commit | cf69565b5f5f60354e70b2fb8009da43de22c1ff (patch) | |
tree | c301ddbabb42d1f6132bd12504cfdbd48c74d6c8 /usr.bin/perl | |
parent | 0cf07ebe50d925cb964b61f9d401ebc3f6cfba4e (diff) | |
download | FreeBSD-src-cf69565b5f5f60354e70b2fb8009da43de22c1ff.zip FreeBSD-src-cf69565b5f5f60354e70b2fb8009da43de22c1ff.tar.gz |
Prevent the wrapper from looping on itself forever, when there
is a symbolic link in the PATH pointing back to /usr/bin/perl.
Change WARNS from 6 to 5 to account for the fact that sys/time.h,
included from sys/stat.h, produces a warning when compiled with
-pedantic.
PR: bin/42418
Reviewed by: roberto
Diffstat (limited to 'usr.bin/perl')
-rw-r--r-- | usr.bin/perl/Makefile | 2 | ||||
-rw-r--r-- | usr.bin/perl/perl.c | 10 |
2 files changed, 11 insertions, 1 deletions
diff --git a/usr.bin/perl/Makefile b/usr.bin/perl/Makefile index 0eaf69c..17994de 100644 --- a/usr.bin/perl/Makefile +++ b/usr.bin/perl/Makefile @@ -2,7 +2,7 @@ PROG= perl NOMAN= -WARNS?= 6 +WARNS?= 5 LINKS= ${BINDIR}/perl ${BINDIR}/perl5 \ ${BINDIR}/perl ${BINDIR}/perl5.6.1 \ ${BINDIR}/perl ${BINDIR}/suidperl diff --git a/usr.bin/perl/perl.c b/usr.bin/perl/perl.c index cb43457..2bd55e7 100644 --- a/usr.bin/perl/perl.c +++ b/usr.bin/perl/perl.c @@ -30,6 +30,7 @@ __FBSDID("$FreeBSD$"); #include <sys/param.h> +#include <sys/stat.h> #include <sys/sysctl.h> #include <err.h> @@ -49,8 +50,13 @@ main(int argc __unused, char *argv[]) char path[PATH_MAX], *cp; const char *cmd, *p, *q, *self; size_t len; + struct stat self_stat, perl_stat; self = argv[0]; + if (stat (self, &self_stat) != 0) { + self_stat.st_dev = makedev (0, 0); + self_stat.st_ino = 0; + } if ((cmd = strrchr(self, '/')) == NULL) cmd = self; else @@ -79,6 +85,10 @@ main(int argc __unused, char *argv[]) len = snprintf(path, sizeof path, "%.*s/%s", (int)(q - p), p, cmd); if (len >= PATH_MAX || strcmp(path, self) == 0) continue; + if (stat (path, &perl_stat) == 0 + && self_stat.st_dev == perl_stat.st_dev + && self_stat.st_ino == perl_stat.st_ino) + continue; execve(path, argv, environ); if (errno != ENOENT) err(1, "%s", path); |