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

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