summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorEric Koegel <eric.koegel@gmail.com>2017-05-04 12:02:47 +0300
committerEric Koegel <eric.koegel@gmail.com>2017-05-04 12:02:57 +0300
commit54552ec21b7823e517df1c5be0dd1cfeb01f6eed (patch)
tree4660a1b20edbc9b3082c872b1fe3c23ca0e51c8f /tools
parentbfdd3535a13dbb38a9ead0c98efcbceced45fcd7 (diff)
downloadConsoleKit2-54552ec21b7823e517df1c5be0dd1cfeb01f6eed.tar.gz
fix coverity cid 64730 Use of untrusted string value
Diffstat (limited to 'tools')
-rw-r--r--tools/ck-launch-session.c20
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);