mirror of
https://github.com/freebsd/freebsd-src.git
synced 2024-11-29 08:52:46 +00:00
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
This commit is contained in:
parent
bb77b79340
commit
39449b2c8a
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=103188
@ -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
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user