linux-sparse.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Davidson Francis <davidsondfgl@gmail.com>
To: linux-sparse@vger.kernel.org
Cc: Davidson Francis <davidsondfgl@gmail.com>
Subject: [PATCH] show-parse: null pointer dereference in do_show_type()
Date: Mon, 11 May 2020 00:06:20 -0300	[thread overview]
Message-ID: <20200511030620.10329-1-davidsondfgl@gmail.com> (raw)

In do_show_type() the first if statement allows passing null
pointers, which can cause a null pointer dereference in some
cases, which I believe is not the desired behavior.

Fix this by changing the first if statement comparison.

Signed-off-by: Davidson Francis <davidsondfgl@gmail.com>
---
 show-parse.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/show-parse.c b/show-parse.c
index 3aa06e47..11a487bc 100644
--- a/show-parse.c
+++ b/show-parse.c
@@ -300,7 +300,7 @@ static void do_show_type(struct symbol *sym, struct type_name *name)
 	int fouled = 0;
 
 deeper:
-	if (!sym || (sym->type != SYM_NODE && sym->type != SYM_ARRAY &&
+	if (sym && (sym->type != SYM_NODE && sym->type != SYM_ARRAY &&
 		     sym->type != SYM_BITFIELD)) {
 		const char *s;
 		size_t len;
-- 
2.11.0

             reply	other threads:[~2020-05-11  3:07 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-11  3:06 Davidson Francis [this message]
2020-05-14 21:14 ` [PATCH] show-parse: null pointer dereference in do_show_type() Luc Van Oostenryck

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=20200511030620.10329-1-davidsondfgl@gmail.com \
    --to=davidsondfgl@gmail.com \
    --cc=linux-sparse@vger.kernel.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;
as well as URLs for NNTP newsgroup(s).