Blame SOURCES/fstrm-0.6.1-Invalid-dereference.patch

81dd04
From d6149aaad2a72a8f000283015f6e381bb2821ee2 Mon Sep 17 00:00:00 2001
81dd04
From: =?UTF-8?q?Petr=20Men=C5=A1=C3=ADk?= <pemensik@redhat.com>
81dd04
Date: Thu, 7 Jan 2021 16:08:40 +0100
81dd04
Subject: [PATCH 1/3] Invalid dereference
81dd04
81dd04
libmy/argv.c:3212: var_deref_model: Passing null pointer "queue_list" to "do_list", which dereferences it
81dd04
libmy/argv.c:3204: var_deref_model: Passing null pointer "queue_list" to "do_list", which dereferences it.
81dd04
81dd04
Workaround to possibility no arguments is received
81dd04
81dd04
Usually at least one arg is always passed in argv - program name. Do not
81dd04
dereference null queue_list in unlikely case no parameter in argv.
81dd04
---
81dd04
 libmy/argv.c | 45 +++++++++++++++++++++++----------------------
81dd04
 1 file changed, 23 insertions(+), 22 deletions(-)
81dd04
81dd04
diff --git a/libmy/argv.c b/libmy/argv.c
81dd04
index 6c64906..c3aadfe 100644
81dd04
--- a/libmy/argv.c
81dd04
+++ b/libmy/argv.c
81dd04
@@ -3197,28 +3197,29 @@ int	argv_process_no_env(argv_t *args, const int arg_n, char **argv)
81dd04
     }
81dd04
     queue_head = 0;
81dd04
     queue_tail = 0;
81dd04
-  }
81dd04
-  
81dd04
-  /* do the env args before? */
81dd04
-  if (argv_process_env_b && (! argv_env_after_b) && env_vect_p != NULL) {
81dd04
-    do_list(args, env_n, env_vect_p, queue_list, &queue_head, &queue_tail,
81dd04
-	    &okay_b);
81dd04
-    free(env_vect_p);
81dd04
-    free(environ_p);
81dd04
-    env_vect_p = NULL;
81dd04
-  }
81dd04
-  
81dd04
-  /* do the external args */
81dd04
-  do_list(args, arg_n - 1, argv + 1, queue_list, &queue_head, &queue_tail,
81dd04
-	  &okay_b);
81dd04
+
81dd04
+    /* do the env args before? */
81dd04
+    if (argv_process_env_b && (! argv_env_after_b) && env_vect_p != NULL) {
81dd04
+      do_list(args, env_n, env_vect_p, queue_list, &queue_head, &queue_tail,
81dd04
+	      &okay_b);
81dd04
+      free(env_vect_p);
81dd04
+      free(environ_p);
81dd04
+      env_vect_p = NULL;
81dd04
+    }
81dd04
+
81dd04
+    /* do the external args */
81dd04
+    if (arg_n > 0)
81dd04
+      do_list(args, arg_n - 1, argv + 1, queue_list, &queue_head, &queue_tail,
81dd04
+	      &okay_b);
81dd04
   
81dd04
-  /* DO the env args after? */
81dd04
-  if (argv_process_env_b && argv_env_after_b && env_vect_p != NULL) {
81dd04
-    do_list(args, env_n, env_vect_p, queue_list, &queue_head, &queue_tail,
81dd04
-	    &okay_b);
81dd04
-    free(env_vect_p);
81dd04
-    free(environ_p);
81dd04
-    env_vect_p = NULL;
81dd04
+    /* DO the env args after? */
81dd04
+    if (argv_process_env_b && argv_env_after_b && env_vect_p != NULL) {
81dd04
+      do_list(args, env_n, env_vect_p, queue_list, &queue_head, &queue_tail,
81dd04
+	      &okay_b);
81dd04
+      free(env_vect_p);
81dd04
+      free(environ_p);
81dd04
+      env_vect_p = NULL;
81dd04
+    }
81dd04
   }
81dd04
   
81dd04
   /* make sure the XOR and MAND args and argument-options are okay */
81dd04
@@ -3233,7 +3234,7 @@ int	argv_process_no_env(argv_t *args, const int arg_n, char **argv)
81dd04
   }
81dd04
   
81dd04
   /* if we allocated the space then free it */
81dd04
-  if (arg_n > 0) {
81dd04
+  if (queue_list) {
81dd04
     free(queue_list);
81dd04
   }
81dd04
   
81dd04
-- 
81dd04
2.26.3
81dd04