bash segfaults on startup when TERM=eterm* and EMACS is unset

View: New views
3 Messages — Rating Filter:   Alert me  

bash segfaults on startup when TERM=eterm* and EMACS is unset

by Roman Rakus :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

$subject can be triggered easily by setting TERM to eterm (with unset
EMACS). Originally this segfault was caused by running emacs and within
emacs try to ssh on localhost.

Reproducer 1)
[rrakus@dhcp-lab-170 ~]$ bash
[rrakus@dhcp-lab-170 ~]$ exit
[rrakus@dhcp-lab-170 ~]$ env TERM=eterm bash
Segmentation fault
[rrakus@dhcp-lab-170 ~]$ env TERM=eterm-sldkhflsad bash
Segmentation fault

Reproducer 2)
1. Start emacs on some machine.
2. M-x ansi-term
3. 'echo $TERM' to verify that it's eterm-color or eterm
4. 'ssh F11HOST' (where F11HOST is a machine with bash 4.0 installed
and set as your shell)
5. Observe the connection being closed instead of receiving a prompt.

Following patch hinders segfault:

--- bash-4.0/shell.c.orig 2009-10-15 15:57:56.000000000 -0400
+++ bash-4.0/shell.c 2009-10-15 15:58:28.000000000 -0400
@@ -572,7 +572,7 @@

        /* running_under_emacs == 2 for `eterm' */
        running_under_emacs = (emacs != 0) || (term&&  STREQN (term, "emacs", 5));
-      running_under_emacs += term&&  STREQN (term, "eterm", 5)&&  strstr (emacs, "term");
+      running_under_emacs += term&&  STREQN (term, "eterm", 5)&&  (emacs != 0)&&  strstr (emacs, "term");

        if (running_under_emacs)
  gnu_error_format = 1;


RR



Re: bash segfaults on startup when TERM=eterm* and EMACS is unset

by Roman Rakus :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On 10/29/2009 10:35 AM, Roman Rakus wrote:

> $subject can be triggered easily by setting TERM to eterm (with unset
> EMACS). Originally this segfault was caused by running emacs and
> within emacs try to ssh on localhost.
>
> Reproducer 1)
> [rrakus@dhcp-lab-170 ~]$ bash
> [rrakus@dhcp-lab-170 ~]$ exit
> [rrakus@dhcp-lab-170 ~]$ env TERM=eterm bash
> Segmentation fault
> [rrakus@dhcp-lab-170 ~]$ env TERM=eterm-sldkhflsad bash
> Segmentation fault
>
> Reproducer 2)
> 1. Start emacs on some machine.
> 2. M-x ansi-term
> 3. 'echo $TERM' to verify that it's eterm-color or eterm
> 4. 'ssh F11HOST' (where F11HOST is a machine with bash 4.0 installed
> and set as your shell)
> 5. Observe the connection being closed instead of receiving a prompt.
>
> Following patch hinders segfault:
>
> --- bash-4.0/shell.c.orig    2009-10-15 15:57:56.000000000 -0400
> +++ bash-4.0/shell.c    2009-10-15 15:58:28.000000000 -0400
> @@ -572,7 +572,7 @@
>
>        /* running_under_emacs == 2 for `eterm' */
>        running_under_emacs = (emacs != 0) || (term&&  STREQN (term,
> "emacs", 5));
> -      running_under_emacs += term&&  STREQN (term, "eterm", 5)&&  
> strstr (emacs, "term");
> +      running_under_emacs += term&&  STREQN (term, "eterm", 5)&&  
> (emacs != 0)&&  strstr (emacs, "term");
>
>        if (running_under_emacs)
>      gnu_error_format = 1;
>
>
> RR
>
>
Any updates/comments here?
RR



Re: bash segfaults on startup when TERM=eterm* and EMACS is unset

by Chet Ramey :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

> On 10/29/2009 10:35 AM, Roman Rakus wrote:
> > $subject can be triggered easily by setting TERM to eterm (with unset
> > EMACS). Originally this segfault was caused by running emacs and
> > within emacs try to ssh on localhost.
> >
> >
> Any updates/comments here?

This will be fixed in the next version of bash.  The supplied patch is
essentially correct.

Chet

--
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRU    chet@...    http://cnswww.cns.cwru.edu/~chet/