Bug 126399 - bash segfaults on substitution in multibyte environments
Summary: bash segfaults on substitution in multibyte environments
Keywords:
Status: CLOSED RAWHIDE
Alias: None
Product: Fedora
Classification: Fedora
Component: bash
Version: 2
Hardware: i386
OS: Linux
medium
high
Target Milestone: ---
Assignee: Tim Waugh
QA Contact: Ben Levenson
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2004-06-21 08:42 UTC by Mirko Streckenbach
Modified: 2007-11-30 22:10 UTC (History)
0 users

Fixed In Version: 2.05b-42
Clone Of:
Environment:
Last Closed: 2004-06-28 16:48:49 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)
proposed fix for the bug (355 bytes, patch)
2004-06-21 08:43 UTC, Mirko Streckenbach
no flags Details | Diff

Description Mirko Streckenbach 2004-06-21 08:42:57 UTC
From Bugzilla Helper:
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.6) Gecko/20040510

Description of problem:
bash produces a segmentation fault in a shell script on a line
like

x=${var##foobar}

if var is longer than 256 characters.


Version-Release number of selected component (if applicable):
bash-2.05b-38

How reproducible:
Always

Steps to Reproduce:
1. run a shell script using variable substituion on long variables
2.
3.
    

Actual Results:  SIGSEGV


Expected Results:  no crash.


Additional info:

This may be hard to reproduce, however the attached patch should
make the mistake obvious to any programmer.

diff -u -r bash-2.05b-orig/subst.c bash-2.05b/subst.c
--- bash-2.05b-orig/subst.c     2004-06-21 10:33:28.065341000 +0200
+++ bash-2.05b/subst.c  2004-06-21 10:33:54.882704680 +0200
@@ -2830,7 +2830,7 @@
       {
        int i, offset;
        char *p;
-       unsigned char last;
+       int last;

       case RP_LONG_LEFT:
       case RP_SHORT_RIGHT:

Comment 1 Mirko Streckenbach 2004-06-21 08:43:55 UTC
Created attachment 101287 [details]
proposed fix for the bug

Comment 2 Tim Waugh 2004-06-25 12:51:17 UTC
Easy to reproduce:

XS=$(perl -e 'print "x" x 400')
echo ${XS##x}

Thanks for the fix.

Comment 3 Tim Waugh 2004-06-28 16:48:49 UTC
Fixed package is bash-2.05b-42.


Note You need to log in before you can comment on or make changes to this bug.