bug-bash
[Top][All Lists]
Advanced

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

Re: [bash-bug] Crash on completion


From: Dr. Werner Fink
Subject: Re: [bash-bug] Crash on completion
Date: Tue, 9 Mar 2010 15:16:03 +0100
User-agent: Mutt/1.5.20 (2009-06-14)

On Tue, Mar 09, 2010 at 02:51:18PM +0100, Roman Rakus wrote:
>
> The bash segfaults on the line `while (val =
> glob_matches[local_index++])', because glob_matches is pointer to
> NULL. I have add the check for this null. But this is most likely
> not the right patch.
> RR

> diff -up bash-4.1/bashline.c.crash bash-4.1/bashline.c
> --- bash-4.1/bashline.c.crash 2010-03-09 14:26:06.000000000 +0100
> +++ bash-4.1/bashline.c       2010-03-09 14:46:10.000000000 +0100
> @@ -1700,7 +1700,8 @@ globword:
>           return ((char *)NULL);
>       }
>  
> -      while (val = glob_matches[local_index++])
> +      /* make sure glob_matches is not NULL */
> +      while (glob_matches && (val = glob_matches[local_index++]))
>          {
>         if (executable_or_directory (val))
>           {

Maybe something like:

--- bashline.c
+++ bashline.c  2010-03-09 14:11:27.612626475 +0000
@@ -1700,6 +1700,13 @@ globword:
            return ((char *)NULL);
        }
 
+      if (GLOB_FAILED (glob_matches) || glob_matches == 0)
+       {
+         glob_ignore_case = old_glob_ignore_case;
+         glob_matches = (char **)NULL;
+         return ((char *)NULL);
+       }
+
       while (val = glob_matches[local_index++])
         {
          if (executable_or_directory (val))

as this also include the check found for (state == 0) case
a few lines above the affected line?

     Werner

-- 
  "Having a smoking section in a restaurant is like having
          a peeing section in a swimming pool." -- Edward Burr




reply via email to

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