]> ruderich.org/simon Gitweb - coloredstderr/coloredstderr.git/commitdiff
Prevent crash in execve() if env is NULL master
authorSimon Ruderich <simon@ruderich.org>
Thu, 1 Feb 2018 20:40:02 +0000 (21:40 +0100)
committerSimon Ruderich <simon@ruderich.org>
Thu, 1 Feb 2018 20:40:02 +0000 (21:40 +0100)
src/coloredstderr.c

index d2700710e7ca9ea185152c025e169f68ba830cae..9161fc34f3deff694dba52eb07923fdde19bc4c2 100644 (file)
@@ -554,6 +554,11 @@ pid_t vfork(void) {
 HOOK_FUNC_DEF3(int, execve, char const *, filename, char * const *, argv, char * const *, env) {
     DLSYM_FUNCTION(real_execve, "execve");
 
+    char * const fake_env[] = {NULL};
+    if (env == NULL) {
+        env = fake_env;
+    }
+
     /* Count environment variables. */
     size_t count = 0;
     char * const *x = env;