This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[PATCH] Process record: Fix null deref when loading empty core file
- From: Andrew D'Addesio <modchipv12 at gmail dot com>
- To: gdb-patches at sourceware dot org
- Cc: Andrew D'Addesio <modchipv12 at gmail dot com>
- Date: Fri, 11 May 2018 16:54:58 -0500
- Subject: [PATCH] Process record: Fix null deref when loading empty core file
Fix a null dereference in the "record full restore" command. If the
supplied file contains no records, the arch list will be empty, so
no need to copy to the record list.
Also remove a redundant "record_full_arch_list_tail->next = NULL;"
assignment, as our arch list is already non-circular by design.
gdb/ChangeLog:
2018-05-11 Andrew D'Addesio <modchipv12@gmail.com>
* record-full.c (record_full_restore): Avoid null deref when
appending the arch list to the record list.
---
gdb/record-full.c | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/gdb/record-full.c b/gdb/record-full.c
index 79f5c0f..edd30fb 100644
--- a/gdb/record-full.c
+++ b/gdb/record-full.c
@@ -2486,11 +2486,13 @@ record_full_restore (void)
discard_cleanups (old_cleanups);
- /* Add record_full_arch_list_head to the end of record list. */
- record_full_first.next = record_full_arch_list_head;
- record_full_arch_list_head->prev = &record_full_first;
- record_full_arch_list_tail->next = NULL;
- record_full_list = &record_full_first;
+ /* Append the arch list to the record list. */
+ if (record_full_arch_list_head != NULL)
+ {
+ record_full_first.next = record_full_arch_list_head;
+ record_full_arch_list_head->prev = &record_full_first;
+ record_full_list = &record_full_first;
+ }
/* Update record_full_insn_max_num. */
if (record_full_insn_num > record_full_insn_max_num)
--
2.7.4