From: Ross Zwisler <ross.zwisler@linux.intel.com>
To: Andi Kleen <andi.kleen@intel.com>
Cc: Andi Kleen <ak@linux.intel.com>, linux-nvdimm@lists.01.org
Subject: Re: [PATCH 1/3] Avoid filename truncation in numastat
Date: Thu, 5 Apr 2018 09:01:49 -0600 [thread overview]
Message-ID: <20180405150149.GA10615@linux.intel.com> (raw)
In-Reply-To: <20180322183322.23076-1-ross.zwisler@linux.intel.com>
Ping on this series.
On Thu, Mar 22, 2018 at 12:33:20PM -0600, Ross Zwisler wrote:
> gcc 7.3.1 provides the following warning when compiling numastat.c:
>
> numastat.c: In function ‘add_pids_from_pattern_search’:
> numastat.c:1316:41: warning: ‘%s’ directive output may be truncated writing
> up to 255 bytes into a region of size 58 [-Wformat-truncation=]
> snprintf(fname, sizeof(fname), "/proc/%s/cmdline", namelist[ix]->d_name);
> ^~
> numastat.c:1316:3: note: ‘snprintf’ output between 15 and 270 bytes into a
> destination of size 64
> snprintf(fname, sizeof(fname), "/proc/%s/cmdline", namelist[ix]->d_name);
> ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
> This is valid - namelist[ix]->d_name is size 256 bytes, we have some extra
> bytes as part of our format string. Our destination buffer, 'fname', is
> only 64 bytes wide.
>
> Signed-off-by: Ross Zwisler <ross.zwisler@linux.intel.com>
> ---
> numastat.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/numastat.c b/numastat.c
> index e0a5639..2d413df 100644
> --- a/numastat.c
> +++ b/numastat.c
> @@ -1312,7 +1312,7 @@ void add_pids_from_pattern_search(char *pattern) {
> }
> // Next copy cmdline file contents onto end of buffer. Do it a
> // character at a time to convert nulls to spaces.
> - char fname[64];
> + char fname[272];
> snprintf(fname, sizeof(fname), "/proc/%s/cmdline", namelist[ix]->d_name);
> FILE *fs = fopen(fname, "r");
> if (fs) {
> --
> 2.14.3
>
_______________________________________________
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm
prev parent reply other threads:[~2018-04-05 15:01 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-03-22 18:33 [PATCH 1/3] Avoid filename truncation in numastat Ross Zwisler
2018-03-22 18:33 ` [PATCH 2/3] readdir_r(3) is deprecated, use readdir(3) instead Ross Zwisler
2018-03-22 18:33 ` [PATCH 3/3] Add pkg-config file for NUMA library Ross Zwisler
2018-04-05 15:01 ` Ross Zwisler [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=20180405150149.GA10615@linux.intel.com \
--to=ross.zwisler@linux.intel.com \
--cc=ak@linux.intel.com \
--cc=andi.kleen@intel.com \
--cc=linux-nvdimm@lists.01.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.