diff options
| author | Eric Koegel <eric.koegel@gmail.com> | 2017-05-04 12:02:47 +0300 |
|---|---|---|
| committer | Eric Koegel <eric.koegel@gmail.com> | 2017-05-04 12:02:57 +0300 |
| commit | 54552ec21b7823e517df1c5be0dd1cfeb01f6eed (patch) | |
| tree | 4660a1b20edbc9b3082c872b1fe3c23ca0e51c8f /tools | |
| parent | bfdd3535a13dbb38a9ead0c98efcbceced45fcd7 (diff) | |
| download | ConsoleKit2-54552ec21b7823e517df1c5be0dd1cfeb01f6eed.tar.gz | |
fix coverity cid 64730 Use of untrusted string value
Diffstat (limited to 'tools')
| -rw-r--r-- | tools/ck-launch-session.c | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/tools/ck-launch-session.c b/tools/ck-launch-session.c index a102998..09f0b5d 100644 --- a/tools/ck-launch-session.c +++ b/tools/ck-launch-session.c @@ -44,9 +44,27 @@ #include <unistd.h> #include <libintl.h> #include <locale.h> +#include <glib.h> +#include <glib/gstdio.h> #include "ck-connector.h" + + +static gboolean +check_shell (const gchar *shell) +{ + if (shell == NULL || *shell == '\0') { + return FALSE; + } + + if (!g_file_test (shell, G_FILE_TEST_IS_EXECUTABLE)) { + return FALSE; + } + + return TRUE; +} + int main (int argc, char **argv) { @@ -99,7 +117,7 @@ main (int argc, char **argv) execvp (argv[1], argv + 1); } else { shell = getenv ("SHELL"); - if (shell == NULL) { + if (!check_shell (shell)) { shell = _PATH_BSHELL; } execlp (shell, shell, NULL); |
