1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-21 13:34:40 +03:00

exec_cmd: skip fork when argv[0] is null

Skip whole fork code path if the arg would be null.
This commit is contained in:
Zdenek Kabelac 2014-04-04 21:15:17 +02:00
parent 6190ded5f1
commit 89615af349

View File

@ -53,6 +53,11 @@ int exec_cmd(struct cmd_context *cmd, const char *const argv[],
int status; int status;
char buf[PATH_MAX * 2]; char buf[PATH_MAX * 2];
if (!argv[0]) {
log_error(INTERNAL_ERROR "Missing command.");
return 0;
}
if (rstatus) if (rstatus)
*rstatus = -1; *rstatus = -1;
@ -74,8 +79,7 @@ int exec_cmd(struct cmd_context *cmd, const char *const argv[],
/* FIXME Fix effect of reset_locking on cache then include this */ /* FIXME Fix effect of reset_locking on cache then include this */
/* destroy_toolcontext(cmd); */ /* destroy_toolcontext(cmd); */
/* FIXME Use execve directly */ /* FIXME Use execve directly */
if (argv[0]) execvp(argv[0], (char **) argv);
execvp(argv[0], (char **) argv);
log_sys_error("execvp", argv[0]); log_sys_error("execvp", argv[0]);
_exit(errno); _exit(errno);
} }