From c9e319faae9677aa0dddfbf9973b9e8fc3feb06c Mon Sep 17 00:00:00 2001 From: Jorgen Lundman Date: Mon, 8 Jun 2020 03:42:12 +0900 Subject: 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 Reviewed-by: Brian Behlendorf Signed-off-by: Jorgen Lundman Closes #10400 --- module/zfs/zfs_ioctl.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'module/zfs/zfs_ioctl.c') diff --git a/module/zfs/zfs_ioctl.c b/module/zfs/zfs_ioctl.c index d55ce20ef..6e7e9b9f0 100644 --- a/module/zfs/zfs_ioctl.c +++ b/module/zfs/zfs_ioctl.c @@ -2504,7 +2504,8 @@ zfs_prop_set_special(const char *dsname, zprop_source_t source, zfs_cmd_t *zc; zc = kmem_zalloc(sizeof (zfs_cmd_t), KM_SLEEP); - (void) strcpy(zc->zc_name, dsname); + (void) strlcpy(zc->zc_name, dsname, + sizeof (zc->zc_name)); (void) zfs_ioc_userspace_upgrade(zc); (void) zfs_ioc_id_quota_upgrade(zc); kmem_free(zc, sizeof (zfs_cmd_t)); @@ -5271,7 +5272,7 @@ zfs_ioc_recv_new(const char *fsname, nvlist_t *innvl, nvlist_t *outnvl) strchr(snapname, '%')) return (SET_ERROR(EINVAL)); - (void) strcpy(tofs, snapname); + (void) strlcpy(tofs, snapname, sizeof (tofs)); tosnap = strchr(tofs, '@'); *tosnap++ = '\0'; -- cgit v1.2.3