]> granicus.if.org Git - zfs/commitdiff
Fix coverity defects: CID 49339, 153393
authorcao <cao.xuewen@zte.com.cn>
Tue, 18 Oct 2016 17:31:57 +0000 (01:31 +0800)
committerBrian Behlendorf <behlendorf1@llnl.gov>
Tue, 18 Oct 2016 17:31:57 +0000 (10:31 -0700)
CID 49339: Type:Buffer not null terminated
CID 153393: Type:Buffer not null terminated

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: <cao.xuewen cao.xuewen@zte.com.cn>
Closes #5296

module/zfs/zfs_vfsops.c
tests/zfs-tests/cmd/xattrtest/xattrtest.c

index 63b7f923087ff92d7d77d58ce5fb2b26f9bc44a8..eb73f3b600c7b729397ba90b9a130d1556756f90 100644 (file)
@@ -553,7 +553,7 @@ zfs_userspace_one(zfs_sb_t *zsb, zfs_userquota_prop_t type,
                return (0);
 
        if (type == ZFS_PROP_USEROBJUSED || type == ZFS_PROP_GROUPOBJUSED) {
-               strncpy(buf, DMU_OBJACCT_PREFIX, DMU_OBJACCT_PREFIX_LEN);
+               strlcpy(buf, DMU_OBJACCT_PREFIX, DMU_OBJACCT_PREFIX_LEN);
                offset = DMU_OBJACCT_PREFIX_LEN;
        }
 
index 68a809f177e6452e20af9aa16019f6c224fc2106..991dd066db875fb49ca5632631ef8fd75cdb456c 100644 (file)
@@ -168,6 +168,7 @@ parse_args(int argc, char **argv)
                        break;
                case 'p':
                        strncpy(path, optarg, PATH_MAX);
+                       path[PATH_MAX - 1] = '\0';
                        break;
                case 'c':
                        synccaches = 1;
@@ -177,6 +178,7 @@ parse_args(int argc, char **argv)
                        break;
                case 't':
                        strncpy(script, optarg, PATH_MAX);
+                       script[PATH_MAX - 1] = '\0';
                        break;
                case 'e':
                        seed = strtol(optarg, NULL, 0);