gfs2-utils: RHEL7 - mkfs.gfs2: Terminate lockproto and locktable strings explicitly
Andrew Price
andyp at fedoraproject.org
Tue Apr 7 21:22:38 UTC 2015
Gitweb: http://git.fedorahosted.org/git/?p=gfs2-utils.git;a=commitdiff;h=29daf41307107693525caa692f9e74639757f650
Commit: 29daf41307107693525caa692f9e74639757f650
Parent: c883c0cef51b116fb6c20bfdfe39542a37e45d5a
Author: Andrew Price <anprice at redhat.com>
AuthorDate: Mon Oct 6 14:22:16 2014 +0100
Committer: Andrew Price <anprice at redhat.com>
CommitterDate: Wed Apr 1 16:51:34 2015 +0100
mkfs.gfs2: Terminate lockproto and locktable strings explicitly
Although the length of the lockproto and locktable options are checked
in test_locking() already, coverity still complains about our use of
strcpy here, and it can't hurt to be a bit more defensive in our string
handling so switch to strncpy and terminate the strings explicitly.
Signed-off-by: Andrew Price <anprice at redhat.com>
---
gfs2/mkfs/main_mkfs.c | 6 ++++--
1 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/gfs2/mkfs/main_mkfs.c b/gfs2/mkfs/main_mkfs.c
index f4b8fe6..282878d 100644
--- a/gfs2/mkfs/main_mkfs.c
+++ b/gfs2/mkfs/main_mkfs.c
@@ -966,8 +966,10 @@ void main_mkfs(int argc, char *argv[])
build_root(&sbd);
sb.sb_root_dir = sbd.md.rooti->i_di.di_num;
- strcpy(sb.sb_lockproto, opts.lockproto);
- strcpy(sb.sb_locktable, opts.locktable);
+ strncpy(sb.sb_lockproto, opts.lockproto, GFS2_LOCKNAME_LEN);
+ strncpy(sb.sb_locktable, opts.locktable, GFS2_LOCKNAME_LEN);
+ sb.sb_lockproto[GFS2_LOCKNAME_LEN - 1] = '\0';
+ sb.sb_locktable[GFS2_LOCKNAME_LEN - 1] = '\0';
do_init_inum(&sbd);
do_init_statfs(&sbd);
More information about the cluster-commits
mailing list