From 89615af349056e3a34788a8b6c0842100389d2b8 Mon Sep 17 00:00:00 2001 From: Zdenek Kabelac Date: Fri, 4 Apr 2014 21:15:17 +0200 Subject: [PATCH] exec_cmd: skip fork when argv[0] is null Skip whole fork code path if the arg would be null. --- lib/misc/lvm-exec.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/misc/lvm-exec.c b/lib/misc/lvm-exec.c index e862bad53..273e7f90c 100644 --- a/lib/misc/lvm-exec.c +++ b/lib/misc/lvm-exec.c @@ -53,6 +53,11 @@ int exec_cmd(struct cmd_context *cmd, const char *const argv[], int status; char buf[PATH_MAX * 2]; + if (!argv[0]) { + log_error(INTERNAL_ERROR "Missing command."); + return 0; + } + if (rstatus) *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 */ /* destroy_toolcontext(cmd); */ /* FIXME Use execve directly */ - if (argv[0]) - execvp(argv[0], (char **) argv); + execvp(argv[0], (char **) argv); log_sys_error("execvp", argv[0]); _exit(errno); }