[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Bash crashes with segfault on certain script constructs
From: |
Chet Ramey |
Subject: |
Re: Bash crashes with segfault on certain script constructs |
Date: |
Mon, 2 Aug 2004 10:13:41 -0400 |
> Machine Type: i686-pc-linux-gnu
>
> Bash Version: 3.0
> Patch Level: 0
> Release Status: release
>
> Description:
> Bash crashes on Execution of FireHOL 196, which is a shell script.
> No shell script should be able to crash a shell.
>
> Repeat-By:
>
> The following script triggers the segfault.
> This was found by Costa Tsaousis the author of FireHOL.
> He wrotes:
>
> "I think I have found the bug. The script bellow crashes at the
> third echo (UNSET). It seems to be a problem of the "unset" BASH
> function when erasing arrays. It leaves something behind so that if
> the array just unset is referenced, it produces a segmentation fault.
> According to the documentation the first and the third expansions
> should be exactly the same."
>
> -----------------------------------------------------------
> !/bin/sh
> rule() {
> echo "1. BEFORE SET:" "${s[@]}"
>
> local -a s=()
> echo "2. SET TO EMPTY:" "${s[@]}"
> unset s
> echo "3. UNSET:" "${s[@]}"
> }
>
> rule
Try this patch.
*** ../bash-3.0/arrayfunc.c Fri Dec 19 00:03:09 2003
--- arrayfunc.c Sun Aug 1 20:43:00 2004
***************
*** 612,616 ****
free (t);
! return var;
}
--- 612,616 ----
free (t);
! return (var == 0 || invisible_p (var)) ? (SHELL_VAR *)0 : var;
}
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
( ``Discere est Dolere'' -- chet )
Live...Laugh...Love
Chet Ramey, ITS, CWRU chet@po.cwru.edu http://tiswww.tis.cwru.edu/~chet/