This is an automated email from the git hooks/post-receive script.
andyp pushed a commit to branch master
in repository gfs2-utils.
The following commit(s) were added to refs/heads/master by this push:
new d9a32a2 gfs2-utils: String handling fix-ups for gcc9
d9a32a2 is described below
commit d9a32a2d4f629e85c10a62ed73c6e22a1b7a5cf7
Author: Andrew Price <anprice(a)redhat.com>
AuthorDate: Wed Jan 23 16:53:49 2019 +0000
gfs2-utils: String handling fix-ups for gcc9
Silence new warnings about (notional) printf format overflows and
truncations.
Signed-off-by: Andrew Price <anprice(a)redhat.com>
---
gfs2/glocktop/glocktop.c | 19 ++++++++++++-------
gfs2/mkfs/main_mkfs.c | 4 ++--
gfs2/tune/super.c | 2 +-
3 files changed, 15 insertions(+), 10 deletions(-)
diff --git a/gfs2/glocktop/glocktop.c b/gfs2/glocktop/glocktop.c
index 7d65ac4..2f74a7f 100644
--- a/gfs2/glocktop/glocktop.c
+++ b/gfs2/glocktop/glocktop.c
@@ -1607,7 +1607,7 @@ static void parse_glocks_file(int fd, const char *fsname, int dlmwaiters,
ctimestr[63] = '\0';
memset(fstitle, 0, sizeof(fstitle));
memset(fsdlm, 0, sizeof(fsdlm));
- sprintf(fstitle, "@ %s %s ", fsname, ctimestr);
+ sprintf(fstitle, "@ %.22s %s ", fsname, ctimestr);
if (dlmwaiters) {
sprintf(fsdlm, "dlm: %s/%s/%s [", dlm_dirtbl_size,
dlm_rsbtbl_size, dlm_lkbtbl_size);
@@ -1791,7 +1791,7 @@ int main(int argc, char **argv)
display_title_lines();
while ((dent = readdir(dir))) {
const char *fsname;
- char dlm_fn[PATH_MAX+5+8]; /* "/dlm/" and "_waiters" */
+ char *dlm_fn;
FILE *dlmf;
int dlmfd;
@@ -1806,24 +1806,29 @@ int main(int argc, char **argv)
else
fsname = dent->d_name;
- memset(dlm_fn, 0, sizeof(dlm_fn));
- sprintf(dlm_fn, "%s/dlm/%s_waiters", debugfs, fsname);
+ if (asprintf(&dlm_fn, "%s/dlm/%s_waiters", debugfs, fsname) == -1) {
+ perror("Failed to construct dlm waiters debugfs path");
+ exit(-1);
+ }
dlmf = fopen(dlm_fn, "rt");
if (dlmf) {
dlmwaiters = parse_dlm_waiters(dlmf, fsname);
fclose(dlmf);
}
+ free(dlm_fn);
if (print_dlm_grants) {
- memset(dlm_fn, 0, sizeof(dlm_fn));
- sprintf(dlm_fn, "%s/dlm/%s_locks", debugfs,
- fsname);
+ if (asprintf(&dlm_fn, "%s/dlm/%s_locks", debugfs, fsname) == -1) {
+ perror("Failed to construct dlm locks debugfs path");
+ exit(-1);
+ }
dlmfd = open(dlm_fn, O_RDONLY);
if (dlmfd > 0) {
dlmgrants = parse_dlm_grants(dlmfd,
fsname);
close(dlmfd);
}
+ free(dlm_fn);
}
if (asprintf(&fn, "%s/gfs2/%s/glocks", debugfs, dent->d_name) == -1) {
diff --git a/gfs2/mkfs/main_mkfs.c b/gfs2/mkfs/main_mkfs.c
index 846b341..7aeae69 100644
--- a/gfs2/mkfs/main_mkfs.c
+++ b/gfs2/mkfs/main_mkfs.c
@@ -1143,8 +1143,8 @@ int main(int argc, char *argv[])
build_root(&sbd);
sb.sb_root_dir = sbd.md.rooti->i_di.di_num;
- strncpy(sb.sb_lockproto, opts.lockproto, GFS2_LOCKNAME_LEN);
- strncpy(sb.sb_locktable, opts.locktable, GFS2_LOCKNAME_LEN);
+ memcpy(sb.sb_lockproto, opts.lockproto, GFS2_LOCKNAME_LEN);
+ memcpy(sb.sb_locktable, opts.locktable, GFS2_LOCKNAME_LEN);
sb.sb_lockproto[GFS2_LOCKNAME_LEN - 1] = '\0';
sb.sb_locktable[GFS2_LOCKNAME_LEN - 1] = '\0';
diff --git a/gfs2/tune/super.c b/gfs2/tune/super.c
index c4ffd7e..f4b7d85 100644
--- a/gfs2/tune/super.c
+++ b/gfs2/tune/super.c
@@ -117,7 +117,7 @@ int change_lockproto(struct tunegfs2 *tfs, const char *lockproto)
return EX_DATAERR;
}
memset(tfs->sb->sb_lockproto, '\0', GFS2_LOCKNAME_LEN);
- strncpy(tfs->sb->sb_lockproto, lockproto, l);
+ memcpy(tfs->sb->sb_lockproto, lockproto, l);
return 0;
}
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.