diff options
author | Eli Zaretskii <eliz@gnu.org> | 2016-05-02 19:37:43 +0300 |
---|---|---|
committer | Eli Zaretskii <eliz@gnu.org> | 2016-05-02 19:37:43 +0300 |
commit | 1270fac69d2f7e89161ccb780ce3b17466da34ea (patch) | |
tree | 52a71edbaa0e1a545c22f2ca013af8ef92863b8b | |
parent | 2e1fb61c58b4a5579a43d9ff3cae8382347e323e (diff) | |
download | gdb-1270fac69d2f7e89161ccb780ce3b17466da34ea.zip gdb-1270fac69d2f7e89161ccb780ce3b17466da34ea.tar.gz gdb-1270fac69d2f7e89161ccb780ce3b17466da34ea.tar.bz2 |
Fix startup on MS-Windows when 'gdb.ini' is found in $HOME
* windows-nat.c (_initialize_check_for_gdb_ini): Fix off-by-one
error in allocation of space for "$HOME/.gdbinit" string. This
caused GDB to abort on startup whenever a '~/gdb.ini' file was
actually found, because xsnprintf would hit an assertion
violation.
-rw-r--r-- | gdb/ChangeLog | 8 | ||||
-rw-r--r-- | gdb/windows-nat.c | 6 |
2 files changed, 11 insertions, 3 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 6d7bfb2..7d69419 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,11 @@ +2016-05-02 Eli Zaretskii <eliz@gnu.org> + + * windows-nat.c (_initialize_check_for_gdb_ini): Fix off-by-one + error in allocation of space for "$HOME/.gdbinit" string. This + caused GDB to abort on startup whenever a '~/gdb.ini' file was + actually found, because xsnprintf would hit an assertion + violation. + 2016-04-28 Simon Marchi <simon.marchi@ericsson.com> * cli/cli-decode.c (help_cmd_list): Do not list commands that diff --git a/gdb/windows-nat.c b/gdb/windows-nat.c index 71d6670..2e8a777 100644 --- a/gdb/windows-nat.c +++ b/gdb/windows-nat.c @@ -2702,7 +2702,7 @@ _initialize_check_for_gdb_ini (void) { char *p; char *oldini = (char *) alloca (strlen (homedir) + - sizeof ("/gdb.ini")); + sizeof ("gdb.ini") + 1); strcpy (oldini, homedir); p = strchr (oldini, '\0'); if (p > oldini && !IS_DIR_SEPARATOR (p[-1])) @@ -2711,9 +2711,9 @@ _initialize_check_for_gdb_ini (void) if (access (oldini, 0) == 0) { int len = strlen (oldini); - char *newini = (char *) alloca (len + 1); + char *newini = (char *) alloca (len + 2); - xsnprintf (newini, len + 1, "%.*s.gdbinit", + xsnprintf (newini, len + 2, "%.*s.gdbinit", (int) (len - (sizeof ("gdb.ini") - 1)), oldini); warning (_("obsolete '%s' found. Rename to '%s'."), oldini, newini); } |