Corrupted path caused by "cd" command.

gdb/ChangeLog:

	* cli/cli-cmds.c (cd_command): Use memmove instead of strcpy.
This commit is contained in:
Joel Brobecker 2012-04-25 15:14:59 +00:00
parent a766d390bb
commit b2a3b50908
2 changed files with 6 additions and 2 deletions

View file

@ -417,7 +417,7 @@ cd_command (char *dir, int from_tty)
{
if (IS_DIR_SEPARATOR (p[0]) && p[1] == '.'
&& (p[2] == 0 || IS_DIR_SEPARATOR (p[2])))
strcpy (p, p + 2);
memmove (p, p + 2, strlen (p + 2) + 1);
else if (IS_DIR_SEPARATOR (p[0]) && p[1] == '.' && p[2] == '.'
&& (p[3] == 0 || IS_DIR_SEPARATOR (p[3])))
{
@ -436,7 +436,7 @@ cd_command (char *dir, int from_tty)
++p;
else
{
strcpy (q - 1, p + 3);
memmove (q - 1, p + 3, strlen (p + 3) + 1);
p = q - 1;
}
}