aboutsummaryrefslogtreecommitdiffstats
path: root/builtins/pushd.c
diff options
context:
space:
mode:
Diffstat (limited to 'builtins/pushd.c')
-rw-r--r--builtins/pushd.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/builtins/pushd.c b/builtins/pushd.c
index 0185450..cd57401 100644
--- a/builtins/pushd.c
+++ b/builtins/pushd.c
@@ -255,7 +255,7 @@ popd_builtin (list)
break;
}
- if (which > directory_list_offset || (directory_list_offset == 0 && which == 0))
+ if (which > directory_list_offset || (which < -directory_list_offset) || (directory_list_offset == 0 && which == 0))
{
pushd_error (directory_list_offset, which_word ? which_word : "");
return (EXECUTION_FAILURE);
@@ -277,6 +277,11 @@ popd_builtin (list)
remove that directory from the list and shift the remainder
of the list into place. */
i = (direction == '+') ? directory_list_offset - which : which;
+ if (i < 0 || i > directory_list_offset)
+ {
+ pushd_error (directory_list_offset, which_word ? which_word : "");
+ return (EXECUTION_FAILURE);
+ }
free (pushd_directory_list[i]);
directory_list_offset--;