diff options
author | Simon McVittie <smcv@collabora.com> | 2019-06-10 08:38:39 +0100 |
---|---|---|
committer | Atomic Bot <atomic-devel@projectatomic.io> | 2019-06-12 06:51:53 +0000 |
commit | 8deef94f9d6ed4575c6c69b505e4528099e1c7e2 (patch) | |
tree | 6cf2042a578baf3f5154c1508c0ead2f014eedc4 /icon-validator | |
parent | 0bb64e9a8833e3158328c99391de2b9930cf6964 (diff) | |
download | flatpak-8deef94f9d6ed4575c6c69b505e4528099e1c7e2.tar.gz |
icon-validator: Remove remnants of GSpawn error handling
Now that validate-icon uses execvpe(), status and error were never set,
so rerun_in_sandbox() would have crashed while dereferencing a NULL
error if execvpe() failed. This is reproducible with, for example:
FLATPAK_BWRAP=/bin/nope flatpak-validate-icon --sandbox 48 48 /path/to/icon
execvpe() does not return on success (the process image is replaced),
and sets errno on failure, so behave accordingly.
Also print the error message to stderr, even if G_MESSAGES_DEBUG is not
set, since it's our only opportunity to indicate to a caller what has
gone wrong.
Signed-off-by: Simon McVittie <smcv@collabora.com>
Closes: #2950
Approved by: alexlarsson
Diffstat (limited to 'icon-validator')
-rw-r--r-- | icon-validator/validate-icon.c | 21 |
1 files changed, 5 insertions, 16 deletions
diff --git a/icon-validator/validate-icon.c b/icon-validator/validate-icon.c index 7658f128..9e885070 100644 --- a/icon-validator/validate-icon.c +++ b/icon-validator/validate-icon.c @@ -20,6 +20,7 @@ #include <gdk-pixbuf/gdk-pixbuf.h> #include <glib/gstdio.h> +#include <errno.h> #include <unistd.h> static int @@ -138,9 +139,6 @@ rerun_in_sandbox (const char *arg_width, const char * const usrmerged_dirs[] = { "bin", "lib64", "lib", "sbin" }; int i; g_autoptr(GPtrArray) args = g_ptr_array_new_with_free_func (g_free); - g_autofree char *err = NULL; - int status; - g_autoptr(GError) error = NULL; char validate_icon[PATH_MAX + 1]; ssize_t symlink_size; @@ -211,19 +209,10 @@ rerun_in_sandbox (const char *arg_width, g_debug ("Icon validation: Spawning %s", cmdline); } - if (execvpe (flatpak_get_bwrap (), (char **) args->pdata, NULL) == -1) - { - g_debug ("Icon validation: %s", error->message); - return 1; - } - - if (!g_spawn_check_exit_status (status, NULL)) - { - g_debug ("Icon validation: %s", err); - return 1; - } - - return 0; + execvpe (flatpak_get_bwrap (), (char **) args->pdata, NULL); + /* If we get here, then execvpe() failed. */ + g_printerr ("Icon validation: execvpe %s: %s\n", flatpak_get_bwrap (), g_strerror (errno)); + return 1; } static gboolean opt_sandbox; |