This is the mail archive of the
gdb-cvs@sourceware.org
mailing list for the GDB project.
[binutils-gdb] Fix potential NULL pointer dereference
- From: Luis Machado <luisgpm at sourceware dot org>
- To: gdb-cvs at sourceware dot org
- Date: 24 Oct 2016 22:52:08 -0000
- Subject: [binutils-gdb] Fix potential NULL pointer dereference
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=b5e1db87897cabfd9beb8b1bd49f7d965c0f2607
commit b5e1db87897cabfd9beb8b1bd49f7d965c0f2607
Author: Luis Machado <lgustavo@codesourcery.com>
Date: Mon Oct 24 17:51:33 2016 -0500
Fix potential NULL pointer dereference
This patch addresses a potential NULL pointer dereference when we try to
duplicate a string. The input pointer can be NULL and that may lead to
crashes. We simply add a check for that case.
gdb/ChangeLog:
2016-10-24 Luis Machado <lgustavo@codesourcery.com>
* exec.c (exec_file_locate_attach): Prevent NULL pointer dereference
when duplicating a string.
Diff:
---
gdb/ChangeLog | 5 +++++
gdb/exec.c | 3 ++-
2 files changed, 7 insertions(+), 1 deletion(-)
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 388cc1f..43175ff 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,10 @@
2016-10-24 Luis Machado <lgustavo@codesourcery.com>
+ * exec.c (exec_file_locate_attach): Prevent NULL pointer dereference
+ when duplicating a string.
+
+2016-10-24 Luis Machado <lgustavo@codesourcery.com>
+
* exec.c (exception_print_same): Fix string comparison to use
statically-allocated ones.
diff --git a/gdb/exec.c b/gdb/exec.c
index 67ecc63..6e2a296 100644
--- a/gdb/exec.c
+++ b/gdb/exec.c
@@ -227,7 +227,8 @@ exec_file_locate_attach (int pid, int defer_bp_reset, int from_tty)
prev_err = err;
/* Save message so it doesn't get trashed by the catch below. */
- prev_err.message = xstrdup (err.message);
+ if (err.message != NULL)
+ prev_err.message = xstrdup (err.message);
}
END_CATCH