From b2a3b50908b8bfc54f21abfba0c351a41d6ef65f Mon Sep 17 00:00:00 2001 From: Joel Brobecker Date: Wed, 25 Apr 2012 15:14:59 +0000 Subject: [PATCH] Corrupted path caused by "cd" command. gdb/ChangeLog: * cli/cli-cmds.c (cd_command): Use memmove instead of strcpy. --- gdb/ChangeLog | 4 ++++ gdb/cli/cli-cmds.c | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index df4bacfc490..c7025b58872 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -111,6 +111,10 @@ (mips_o32_return_value): Likewise. (mips_o64_return_value): Likewise. +2012-04-25 Fredrik Hederstierna + + * cli/cli-cmds.c (cd_command): Use memmove instead of strcpy. + 2012-04-21 Paul Hilfinger * ada-lang.c (ada_evaluate_subexp): Add cases for diff --git a/gdb/cli/cli-cmds.c b/gdb/cli/cli-cmds.c index 7513ee41d07..2968662ab31 100644 --- a/gdb/cli/cli-cmds.c +++ b/gdb/cli/cli-cmds.c @@ -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; } } -- 2.30.2