]> Kevux Git Server - fll/commitdiff
Security: Add additional checks against the parameters in fll_execute_program().
authorKevin Day <kevin@kevux.org>
Tue, 8 Aug 2023 01:21:06 +0000 (20:21 -0500)
committerKevin Day <kevin@kevux.org>
Tue, 8 Aug 2023 01:21:06 +0000 (20:21 -0500)
level_2/fll_execute/c/execute.c

index 192e3b4df672659b7f9be72661ede8d4b429c105..d77ebde97b5baf675573ddfef4f9c0d4b8f80ec3 100644 (file)
@@ -278,13 +278,25 @@ extern "C" {
     f_string_t fixed_arguments[arguments.used + 2];
     f_string_static_t program_name = f_string_static_t_initialize;
 
-    const f_string_t last_slash = (f_string_t) strrchr((program.used ? program.string : arguments.array[0].string), (char) f_path_separator_s.string[0]);
+    const f_string_t last_slash = (f_string_t) strrchr(
+      (program.used
+        ? program.string
+        : arguments.used && arguments.array[0].used
+          ? arguments.array[0].string
+          : 0
+      ),
+      (char) f_path_separator_s.string[0]
+    );
 
     if (last_slash) {
       program_name.used = strnlen((last_slash + 1), F_path_length_max_d);
     }
     else {
-      program_name.used = program.used ? program.used : arguments.array[0].used;
+      program_name.used = program.used
+        ? program.used
+        : arguments.used && arguments.array[0].used
+          ? arguments.array[0].used
+          : 0;
     }
 
     f_char_t program_name_string[program_name.used + 1];