Home
Reading
Searching
Subscribe
Sponsors
Statistics
Posting
Contact
Spam
Lists
Links
About
Hosting
Filtering
Features Download
Marketing
Archives
FAQ
Blog
 
Gmane
From: =?ISO-8859-1?Q?St=E9phane_Jourdois?= <sjourdois <at> gmail.com>
Subject: String corruption using \W in prompt
Newsgroups: gmane.comp.shells.bash.bugs
Date: Thursday 27th May 2010 13:44:29 UTC (over 8 years ago)
Configuration Information [Automatically generated, do not change]:
Machine: x86_64
OS: linux-gnu
Compiler: gcc
Compilation CFLAGS:  -DPROGRAM='bash' -DCONF_HOSTTYPE='x86_64'
-DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='x86_64-pc-linux-gnu'
-DCONF_VENDOR='pc' -DLOCALEDIR='/usr/share/locale' -DPACKAGE='bash'
-DSHELL -DHAVE_CONFIG_H   -I.  -I../bash -I../bash/include
-I../bash/lib   -g -O2 -Wall
uname output: Linux topaze.kwi.fr 2.6.34-2010-05-26-wl-59453-g97ef193
#52 SMP PREEMPT Wed May 26 10:06:42 CEST 2010 x86_64 GNU/Linux
Machine Type: x86_64-pc-linux-gnu

Bash Version: 4.1
Patch Level: 5
Release Status: release

Description:
        String corruption caused by strcpy on overlapping strings.

        From parse.y, lines 5153-5155 :
        -----
                        t = strrchr (t_string, '/');
                        if (t)
                          strcpy (t_string, t +
1);
        -----

Repeat-By:
        Use \W in PS1, cd to /something :
        -----
        [email protected]:~ $ export PS1='\W '
        ~ cd /root/
        rott
        -----

Fix:
--- parse.y     2010-05-27 15:16:15.623495000 +0200
+++ parse.y.smj 2010-05-27 15:16:30.364495000 +0200
@@ -5152,7 +5152,7 @@
                      {
                        t = strrchr (t_string, '/');
                        if (t)
-                         strcpy (t_string, t + 1);
+                         memmove (t_string, t + 1,
sizeof(t));
                      }
                  }
 #undef ROOT_PATH


Thanks,
Stéphane (kwisatz) Jourdois.
 
CD: 14ms