Calls one or more of malloc(), warn(), err(), syslog(), execlp() or
execvp() in the child branch of a vfork(). Changed to use fork() instead. Some of these (mv, find, apply, xargs) might benefit greatly from being rewritten to use vfork() properly. PR: Loosely related to bin/8252 Approved by: jkh and bde
This commit is contained in:
parent
0ffc35a465
commit
1fd98d7d88
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=40301
@ -45,7 +45,7 @@ static char const copyright[] =
|
|||||||
static char sccsid[] = "@(#)mv.c 8.2 (Berkeley) 4/2/94";
|
static char sccsid[] = "@(#)mv.c 8.2 (Berkeley) 4/2/94";
|
||||||
#endif
|
#endif
|
||||||
static const char rcsid[] =
|
static const char rcsid[] =
|
||||||
"$Id: mv.c,v 1.20 1998/06/09 03:39:38 imp Exp $";
|
"$Id: mv.c,v 1.21 1998/06/28 21:00:04 bde Exp $";
|
||||||
#endif /* not lint */
|
#endif /* not lint */
|
||||||
|
|
||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
@ -308,7 +308,7 @@ copy(from, to)
|
|||||||
{
|
{
|
||||||
int pid, status;
|
int pid, status;
|
||||||
|
|
||||||
if ((pid = vfork()) == 0) {
|
if ((pid = fork()) == 0) {
|
||||||
execl(_PATH_CP, "mv", "-PRp", from, to, NULL);
|
execl(_PATH_CP, "mv", "-PRp", from, to, NULL);
|
||||||
warn("%s", _PATH_CP);
|
warn("%s", _PATH_CP);
|
||||||
_exit(1);
|
_exit(1);
|
||||||
|
@ -36,7 +36,7 @@
|
|||||||
static const char sccsid[] = "@(#)pw_util.c 8.3 (Berkeley) 4/2/94";
|
static const char sccsid[] = "@(#)pw_util.c 8.3 (Berkeley) 4/2/94";
|
||||||
#endif
|
#endif
|
||||||
static const char rcsid[] =
|
static const char rcsid[] =
|
||||||
"$Id$";
|
"$Id: pw_util.c,v 1.9 1997/10/27 07:53:19 charnier Exp $";
|
||||||
#endif /* not lint */
|
#endif /* not lint */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -148,7 +148,7 @@ char *username;
|
|||||||
pid_t pid;
|
pid_t pid;
|
||||||
|
|
||||||
(void)fflush(stderr);
|
(void)fflush(stderr);
|
||||||
if (!(pid = vfork())) {
|
if (!(pid = fork())) {
|
||||||
if(!username) {
|
if(!username) {
|
||||||
warnx("rebuilding the database...");
|
warnx("rebuilding the database...");
|
||||||
execl(_PATH_PWD_MKDB, "pwd_mkdb", "-p", tempname, NULL);
|
execl(_PATH_PWD_MKDB, "pwd_mkdb", "-p", tempname, NULL);
|
||||||
@ -180,7 +180,7 @@ pw_edit(notsetuid)
|
|||||||
else
|
else
|
||||||
p = editor;
|
p = editor;
|
||||||
|
|
||||||
if (!(editpid = vfork())) {
|
if (!(editpid = fork())) {
|
||||||
if (notsetuid) {
|
if (notsetuid) {
|
||||||
(void)setgid(getgid());
|
(void)setgid(getgid());
|
||||||
(void)setuid(getuid());
|
(void)setuid(getuid());
|
||||||
|
@ -207,7 +207,7 @@ system(command)
|
|||||||
return(1);
|
return(1);
|
||||||
|
|
||||||
omask = sigblock(sigmask(SIGCHLD));
|
omask = sigblock(sigmask(SIGCHLD));
|
||||||
switch(pid = vfork()) {
|
switch(pid = fork()) {
|
||||||
case -1: /* error */
|
case -1: /* error */
|
||||||
err(1, "fork");
|
err(1, "fork");
|
||||||
case 0: /* child */
|
case 0: /* child */
|
||||||
|
@ -308,7 +308,7 @@ f_exec(plan, entry)
|
|||||||
/* make sure find output is interspersed correctly with subprocesses */
|
/* make sure find output is interspersed correctly with subprocesses */
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
|
|
||||||
switch (pid = vfork()) {
|
switch (pid = fork()) {
|
||||||
case -1:
|
case -1:
|
||||||
err(1, "fork");
|
err(1, "fork");
|
||||||
/* NOTREACHED */
|
/* NOTREACHED */
|
||||||
@ -414,7 +414,7 @@ f_execdir(plan, entry)
|
|||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
fflush(stderr);
|
fflush(stderr);
|
||||||
|
|
||||||
switch (pid = vfork()) {
|
switch (pid = fork()) {
|
||||||
case -1:
|
case -1:
|
||||||
err(1, "fork");
|
err(1, "fork");
|
||||||
/* NOTREACHED */
|
/* NOTREACHED */
|
||||||
|
@ -32,7 +32,7 @@
|
|||||||
static char sccsid[] = "@(#)update.c 1.2 91/03/11 Copyr 1986 Sun Micro";
|
static char sccsid[] = "@(#)update.c 1.2 91/03/11 Copyr 1986 Sun Micro";
|
||||||
#endif
|
#endif
|
||||||
static const char rcsid[] =
|
static const char rcsid[] =
|
||||||
"$Id: update.c,v 1.2 1997/07/29 06:54:16 charnier Exp $";
|
"$Id: update.c,v 1.3 1998/02/20 04:38:20 jb Exp $";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -167,11 +167,7 @@ _openchild(command, fto, ffrom)
|
|||||||
if (pipe(pdfrom) < 0) {
|
if (pipe(pdfrom) < 0) {
|
||||||
goto error2;
|
goto error2;
|
||||||
}
|
}
|
||||||
#ifdef VFORK
|
|
||||||
switch (pid = vfork()) {
|
|
||||||
#else
|
|
||||||
switch (pid = fork()) {
|
switch (pid = fork()) {
|
||||||
#endif
|
|
||||||
case -1:
|
case -1:
|
||||||
goto error3;
|
goto error3;
|
||||||
|
|
||||||
|
@ -42,7 +42,7 @@ static const char copyright[] =
|
|||||||
static char sccsid[] = "@(#)time.c 8.1 (Berkeley) 6/6/93";
|
static char sccsid[] = "@(#)time.c 8.1 (Berkeley) 6/6/93";
|
||||||
#endif
|
#endif
|
||||||
static const char rcsid[] =
|
static const char rcsid[] =
|
||||||
"$Id: time.c,v 1.10 1998/07/28 10:08:16 des Exp $";
|
"$Id: time.c,v 1.11 1998/08/24 10:16:59 cracauer Exp $";
|
||||||
#endif /* not lint */
|
#endif /* not lint */
|
||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
@ -106,7 +106,7 @@ main(argc, argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
gettimeofday(&before, (struct timezone *)NULL);
|
gettimeofday(&before, (struct timezone *)NULL);
|
||||||
switch(pid = vfork()) {
|
switch(pid = fork()) {
|
||||||
case -1: /* error */
|
case -1: /* error */
|
||||||
err(1, "time");
|
err(1, "time");
|
||||||
/* NOTREACHED */
|
/* NOTREACHED */
|
||||||
|
@ -722,9 +722,9 @@ char *argv[];
|
|||||||
|
|
||||||
child_died(); /* Start up signal handler */
|
child_died(); /* Start up signal handler */
|
||||||
shell_active = 1; /* We are running down below */
|
shell_active = 1; /* We are running down below */
|
||||||
if (shell_pid = vfork()) {
|
if (shell_pid = fork()) {
|
||||||
if (shell_pid == -1) {
|
if (shell_pid == -1) {
|
||||||
perror("vfork");
|
perror("fork");
|
||||||
(void) close(serversock);
|
(void) close(serversock);
|
||||||
} else {
|
} else {
|
||||||
state = UNCONNECTED;
|
state = UNCONNECTED;
|
||||||
|
@ -31,7 +31,7 @@
|
|||||||
|
|
||||||
#ifndef lint
|
#ifndef lint
|
||||||
static const char rcsid[] =
|
static const char rcsid[] =
|
||||||
"$Id$";
|
"$Id: setup.c,v 1.7 1998/01/05 07:30:25 charnier Exp $";
|
||||||
#endif /* not lint */
|
#endif /* not lint */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -56,7 +56,7 @@ static int evflags = 0;
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* setup_and_wait() is called to start a process. All it really does
|
* setup_and_wait() is called to start a process. All it really does
|
||||||
* is vfork(), set itself up to stop on exec or exit, and then exec
|
* is fork(), set itself up to stop on exec or exit, and then exec
|
||||||
* the given command. At that point, the child process stops, and
|
* the given command. At that point, the child process stops, and
|
||||||
* the parent can wake up and deal with it.
|
* the parent can wake up and deal with it.
|
||||||
*/
|
*/
|
||||||
@ -69,9 +69,9 @@ setup_and_wait(char *command[]) {
|
|||||||
int pid;
|
int pid;
|
||||||
int flags;
|
int flags;
|
||||||
|
|
||||||
pid = vfork();
|
pid = fork();
|
||||||
if (pid == -1) {
|
if (pid == -1) {
|
||||||
err(1, "vfork failed");
|
err(1, "fork failed");
|
||||||
}
|
}
|
||||||
if (pid == 0) { /* Child */
|
if (pid == 0) { /* Child */
|
||||||
int mask = S_EXEC | S_EXIT;
|
int mask = S_EXEC | S_EXIT;
|
||||||
|
@ -42,7 +42,7 @@ static const char copyright[] =
|
|||||||
static char sccsid[] = "@(#)from: vacation.c 8.2 (Berkeley) 1/26/94";
|
static char sccsid[] = "@(#)from: vacation.c 8.2 (Berkeley) 1/26/94";
|
||||||
#endif
|
#endif
|
||||||
static const char rcsid[] =
|
static const char rcsid[] =
|
||||||
"$Id$";
|
"$Id: vacation.c,v 1.12 1997/11/03 07:51:05 charnier Exp $";
|
||||||
#endif /* not lint */
|
#endif /* not lint */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -417,7 +417,7 @@ sendmessage(myname)
|
|||||||
syslog(LOG_ERR, "vacation: pipe: %s", strerror(errno));
|
syslog(LOG_ERR, "vacation: pipe: %s", strerror(errno));
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
i = vfork();
|
i = fork();
|
||||||
if (i < 0) {
|
if (i < 0) {
|
||||||
syslog(LOG_ERR, "vacation: fork: %s", strerror(errno));
|
syslog(LOG_ERR, "vacation: fork: %s", strerror(errno));
|
||||||
exit(1);
|
exit(1);
|
||||||
|
@ -45,7 +45,7 @@ static const char copyright[] =
|
|||||||
static char sccsid[] = "@(#)xargs.c 8.1 (Berkeley) 6/6/93";
|
static char sccsid[] = "@(#)xargs.c 8.1 (Berkeley) 6/6/93";
|
||||||
#endif
|
#endif
|
||||||
static const char rcsid[] =
|
static const char rcsid[] =
|
||||||
"$Id: xargs.c,v 1.5 1997/08/27 06:26:23 charnier Exp $";
|
"$Id: xargs.c,v 1.6 1998/06/17 12:58:43 jkoshy Exp $";
|
||||||
#endif /* not lint */
|
#endif /* not lint */
|
||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
@ -287,9 +287,9 @@ run(argv)
|
|||||||
(void)fflush(stderr);
|
(void)fflush(stderr);
|
||||||
}
|
}
|
||||||
noinvoke = 0;
|
noinvoke = 0;
|
||||||
switch(pid = vfork()) {
|
switch(pid = fork()) {
|
||||||
case -1:
|
case -1:
|
||||||
err(1, "vfork");
|
err(1, "fork");
|
||||||
case 0:
|
case 0:
|
||||||
execvp(argv[0], argv);
|
execvp(argv[0], argv);
|
||||||
warn("%s", argv[0]);
|
warn("%s", argv[0]);
|
||||||
|
@ -42,7 +42,7 @@ static const char copyright[] =
|
|||||||
static char sccsid[] = "From: @(#)xinstall.c 8.1 (Berkeley) 7/21/93";
|
static char sccsid[] = "From: @(#)xinstall.c 8.1 (Berkeley) 7/21/93";
|
||||||
#endif
|
#endif
|
||||||
static const char rcsid[] =
|
static const char rcsid[] =
|
||||||
"$Id: xinstall.c,v 1.31 1998/01/20 13:52:32 bde Exp $";
|
"$Id: xinstall.c,v 1.32 1998/06/02 12:00:07 peter Exp $";
|
||||||
#endif /* not lint */
|
#endif /* not lint */
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
@ -645,7 +645,7 @@ strip(to_name)
|
|||||||
{
|
{
|
||||||
int serrno, status;
|
int serrno, status;
|
||||||
|
|
||||||
switch (vfork()) {
|
switch (fork()) {
|
||||||
case -1:
|
case -1:
|
||||||
serrno = errno;
|
serrno = errno;
|
||||||
(void)unlink(to_name);
|
(void)unlink(to_name);
|
||||||
|
@ -36,7 +36,7 @@
|
|||||||
static const char sccsid[] = "@(#)pw_util.c 8.3 (Berkeley) 4/2/94";
|
static const char sccsid[] = "@(#)pw_util.c 8.3 (Berkeley) 4/2/94";
|
||||||
#endif
|
#endif
|
||||||
static const char rcsid[] =
|
static const char rcsid[] =
|
||||||
"$Id$";
|
"$Id: pw_util.c,v 1.9 1997/10/27 07:53:19 charnier Exp $";
|
||||||
#endif /* not lint */
|
#endif /* not lint */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -148,7 +148,7 @@ char *username;
|
|||||||
pid_t pid;
|
pid_t pid;
|
||||||
|
|
||||||
(void)fflush(stderr);
|
(void)fflush(stderr);
|
||||||
if (!(pid = vfork())) {
|
if (!(pid = fork())) {
|
||||||
if(!username) {
|
if(!username) {
|
||||||
warnx("rebuilding the database...");
|
warnx("rebuilding the database...");
|
||||||
execl(_PATH_PWD_MKDB, "pwd_mkdb", "-p", tempname, NULL);
|
execl(_PATH_PWD_MKDB, "pwd_mkdb", "-p", tempname, NULL);
|
||||||
@ -180,7 +180,7 @@ pw_edit(notsetuid)
|
|||||||
else
|
else
|
||||||
p = editor;
|
p = editor;
|
||||||
|
|
||||||
if (!(editpid = vfork())) {
|
if (!(editpid = fork())) {
|
||||||
if (notsetuid) {
|
if (notsetuid) {
|
||||||
(void)setgid(getgid());
|
(void)setgid(getgid());
|
||||||
(void)setuid(getuid());
|
(void)setuid(getuid());
|
||||||
|
Loading…
Reference in New Issue
Block a user