diff options
author | Jorgen Lundman <[email protected]> | 2020-06-08 03:42:12 +0900 |
---|---|---|
committer | GitHub <[email protected]> | 2020-06-07 11:42:12 -0700 |
commit | c9e319faae9677aa0dddfbf9973b9e8fc3feb06c (patch) | |
tree | 3d6677913e5f26d91b7f35bcb62b9b354287db61 /module/zfs/zcp_get.c | |
parent | 60265072e02049be708f74cf0865eba2434a2d85 (diff) |
Replace sprintf()->snprintf() and strcpy()->strlcpy()
The strcpy() and sprintf() functions are deprecated on some platforms.
Care is needed to ensure correct size is used. If some platforms
miss snprintf, we can add a #define to sprintf, likewise strlcpy().
The biggest change is adding a size parameter to zfs_id_to_fuidstr().
The various *_impl_get() functions are only used on linux and have
not yet been updated.
Reviewed by: Sean Eric Fagan <[email protected]>
Reviewed-by: Brian Behlendorf <[email protected]>
Signed-off-by: Jorgen Lundman <[email protected]>
Closes #10400
Diffstat (limited to 'module/zfs/zcp_get.c')
-rw-r--r-- | module/zfs/zcp_get.c | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/module/zfs/zcp_get.c b/module/zfs/zcp_get.c index 311875583..a23230ffb 100644 --- a/module/zfs/zcp_get.c +++ b/module/zfs/zcp_get.c @@ -82,13 +82,13 @@ get_objset_type_name(dsl_dataset_t *ds, char *str) return (error); switch (type) { case ZFS_TYPE_SNAPSHOT: - (void) strcpy(str, "snapshot"); + (void) strlcpy(str, "snapshot", ZAP_MAXVALUELEN); break; case ZFS_TYPE_FILESYSTEM: - (void) strcpy(str, "filesystem"); + (void) strlcpy(str, "filesystem", ZAP_MAXVALUELEN); break; case ZFS_TYPE_VOLUME: - (void) strcpy(str, "volume"); + (void) strlcpy(str, "volume", ZAP_MAXVALUELEN); break; default: return (EINVAL); @@ -321,11 +321,11 @@ get_special_prop(lua_State *state, dsl_dataset_t *ds, const char *dsname, break; case ZFS_PROP_FILESYSTEM_COUNT: error = dsl_dir_get_filesystem_count(ds->ds_dir, &numval); - (void) strcpy(setpoint, ""); + (void) strlcpy(setpoint, "", ZFS_MAX_DATASET_NAME_LEN); break; case ZFS_PROP_SNAPSHOT_COUNT: error = dsl_dir_get_snapshot_count(ds->ds_dir, &numval); - (void) strcpy(setpoint, ""); + (void) strlcpy(setpoint, "", ZFS_MAX_DATASET_NAME_LEN); break; case ZFS_PROP_NUMCLONES: numval = dsl_get_numclones(ds); @@ -367,7 +367,8 @@ get_special_prop(lua_State *state, dsl_dataset_t *ds, const char *dsname, sizeof (numval), 1, &numval); } if (error == 0) - (void) strcpy(setpoint, dsname); + (void) strlcpy(setpoint, dsname, + ZFS_MAX_DATASET_NAME_LEN); break; case ZFS_PROP_VOLBLOCKSIZE: { @@ -693,9 +694,10 @@ parse_written_prop(const char *dataset_name, const char *prop_name, ASSERT(zfs_prop_written(prop_name)); const char *name = prop_name + ZFS_WRITTEN_PROP_PREFIX_LEN; if (strchr(name, '@') == NULL) { - (void) sprintf(snap_name, "%s@%s", dataset_name, name); + (void) snprintf(snap_name, ZFS_MAX_DATASET_NAME_LEN, "%s@%s", + dataset_name, name); } else { - (void) strcpy(snap_name, name); + (void) strlcpy(snap_name, name, ZFS_MAX_DATASET_NAME_LEN); } } |