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
Upgrade. This is fixed by bash-4.1 patch 10.
Chet
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRU ch...@case.edu http://cnswww.cns.cwru.edu/~chet/