Bug 126399 - bash segfaults on substitution in multibyte environments
bash segfaults on substitution in multibyte environments
Status: CLOSED RAWHIDE
Product: Fedora
Classification: Fedora
Component: bash (Show other bugs)
2
i386 Linux
medium Severity high
: ---
: ---
Assigned To: Tim Waugh
Ben Levenson
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2004-06-21 04:42 EDT by Mirko Streckenbach
Modified: 2007-11-30 17:10 EST (History)
0 users

See Also:
Fixed In Version: 2.05b-42
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2004-06-28 12:48:49 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


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

  None (edit)
Description Mirko Streckenbach 2004-06-21 04:42:57 EDT
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 04:43:55 EDT
Created attachment 101287 [details]
proposed fix for the bug
Comment 2 Tim Waugh 2004-06-25 08:51:17 EDT
Easy to reproduce:

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

Thanks for the fix.
Comment 3 Tim Waugh 2004-06-28 12:48:49 EDT
Fixed package is bash-2.05b-42.

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