From: Andrew Price <anprice@redhat.com>
To: cluster-devel.redhat.com
Subject: [Cluster-devel] [PATCH] glocktop: Fix new -Wformat-overflow warnings
Date: Tue, 10 Apr 2018 12:33:09 +0100 [thread overview]
Message-ID: <20180410113309.11290-1-anprice@redhat.com> (raw)
Fixes new warnings in glocktop that appeared in Fedora 28 (gcc 8.0.1 /
glibc 2.27), e.g.:
glocktop.c:1806:30: warning: '_waiters' directive writing 8 bytes
into a region of size between 2 and 4091 [-Wformat-overflow=]
Signed-off-by: Andrew Price <anprice@redhat.com>
---
gfs2/glocktop/glocktop.c | 22 +++++++++++++++-------
1 file changed, 15 insertions(+), 7 deletions(-)
diff --git a/gfs2/glocktop/glocktop.c b/gfs2/glocktop/glocktop.c
index 0305d3dd..7d65ac4a 100644
--- a/gfs2/glocktop/glocktop.c
+++ b/gfs2/glocktop/glocktop.c
@@ -921,7 +921,7 @@ static void show_dlm_grants(int locktype, const char *g_line, int dlmgrants,
int summary)
{
int i;
- char dlm_resid[64];
+ char dlm_resid[75];
unsigned int lkb_id, lkbnodeid, remid, ownpid, exflags, flags, status;
unsigned int grmode, rqmode, nodeid, length;
unsigned long long xid, us;
@@ -1596,7 +1596,7 @@ static void parse_glocks_file(int fd, const char *fsname, int dlmwaiters,
int dlmgrants, int trace_dir_path,
int show_held, int help, int summary)
{
- char fstitle[96], fsdlm[96];
+ char fstitle[96], fsdlm[105];
char ctimestr[64];
time_t t;
int i;
@@ -1652,7 +1652,7 @@ int main(int argc, char **argv)
{
int fd;
DIR *dir = NULL;
- char fn[PATH_MAX];
+ char *fn;
struct dirent *dent;
int retval;
int refresh_time = REFRESH_TIME;
@@ -1772,8 +1772,12 @@ int main(int argc, char **argv)
while (!done) {
struct timeval tv;
- sprintf(fn, "%s/gfs2/", debugfs);
+ if (asprintf(&fn, "%s/gfs2/", debugfs) == -1) {
+ perror(argv[0]);
+ exit(-1);
+ }
dir = opendir(fn);
+ free(fn);
if (!dir) {
if (interactive) {
@@ -1787,7 +1791,7 @@ int main(int argc, char **argv)
display_title_lines();
while ((dent = readdir(dir))) {
const char *fsname;
- char dlm_fn[PATH_MAX];
+ char dlm_fn[PATH_MAX+5+8]; /* "/dlm/" and "_waiters" */
FILE *dlmf;
int dlmfd;
@@ -1822,8 +1826,10 @@ int main(int argc, char **argv)
}
}
- sprintf(fn, "%s/gfs2/%s/glocks", debugfs,
- dent->d_name);
+ if (asprintf(&fn, "%s/gfs2/%s/glocks", debugfs, dent->d_name) == -1) {
+ perror(argv[0]);
+ exit(-1);
+ }
fd = open(fn, O_RDONLY);
if (fd < 0) {
if (interactive) {
@@ -1831,8 +1837,10 @@ int main(int argc, char **argv)
endwin();
}
perror(fn);
+ free(fn);
exit(-1);
}
+ free(fn);
parse_glocks_file(fd, fsname, dlmwaiters, dlmgrants,
trace_dir_path, show_held, help,
summary);
--
2.16.2
next reply other threads:[~2018-04-10 11:33 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-04-10 11:33 Andrew Price [this message]
2018-04-10 13:05 ` [Cluster-devel] [PATCH] glocktop: Fix new -Wformat-overflow warnings Bob Peterson
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=20180410113309.11290-1-anprice@redhat.com \
--to=anprice@redhat.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: 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).