From: Frank Rowand <frowand.list-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: david-xT8FGy+AXnRB3Ne2BGzF6laj5H9X9Tb+@public.gmane.org,
jdl-CYoMK+44s/E@public.gmane.org
Cc: devicetree-compiler-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: [RFC PATCH v4 1/2] dtc: protect against null pointer dereference in srcpos_string()
Date: Wed, 30 Sep 2015 19:52:10 -0700 [thread overview]
Message-ID: <560C9FDA.1090403@gmail.com> (raw)
In-Reply-To: <560C9D4B.1040603-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
From: Frank Rowand <frank.rowand-/MT0OVThwyLZJqsBc5GL+g@public.gmane.org>
Check for NULL pos before dereferencing is in srcpos_string().
Signed-off-by: Frank Rowand <frank.rowand-/MT0OVThwyLZJqsBc5GL+g@public.gmane.org>
---
srcpos.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
Index: b/srcpos.c
===================================================================
--- a/srcpos.c
+++ b/srcpos.c
@@ -272,7 +272,9 @@ srcpos_string(struct srcpos *pos)
fname = pos->file->name;
- if (pos->first_line != pos->last_line)
+ if (!pos)
+ rc = asprintf(&pos_str, "%s:0", fname);
+ else if (pos->first_line != pos->last_line)
rc = asprintf(&pos_str, "%s:%d.%d-%d.%d", fname,
pos->first_line, pos->first_column,
pos->last_line, pos->last_column);
next prev parent reply other threads:[~2015-10-01 2:52 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-10-01 2:41 [RFC PATCH v4] dtc: dts source location annotation Frank Rowand
[not found] ` <560C9D4B.1040603-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2015-10-01 2:44 ` Frank Rowand
2015-10-01 2:52 ` Frank Rowand [this message]
2015-10-01 2:56 ` [RFC PATCH v4 2/2] " Frank Rowand
2015-10-01 3:15 ` [RFC PATCH v4] " Frank Rowand
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=560C9FDA.1090403@gmail.com \
--to=frowand.list-re5jqeeqqe8avxtiumwx3w@public.gmane.org \
--cc=david-xT8FGy+AXnRB3Ne2BGzF6laj5H9X9Tb+@public.gmane.org \
--cc=devicetree-compiler-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=jdl-CYoMK+44s/E@public.gmane.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).