diff options
author | cao <[email protected]> | 2016-09-26 06:08:28 +0800 |
---|---|---|
committer | Brian Behlendorf <[email protected]> | 2016-09-25 15:08:28 -0700 |
commit | 680eada9b05415a8e564eb345f062f357d66f0f1 (patch) | |
tree | c5f5e5d881d09166544b6a18bdf00f8dea5d48fa | |
parent | 92bc9278689fcce48183182f2488ead42a9eb790 (diff) |
Fix coverity defects: CID 147650, 147649, 147647, 147646
coverity scan CID:147650, Type:copy into fixed size buffer.
coverity scan CID:147649, Type:copy into fixed size buffer.
coverity scan CID:147647, Type:copy into fixed size buffer.
coverity scan CID:147646, Type:copy into fixed size buffer.
Reviewed-by: Brian Behlendorf <[email protected]>
Signed-off-by: cao.xuewen <[email protected]>
Closes #5161
-rw-r--r-- | module/zfs/dsl_dir.c | 3 | ||||
-rw-r--r-- | module/zfs/zap_micro.c | 3 | ||||
-rw-r--r-- | module/zfs/zfs_ioctl.c | 8 |
3 files changed, 9 insertions, 5 deletions
diff --git a/module/zfs/dsl_dir.c b/module/zfs/dsl_dir.c index ae67b362e..59d382214 100644 --- a/module/zfs/dsl_dir.c +++ b/module/zfs/dsl_dir.c @@ -203,7 +203,8 @@ dsl_dir_hold_obj(dsl_pool_t *dp, uint64_t ddobj, sizeof (foundobj), 1, &foundobj); ASSERT(err || foundobj == ddobj); #endif - (void) strcpy(dd->dd_myname, tail); + (void) strlcpy(dd->dd_myname, tail, + sizeof (dd->dd_myname)); } else { err = zap_value_search(dp->dp_meta_objset, dsl_dir_phys(dd->dd_parent)-> diff --git a/module/zfs/zap_micro.c b/module/zfs/zap_micro.c index df952146b..a15e22c5b 100644 --- a/module/zfs/zap_micro.c +++ b/module/zfs/zap_micro.c @@ -1110,7 +1110,8 @@ again: if (mze->mze_name[0] == 0) { mze->mze_value = value; mze->mze_cd = cd; - (void) strcpy(mze->mze_name, zn->zn_key_orig); + (void) strlcpy(mze->mze_name, zn->zn_key_orig, + sizeof (mze->mze_name)); zap->zap_m.zap_num_entries++; zap->zap_m.zap_alloc_next = i+1; if (zap->zap_m.zap_alloc_next == diff --git a/module/zfs/zfs_ioctl.c b/module/zfs/zfs_ioctl.c index 0385bfcbb..64f630108 100644 --- a/module/zfs/zfs_ioctl.c +++ b/module/zfs/zfs_ioctl.c @@ -3928,12 +3928,13 @@ zfs_check_clearable(char *dataset, nvlist_t *props, nvlist_t **errlist) VERIFY(nvlist_alloc(&errors, NV_UNIQUE_NAME, KM_SLEEP) == 0); zc = kmem_alloc(sizeof (zfs_cmd_t), KM_SLEEP); - (void) strcpy(zc->zc_name, dataset); + (void) strlcpy(zc->zc_name, dataset, sizeof (zc->zc_name)); pair = nvlist_next_nvpair(props, NULL); while (pair != NULL) { next_pair = nvlist_next_nvpair(props, pair); - (void) strcpy(zc->zc_value, nvpair_name(pair)); + (void) strlcpy(zc->zc_value, nvpair_name(pair), + sizeof (zc->zc_value)); if ((err = zfs_check_settable(dataset, pair, CRED())) != 0 || (err = zfs_secpolicy_inherit_prop(zc, NULL, CRED())) != 0) { VERIFY(nvlist_remove_nvpair(props, pair) == 0); @@ -4951,7 +4952,8 @@ zfs_ioc_tmp_snapshot(zfs_cmd_t *zc) error = dsl_dataset_snapshot_tmp(zc->zc_name, snap_name, minor, hold_name); if (error == 0) - (void) strcpy(zc->zc_value, snap_name); + (void) strlcpy(zc->zc_value, snap_name, + sizeof (zc->zc_value)); strfree(snap_name); strfree(hold_name); zfs_onexit_fd_rele(zc->zc_cleanup_fd); |