From: David Gibson <david-xT8FGy+AXnRB3Ne2BGzF6laj5H9X9Tb+@public.gmane.org>
To: Frank Rowand <frowand.list-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Cc: jdl-CYoMK+44s/E@public.gmane.org,
devicetree-compiler-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: [RFC PATCH v5 1/2] dtc: protect against null pointer dereference in srcpos_string()
Date: Thu, 1 Oct 2015 15:32:07 +1000 [thread overview]
Message-ID: <20151001053207.GL23574@voom> (raw)
In-Reply-To: <560CA95C.6010109-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
[-- Attachment #1: Type: text/plain, Size: 1445 bytes --]
On Wed, Sep 30, 2015 at 08:32:44PM -0700, Frank Rowand wrote:
> From: Frank Rowand <frank.rowand-/MT0OVThwyLZJqsBc5GL+g@public.gmane.org>
>
> Check for NULL pos before dereferencing it 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;
Hmm.. looking at the existing code, it looks like the
if (pos)
above should probably be
if (pos->file)
It would be nice to fix that at the same time..
>
> - if (pos->first_line != pos->last_line)
> + if (!pos)
> + rc = asprintf(&pos_str, "%s:0", fname);
Because this really should go very first, before even setting fname.
"<no-file>:0" seems an odd way to display this, rather than just
"<no-location>", for example.
> + 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);
--
David Gibson | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_
| _way_ _around_!
http://www.ozlabs.org/~dgibson
[-- Attachment #2: Type: application/pgp-signature, Size: 819 bytes --]
next prev parent reply other threads:[~2015-10-01 5:32 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-10-01 3:29 [RFC PATCH v5 0/2] dtc: dts source location annotation Frank Rowand
[not found] ` <560CA87E.1010103-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2015-10-01 3:32 ` [RFC PATCH v5 1/2] dtc: protect against null pointer dereference in srcpos_string() Frank Rowand
[not found] ` <560CA95C.6010109-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2015-10-01 5:32 ` David Gibson [this message]
2015-10-01 3:35 ` [RFC PATCH v5 1/2] dtc: dts source location annotation Frank Rowand
[not found] ` <560CA9FB.6050700-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2015-10-01 3:36 ` Frank Rowand
2015-10-01 5:49 ` David Gibson
2015-10-03 4:24 ` Frank Rowand
[not found] ` <560F586F.8040302-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2015-10-03 4:29 ` 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=20151001053207.GL23574@voom \
--to=david-xt8fgy+axnrb3ne2bgzf6laj5h9x9tb+@public.gmane.org \
--cc=devicetree-compiler-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=frowand.list-Re5JQEeQqe8AvxtiuMwx3w@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).