Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Andrew D'Addesio <modchipv12@gmail.com>
To: gdb-patches@sourceware.org
Cc: Andrew D'Addesio <modchipv12@gmail.com>
Subject: [PATCH] Process record: Fix null deref when loading empty core file
Date: Sat, 12 May 2018 03:53:00 -0000	[thread overview]
Message-ID: <1526075698-20880-1-git-send-email-modchipv12@gmail.com> (raw)

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


             reply	other threads:[~2018-05-11 21:55 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-12  3:53 Andrew D'Addesio [this message]
2018-05-12  6:07 ` Andrew D'Addesio
2018-05-31  0:20   ` Joel Brobecker

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1526075698-20880-1-git-send-email-modchipv12@gmail.com \
    --to=modchipv12@gmail.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox