mirror of
https://github.com/troglobit/finit.git
synced 2026-10-01 13:33:09 +07:00
Fix possible NULL deref in run() error handling
When we added support for using popen() to run(), to log the output, we forgot to update the error handling path. Found by Coverity Scan. Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
+4
-2
@@ -97,12 +97,14 @@ static int do_redirect(void)
|
||||
*/
|
||||
int run(char *cmd, char *log)
|
||||
{
|
||||
char *args[NUM_ARGS + 1] = { 0 };
|
||||
int status, result, i = 0;
|
||||
char *args[NUM_ARGS + 1], *arg;
|
||||
char *backup = NULL;
|
||||
pid_t pid;
|
||||
|
||||
if (!log) {
|
||||
char *arg;
|
||||
|
||||
/* We must create a copy that is possible to modify. */
|
||||
backup = arg = strdup(cmd);
|
||||
if (!arg)
|
||||
@@ -164,7 +166,7 @@ int run(char *cmd, char *log)
|
||||
|
||||
_exit(rc);
|
||||
} else if (-1 == pid) {
|
||||
_pe("%s", args[0]);
|
||||
_pe("%s", !log ? args[0] : cmd);
|
||||
if (backup)
|
||||
free(backup);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user