devicetree-compiler.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Gibson <david-xT8FGy+AXnRB3Ne2BGzF6laj5H9X9Tb+@public.gmane.org>
To: Jean-Christophe Dubois <jcd-WBS85hRCVJbxB9160cZjhg@public.gmane.org>
Cc: devicetree-compiler-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	jdl-CYoMK+44s/E@public.gmane.org
Subject: Re: [PATCH] DTC: Fix unprotected file name member access.
Date: Mon, 11 Jul 2016 11:30:53 +1000	[thread overview]
Message-ID: <20160711013053.GC16355@voom.fritz.box> (raw)
In-Reply-To: <1468189028-1641-1-git-send-email-jcd-WBS85hRCVJbxB9160cZjhg@public.gmane.org>

[-- Attachment #1: Type: text/plain, Size: 1439 bytes --]

On Mon, Jul 11, 2016 at 12:17:08AM +0200, Jean-Christophe Dubois wrote:
> Signed-off-by: Jean-Christophe Dubois <jcd-WBS85hRCVJbxB9160cZjhg@public.gmane.org>

A patch like this really needs a commit message describing when the
situation it's guarding against can occur.  In this case when can
pos->file be non-NULL, but pos->file->name == NULL.

It's not exactly high priority, since srcpos_dump() has no current
users AFAICT.

> ---
>  srcpos.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/srcpos.c b/srcpos.c
> index af7fb3c..927ac54 100644
> --- a/srcpos.c
> +++ b/srcpos.c
> @@ -252,7 +252,7 @@ void
>  srcpos_dump(struct srcpos *pos)
>  {
>  	printf("file        : \"%s\"\n",
> -	       pos->file ? (char *) pos->file : "<no file>");
> +	       (pos->file && pos->file->name) ? pos->file->name : "<no file>");
>  	printf("first_line  : %d\n", pos->first_line);
>  	printf("first_column: %d\n", pos->first_column);
>  	printf("last_line   : %d\n", pos->last_line);
> @@ -267,7 +267,7 @@ srcpos_string(struct srcpos *pos)
>  	const char *fname = "<no-file>";
>  	char *pos_str;
>  
> -	if (pos)
> +	if (pos->file && pos->file->name)
>  		fname = pos->file->name;
>  
>  

-- 
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: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

  parent reply	other threads:[~2016-07-11  1:30 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-10 22:17 [PATCH] DTC: Fix unprotected file name member access Jean-Christophe Dubois
     [not found] ` <1468189028-1641-1-git-send-email-jcd-WBS85hRCVJbxB9160cZjhg@public.gmane.org>
2016-07-11  1:30   ` David Gibson [this message]
     [not found]     ` <20160711013053.GC16355-RXTfZT5YzpxwFLYp8hBm2A@public.gmane.org>
2016-07-11  6:22       ` Jean-Christophe DUBOIS
     [not found]         ` <57833B0E.8040508-WBS85hRCVJbxB9160cZjhg@public.gmane.org>
2016-07-12 14:45           ` David Gibson

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=20160711013053.GC16355@voom.fritz.box \
    --to=david-xt8fgy+axnrb3ne2bgzf6laj5h9x9tb+@public.gmane.org \
    --cc=devicetree-compiler-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=jcd-WBS85hRCVJbxB9160cZjhg@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).