From: "Darrick J. Wong" <darrick.wong@oracle.com> To: Ross Zwisler <ross.zwisler@linux.intel.com> Cc: Jan Kara <jack@suse.cz>, linux-nvdimm <linux-nvdimm@lists.01.org>, Dave Chinner <david@fromorbit.com>, fstests <fstests@vger.kernel.org>, linux-xfs <linux-xfs@vger.kernel.org> Subject: Re: [xfsprogs PATCH v2 1/3] xfs_io: fix compiler warnings in getfsmap code Date: Tue, 5 Dec 2017 16:03:53 -0800 [thread overview] Message-ID: <20171206000353.GH19219@magnolia> (raw) In-Reply-To: <20171205235651.17102-2-ross.zwisler@linux.intel.com> On Tue, Dec 05, 2017 at 04:56:49PM -0700, Ross Zwisler wrote: > I recently upgraded my compiler from > gcc (GCC) 6.4.1 20170727 (Red Hat 6.4.1-1) > to > gcc (GCC) 7.2.1 20170915 (Red Hat 7.2.1-2) > and started getting a bunch of compiler warnings in io/fsmap.c: > > fsmap.c: In function ‘fsmap_f’: > fsmap.c:228:40: warning: ‘%lld’ directive output may be truncated writing > between 1 and 17 bytes into a region of size between 12 and 28 > [-Wformat-truncation=] > snprintf(bbuf, sizeof(bbuf), "[%lld..%lld]:", > ^~~~ > fsmap.c:228:32: note: directive argument in the range [0, 36028797018963967] > snprintf(bbuf, sizeof(bbuf), "[%lld..%lld]:", > ^~~~~~~~~~~~~~~ > fsmap.c:228:3: note: ‘snprintf’ output between 8 and 40 bytes into a > destination of size 32 > snprintf(bbuf, sizeof(bbuf), "[%lld..%lld]:", > ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > (long long)BTOBBT(p->fmr_physical), > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > (long long)BTOBBT(p->fmr_physical + p->fmr_length - 1)); > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > > The issue is that 'bbuf' is only defined to be 32 characters wide, but each > signed long long can potentially print as many as 19 characters > (9223372036854775807 is the max value). The format we're using for bbuf is > "[%lld..%lld]:" which has 2 signed long longs plus 6 other characters > "[..]:\0", which means it's possible we'll print up to 44 characters, > overflowing our 32 char buffer. > > Fix this by bumping all the buffer sizes in dump_map_verbose() to 64 > characters. > > Signed-off-by: Ross Zwisler <ross.zwisler@linux.intel.com> > Cc: Darrick J. Wong <darrick.wong@oracle.com> Looks ok, Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com> > Fixes: 3fcab549a234 ("xfs_io: support the new getfsmap ioctl") > --- > io/fsmap.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/io/fsmap.c b/io/fsmap.c > index 448fb535..3d8a6700 100644 > --- a/io/fsmap.c > +++ b/io/fsmap.c > @@ -184,8 +184,8 @@ dump_map_verbose( > off64_t agoff, bperag; > int foff_w, boff_w, aoff_w, tot_w, agno_w, own_w; > int nr_w, dev_w; > - char rbuf[32], bbuf[32], abuf[32], obuf[32]; > - char nbuf[32], dbuf[32], gbuf[32]; > + char rbuf[64], bbuf[64], abuf[64], obuf[64]; > + char nbuf[64], dbuf[64], gbuf[64]; > char owner[OWNER_BUF_SZ]; > int sunit, swidth; > int flg = 0; > -- > 2.14.3 > > -- > To unsubscribe from this list: send the line "unsubscribe linux-xfs" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html _______________________________________________ Linux-nvdimm mailing list Linux-nvdimm@lists.01.org https://lists.01.org/mailman/listinfo/linux-nvdimm
WARNING: multiple messages have this Message-ID (diff)
From: "Darrick J. Wong" <darrick.wong@oracle.com> To: Ross Zwisler <ross.zwisler@linux.intel.com> Cc: linux-xfs <linux-xfs@vger.kernel.org>, linux-nvdimm <linux-nvdimm@lists.01.org>, fstests <fstests@vger.kernel.org>, Jan Kara <jack@suse.cz>, Dave Chinner <david@fromorbit.com>, Dan Williams <dan.j.williams@intel.com> Subject: Re: [xfsprogs PATCH v2 1/3] xfs_io: fix compiler warnings in getfsmap code Date: Tue, 5 Dec 2017 16:03:53 -0800 [thread overview] Message-ID: <20171206000353.GH19219@magnolia> (raw) In-Reply-To: <20171205235651.17102-2-ross.zwisler@linux.intel.com> On Tue, Dec 05, 2017 at 04:56:49PM -0700, Ross Zwisler wrote: > I recently upgraded my compiler from > gcc (GCC) 6.4.1 20170727 (Red Hat 6.4.1-1) > to > gcc (GCC) 7.2.1 20170915 (Red Hat 7.2.1-2) > and started getting a bunch of compiler warnings in io/fsmap.c: > > fsmap.c: In function ‘fsmap_f’: > fsmap.c:228:40: warning: ‘%lld’ directive output may be truncated writing > between 1 and 17 bytes into a region of size between 12 and 28 > [-Wformat-truncation=] > snprintf(bbuf, sizeof(bbuf), "[%lld..%lld]:", > ^~~~ > fsmap.c:228:32: note: directive argument in the range [0, 36028797018963967] > snprintf(bbuf, sizeof(bbuf), "[%lld..%lld]:", > ^~~~~~~~~~~~~~~ > fsmap.c:228:3: note: ‘snprintf’ output between 8 and 40 bytes into a > destination of size 32 > snprintf(bbuf, sizeof(bbuf), "[%lld..%lld]:", > ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > (long long)BTOBBT(p->fmr_physical), > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > (long long)BTOBBT(p->fmr_physical + p->fmr_length - 1)); > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > > The issue is that 'bbuf' is only defined to be 32 characters wide, but each > signed long long can potentially print as many as 19 characters > (9223372036854775807 is the max value). The format we're using for bbuf is > "[%lld..%lld]:" which has 2 signed long longs plus 6 other characters > "[..]:\0", which means it's possible we'll print up to 44 characters, > overflowing our 32 char buffer. > > Fix this by bumping all the buffer sizes in dump_map_verbose() to 64 > characters. > > Signed-off-by: Ross Zwisler <ross.zwisler@linux.intel.com> > Cc: Darrick J. Wong <darrick.wong@oracle.com> Looks ok, Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com> > Fixes: 3fcab549a234 ("xfs_io: support the new getfsmap ioctl") > --- > io/fsmap.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/io/fsmap.c b/io/fsmap.c > index 448fb535..3d8a6700 100644 > --- a/io/fsmap.c > +++ b/io/fsmap.c > @@ -184,8 +184,8 @@ dump_map_verbose( > off64_t agoff, bperag; > int foff_w, boff_w, aoff_w, tot_w, agno_w, own_w; > int nr_w, dev_w; > - char rbuf[32], bbuf[32], abuf[32], obuf[32]; > - char nbuf[32], dbuf[32], gbuf[32]; > + char rbuf[64], bbuf[64], abuf[64], obuf[64]; > + char nbuf[64], dbuf[64], gbuf[64]; > char owner[OWNER_BUF_SZ]; > int sunit, swidth; > int flg = 0; > -- > 2.14.3 > > -- > To unsubscribe from this list: send the line "unsubscribe linux-xfs" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2017-12-06 0:00 UTC|newest] Thread overview: 42+ messages / expand[flat|nested] mbox.gz Atom feed top 2017-12-05 23:56 [xfsprogs PATCH v2 0/3] Add necessary items for MAP_SYNC testing Ross Zwisler 2017-12-05 23:56 ` Ross Zwisler 2017-12-05 23:56 ` [xfsprogs PATCH v2 1/3] xfs_io: fix compiler warnings in getfsmap code Ross Zwisler 2017-12-05 23:56 ` Ross Zwisler 2017-12-06 0:03 ` Darrick J. Wong [this message] 2017-12-06 0:03 ` Darrick J. Wong 2017-12-06 0:27 ` Dave Chinner 2017-12-06 0:27 ` Dave Chinner 2017-12-06 13:59 ` Eric Sandeen 2017-12-06 13:59 ` Eric Sandeen 2017-12-06 20:10 ` Ross Zwisler 2017-12-06 20:10 ` Ross Zwisler 2017-12-06 20:47 ` Darrick J. Wong 2017-12-06 20:47 ` Darrick J. Wong 2017-12-06 20:58 ` Ross Zwisler 2017-12-06 20:58 ` Ross Zwisler 2017-12-05 23:56 ` [xfsprogs PATCH v2 2/3] xfs_io: add MAP_SYNC support to mmap() Ross Zwisler 2017-12-05 23:56 ` Ross Zwisler 2017-12-21 17:09 ` Darrick J. Wong 2017-12-21 17:09 ` Darrick J. Wong 2017-12-21 17:41 ` Ross Zwisler 2017-12-21 17:41 ` Ross Zwisler 2017-12-21 17:46 ` Darrick J. Wong 2017-12-21 17:46 ` Darrick J. Wong 2017-12-05 23:56 ` [xfsprogs PATCH v2 3/3] xfs_io: add a new 'log_writes' command Ross Zwisler 2017-12-05 23:56 ` Ross Zwisler 2017-12-06 0:29 ` Dave Chinner 2017-12-06 0:29 ` Dave Chinner 2017-12-06 4:38 ` Ross Zwisler 2017-12-06 4:38 ` Ross Zwisler 2017-12-06 4:41 ` Ross Zwisler 2017-12-06 4:41 ` Ross Zwisler 2017-12-06 5:43 ` Dave Chinner 2017-12-06 5:43 ` Dave Chinner 2017-12-06 18:13 ` [xfsprogs PATCH v3 " Ross Zwisler 2017-12-06 18:13 ` Ross Zwisler 2017-12-21 17:14 ` Darrick J. Wong 2017-12-21 17:14 ` Darrick J. Wong 2017-12-13 16:45 ` [xfsprogs PATCH v2 0/3] Add necessary items for MAP_SYNC testing Ross Zwisler 2017-12-13 16:45 ` Ross Zwisler 2017-12-21 16:55 ` Ross Zwisler 2017-12-21 16:55 ` Ross Zwisler
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=20171206000353.GH19219@magnolia \ --to=darrick.wong@oracle.com \ --cc=david@fromorbit.com \ --cc=fstests@vger.kernel.org \ --cc=jack@suse.cz \ --cc=linux-nvdimm@lists.01.org \ --cc=linux-xfs@vger.kernel.org \ --cc=ross.zwisler@linux.intel.com \ /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: linkBe 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.