From: Ruediger Meier <sweet_f_a@gmx.de>
To: util-linux@vger.kernel.org
Subject: [PATCH 4/6] misc: fix gcc-7 sprintf warnings -Wformat-overflow
Date: Mon, 12 Jun 2017 10:49:56 +0200 [thread overview]
Message-ID: <20170612084958.22054-5-sweet_f_a@gmx.de> (raw)
In-Reply-To: <20170612084958.22054-1-sweet_f_a@gmx.de>
From: Ruediger Meier <ruediger.meier@ga-group.nl>
../login-utils/last.c: In function ‘main’:
../login-utils/last.c:624:23: warning: ‘%s’ directive writing up to 31 bytes into a region of size 27 [-Wformat-overflow=]
sprintf(path, "/dev/%s", ut->ut_line);
^~ ~~
../login-utils/last.c:624:3: note: ‘sprintf’ output between 6 and 37 bytes into a destination of size 32
sprintf(path, "/dev/%s", ut->ut_line);
../libblkid/src/devname.c: In function 'probe_one':
../libblkid/src/devname.c:166:29: warning: '%s' directive writing up to 255 bytes into a region of size 245 [-Wformat-overflow=]
sprintf(path, "/sys/block/%s/slaves", de->d_name);
^~
../libblkid/src/devname.c:166:3: note: 'sprintf' output between 19 and 274 bytes into a destination of size 256
sprintf(path, "/sys/block/%s/slaves", de->d_name);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
---
libblkid/src/devname.c | 2 +-
login-utils/last.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/libblkid/src/devname.c b/libblkid/src/devname.c
index ba3c57a41..59029ec06 100644
--- a/libblkid/src/devname.c
+++ b/libblkid/src/devname.c
@@ -152,7 +152,7 @@ static int is_dm_leaf(const char *devname)
{
struct dirent *de, *d_de;
DIR *dir, *d_dir;
- char path[256];
+ char path[NAME_MAX + 18 + 1];
int ret = 1;
if ((dir = opendir("/sys/block")) == NULL)
diff --git a/login-utils/last.c b/login-utils/last.c
index f93ec7fbf..c90b574e5 100644
--- a/login-utils/last.c
+++ b/login-utils/last.c
@@ -598,7 +598,7 @@ static void __attribute__((__noreturn__)) usage(const struct last_control *ctl,
static int is_phantom(const struct last_control *ctl, struct utmpx *ut)
{
struct passwd *pw;
- char path[32];
+ char path[sizeof(ut->ut_line) + 16];
int ret = 0;
if (ut->ut_tv.tv_sec < ctl->boot_time.tv_sec)
--
2.12.3
next prev parent reply other threads:[~2017-06-12 8:50 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-06-12 8:49 [PATCH 0/6] fix various minor issues and warnings Ruediger Meier
2017-06-12 8:49 ` [PATCH 1/6] tests: fix fincore, don't use variable COLUMNS Ruediger Meier
2017-06-12 8:49 ` [PATCH 2/6] libmount: btrfs, remove unused setter functions Ruediger Meier
2017-06-12 8:49 ` [PATCH 3/6] hwclock: fix warning [-Winvalid-noreturn] Ruediger Meier
2017-06-12 8:49 ` Ruediger Meier [this message]
2017-06-12 8:49 ` [PATCH 5/6] misc: fix gcc-7 snprintf warnings -Wformat-truncation Ruediger Meier
2017-06-12 19:27 ` Rüdiger Meier
2017-06-12 8:49 ` [PATCH 6/6] libblkid: fix gcc-7 warning -Wint-in-bool-context Ruediger Meier
2017-06-13 13:47 ` [PATCH 0/6] fix various minor issues and warnings Karel Zak
2017-06-13 15:18 ` Rüdiger Meier
2017-06-14 10:10 ` Karel Zak
2017-06-14 11:06 ` Ruediger Meier
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=20170612084958.22054-5-sweet_f_a@gmx.de \
--to=sweet_f_a@gmx.de \
--cc=util-linux@vger.kernel.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