Kexec Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Simon Horman <horms@verge.net.au>
To: Bhupesh Sharma <bhsharma@redhat.com>
Cc: bhupesh.linux@gmail.com, kexec@lists.infradead.org,
	Eric Biederman <ebiederm@xmission.com>
Subject: Re: [PATCH] kexec: Fix snprintf related compilation warnings
Date: Tue, 29 Sep 2020 18:21:01 +0200	[thread overview]
Message-ID: <20200929162101.GH7355@vergenet.net> (raw)
In-Reply-To: <20200923111237.883383-1-bhsharma@redhat.com>

On Wed, Sep 23, 2020 at 04:42:37PM +0530, Bhupesh Sharma wrote:
> This patch fixes the following snprintf related compilation warning
> seen currently with gcc versions 7 and 8 when kexec is compiled with
> -Wformat-truncation option:
> 
>     kexec/fs2dt.c:673:34: warning: ‘stdout-path’ directive output may be truncated writing 11 bytes into a region of size between 1 and 1024 [-Wformat-truncation=]
>        snprintf(filename, MAXPATH, "%sstdout-path", pathname);
>                                       ^~~~~~~~~~~
>     kexec/fs2dt.c:673:3: note: ‘snprintf’ output between 12 and 1035 bytes into a destination of size 1024
>        snprintf(filename, MAXPATH, "%sstdout-path", pathname);
>        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>     kexec/fs2dt.c:676:35: warning: ‘linux,stdout-path’ directive output may be truncated writing 17 bytes into a region of size between 1 and 1024 [-Wformat-truncation=]
>         snprintf(filename, MAXPATH, "%slinux,stdout-path", pathname);
>                                        ^~~~~~~~~~~~~~~~~
>     kexec/fs2dt.c:676:4: note: ‘snprintf’ output between 18 and 1041 bytes into a destination of size 1024
>         snprintf(filename, MAXPATH, "%slinux,stdout-path", pathname);
>         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> 
>     kexec/firmware_memmap.c:132:35: warning: ‘%s’ directive output may be truncated writing 5 bytes into a region of size between 0 and 4095 [-Wformat-truncation=]
>       snprintf(filename, PATH_MAX, "%s/%s", entry, "start");
>                                        ^~          ~~~~~~~
>     kexec/firmware_memmap.c:132:2: note: ‘snprintf’ output between 7 and 4102 bytes into a destination of size 4096
>       snprintf(filename, PATH_MAX, "%s/%s", entry, "start");
>       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>     kexec/firmware_memmap.c:142:35: warning: ‘%s’ directive output may be truncated writing 3 bytes into a region of size between 0 and 4095 [-Wformat-truncation=]
>       snprintf(filename, PATH_MAX, "%s/%s", entry, "end");
>                                        ^~          ~~~~~
>     kexec/firmware_memmap.c:142:2: note: ‘snprintf’ output between 5 and 4100 bytes into a destination of size 4096
>       snprintf(filename, PATH_MAX, "%s/%s", entry, "end");
>       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>     kexec/firmware_memmap.c:152:35: warning: ‘%s’ directive output may be truncated writing 4 bytes into a region of size between 0 and 4095 [-Wformat-truncation=]
>       snprintf(filename, PATH_MAX, "%s/%s", entry, "type");
>                                        ^~          ~~~~~~
>     kexec/firmware_memmap.c:152:2: note: ‘snprintf’ output between 6 and 4101 bytes into a destination of size 4096
>       snprintf(filename, PATH_MAX, "%s/%s", entry, "type");
>       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> 
> Since the simplest method to address the gcc warnings and possible
> truncation would be to check the return value provided from snprintf
> (well there are other methods like using 'asnprintf' or using
> 'open_memstream' function to create the FILE object, but these are more
> intrusive), so this patch does the same.
> 
> Cc: Simon Horman <horms@verge.net.au>
> Cc: Eric Biederman <ebiederm@xmission.com>
> Cc: kexec@lists.infradead.org
> Signed-off-by: Bhupesh Sharma <bhsharma@redhat.com>

Thanks, applied.

_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

      reply	other threads:[~2020-09-29 16:21 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-23 11:12 [PATCH] kexec: Fix snprintf related compilation warnings Bhupesh Sharma
2020-09-29 16:21 ` Simon Horman [this message]

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=20200929162101.GH7355@vergenet.net \
    --to=horms@verge.net.au \
    --cc=bhsharma@redhat.com \
    --cc=bhupesh.linux@gmail.com \
    --cc=ebiederm@xmission.com \
    --cc=kexec@lists.infradead.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