From dac709ef1d707ce5ec5fd8ea10455481520ea5b9 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Wed, 14 Jan 2015 22:37:54 -0500 Subject: [PATCH] Handle exec error correctly exec(1) states that exec will only return in case of an error, and the return value is -1. Therefore, if (!execv(...)) doesn't make sense. --- xdg-app-builtins-run.c | 2 +- xdg-app-helper.c | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/xdg-app-builtins-run.c b/xdg-app-builtins-run.c index 734d05da..4f1e9dc8 100644 --- a/xdg-app-builtins-run.c +++ b/xdg-app-builtins-run.c @@ -289,7 +289,7 @@ xdg_app_builtin_run (int argc, char **argv, GCancellable *cancellable, GError ** g_unsetenv ("LD_LIBRARY_PATH"); g_setenv ("PATH", "/self/bin:/usr/bin", TRUE); - if (!execv (HELPER, (char **)argv_array->pdata)) + if (execv (HELPER, (char **)argv_array->pdata) == -1) { g_set_error (error, G_IO_ERROR, g_io_error_from_errno (errno), "Unable to start app"); goto out; diff --git a/xdg-app-helper.c b/xdg-app-helper.c index 2b1634b3..6f733c76 100644 --- a/xdg-app-helper.c +++ b/xdg-app-helper.c @@ -1156,5 +1156,8 @@ main (int argc, __debug__(("launch executable %s\n", args[0])); - return execvp (args[0], args); + if (execvp (args[0], args) == -1) + die_with_error ("execvp %s", args[0]); + + return 0; }