bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Reproducible SIGSEGV in bash 4.2 caused by alias.


From: Piotr Grzybowski
Subject: Re: Reproducible SIGSEGV in bash 4.2 caused by alias.
Date: Thu, 10 Oct 2013 17:44:40 +0200

helo all!

I agree, it is abit off a bug. That should fix it (coding and writting from
my mobile, so sorry for bad style ;-)) :

cheers,
pg

---
builtins/alias.def | 7 +++++++
1 file changed, 7 insertions(+)

diff --git a/builtins/alias.def b/builtins/alias.def
index d760ceb..7a7b510 100644
--- a/builtins/alias.def
+++ b/builtins/alias.def
@@ -67,6 +67,9 @@ static void print_alias __P((alias_t *, int));

extern int posixly_correct;

+#define MAX_RECURSIONS 255
+static int recursion_count=0;
+
/* Hack the alias command in a Korn shell way. */
int
alias_builtin (list)
@@ -76,6 +79,10 @@ alias_builtin (list)
   alias_t **alias_list, *t;
   char *name, *value;

+  if (recursion_count>MAX_RECURSIONS) {
+   return EXECUTION_FAILURE;
+  }
+  recursion_count++;
   dflags = posixly_correct ? 0 : AL_REUSABLE;
   pflag = 0;
   reset_internal_getopt ();
-- 
1.8.4


On Oct 10, 2013 11:50 AM, "Oliver J. Morais" <address@hidden>
wrote:
>
> [Thu, Oct 10, 2013 at 11:38:47AM +0200] Andreas Schwab
> > "Oliver J. Morais" <address@hidden> writes:
> > > Playing around with aliases, I stumbled over the following:
> > > $ alias alias="eval alias"
> > > $ alias foo=bar
> > You have created an infinite recursion, same as f() { f; }; f.
>
> Sure, but I think bash should not just crash, zsh for example catches
> this glitch:
>
> % alias alias="eval alias"
> % alias foo=bar
> zsh: job table full or recursion limit exceeded
>
> I know, bash != zsh and the eval-alias-foo is a silly thing to do,
> but crashing is a bug :)
>


reply via email to

[Prev in Thread] Current Thread [Next in Thread]