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/shar uname output: Linux gohan 2.6.37-2-amd64 #1 SMP Sun Feb 27 10:12:22 UTC 2011 x86_64 GNU/Linux Machine Type: x86_64-pc-linux-gnu
Bash Version: 4.1 Patch Level: 5 Release Status: release Description: The "\W" escape in the prompt is expanded incorrectly for some directories. The problem is caused by the use of strcpy with overlapping strings; but strcpy has undefined behaviour when the strings overlap. Repeat-By: Set PS1 to include the "\W" escape, then cd to /home or /media to see the problem: "home" is displayed as "hmee" and "media" is displayed as "meiia". A transcript from my bash session is below: bash-4.1$ PS1='\W$ ' ~$ cd /home hmee$ cd /media meiia$ cd /etc etc$ cd ~$ exit Fix: The patch below fixes the problem. --- y.tab.c.orig 2011-04-04 01:12:23.000000000 +0900 +++ y.tab.c 2011-04-04 01:19:48.000000000 +0900 @@ -7481,7 +7481,8 @@ { t = strrchr (t_string, '/'); if (t) - strcpy (t_string, t + 1); + for ( temp = t_string; *t; temp++ ) + *temp = *++t; } } #undef ROOT_PATH