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

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