nalika / rpms / bash

Forked from rpms/bash 2 years ago
Clone
462fb2
diff --git a/builtins/pushd.def b/builtins/pushd.def
462fb2
index 05b7529..4eb0132 100644
462fb2
--- a/builtins/pushd.def
462fb2
+++ b/builtins/pushd.def
462fb2
@@ -353,7 +353,7 @@ popd_builtin (list)
462fb2
 	break;
462fb2
     }
462fb2
 
462fb2
-  if (which > directory_list_offset || (directory_list_offset == 0 && which == 0))
462fb2
+  if (which > directory_list_offset || (which < -directory_list_offset) || (directory_list_offset == 0 && which == 0))
462fb2
     {
462fb2
       pushd_error (directory_list_offset, which_word ? which_word : "");
462fb2
       return (EXECUTION_FAILURE);
462fb2
@@ -375,6 +375,11 @@ popd_builtin (list)
462fb2
 	 remove that directory from the list and shift the remainder
462fb2
 	 of the list into place. */
462fb2
       i = (direction == '+') ? directory_list_offset - which : which;
462fb2
+      if (i < 0 || i > directory_list_offset)
462fb2
+	{
462fb2
+	  pushd_error (directory_list_offset, which_word ? which_word : "");
462fb2
+	  return (EXECUTION_FAILURE);
462fb2
+	}
462fb2
       free (pushd_directory_list[i]);
462fb2
       directory_list_offset--;
462fb2
 
462fb2
-- 
462fb2
2.9.3
462fb2