svashisht / rpms / bash

Forked from rpms/bash 4 years ago
Clone

Blame SOURCES/bash-4.4-cve-2019-9924.patch

ff19ae
diff --git a/variables.c b/variables.c
ff19ae
--- a/variables.c
ff19ae
+++ b/variables.c
ff19ae
@@ -1578,6 +1578,28 @@ assign_hashcmd (self, value, ind, key)
ff19ae
      arrayind_t ind;
ff19ae
      char *key;
ff19ae
 {
ff19ae
+#if defined (RESTRICTED_SHELL)
ff19ae
+  char *full_path;
ff19ae
+
ff19ae
+  if (restricted)
ff19ae
+    {
ff19ae
+      if (strchr (value, '/'))
ff19ae
+	{
ff19ae
+	  sh_restricted (value);
ff19ae
+	  return (SHELL_VAR *)NULL;
ff19ae
+	}
ff19ae
+      /* If we are changing the hash table in a restricted shell, make sure the
ff19ae
+	 target pathname can be found using a $PATH search. */
ff19ae
+      full_path = find_user_command (value);
ff19ae
+      if (full_path == 0 || *full_path == 0 || executable_file (full_path) == 0)
ff19ae
+	{
ff19ae
+	  sh_notfound (value);
ff19ae
+	  free (full_path);
ff19ae
+	  return ((SHELL_VAR *)NULL);
ff19ae
+	}
ff19ae
+      free (full_path);
ff19ae
+    }
ff19ae
+#endif
ff19ae
   phash_insert (key, value, 0, 0);
ff19ae
   return (build_hashcmd (self));
ff19ae
 }