diff --git a/include/sys/zfs_fuid.h b/include/sys/zfs_fuid.h index fa399f11542b..b5b37db29468 100644 --- a/include/sys/zfs_fuid.h +++ b/include/sys/zfs_fuid.h @@ -117,7 +117,7 @@ extern int zfs_fuid_find_by_domain(zfsvfs_t *, const char *domain, extern const char *zfs_fuid_find_by_idx(zfsvfs_t *zfsvfs, uint32_t idx); extern void zfs_fuid_txhold(zfsvfs_t *zfsvfs, dmu_tx_t *tx); extern int zfs_id_to_fuidstr(zfsvfs_t *zfsvfs, const char *domain, uid_t rid, - char *buf, boolean_t addok); + char *buf, size_t len, boolean_t addok); #endif char *zfs_fuid_idx_domain(avl_tree_t *, uint32_t); diff --git a/module/icp/algs/aes/aes_impl.c b/module/icp/algs/aes/aes_impl.c index 2c123b8f556b..19b350434d75 100644 --- a/module/icp/algs/aes/aes_impl.c +++ b/module/icp/algs/aes/aes_impl.c @@ -330,7 +330,7 @@ aes_impl_init(void) sizeof (aes_fastest_impl)); #endif - strcpy(aes_fastest_impl.name, "fastest"); + strlcpy(aes_fastest_impl.name, "fastest", sizeof(aes_fastest_impl.name)); /* Finish initialization */ atomic_swap_32(&icp_aes_impl, user_sel_impl); @@ -405,6 +405,7 @@ aes_impl_set(const char *val) return (err); } +#ifndef __APPLE__ #if defined(_KERNEL) static int @@ -413,6 +414,7 @@ icp_aes_impl_set(const char *val, zfs_kernel_param_t *kp) return (aes_impl_set(val)); } +#if defined(__linux__) || defined(__FreeBSD__) static int icp_aes_impl_get(char *buffer, zfs_kernel_param_t *kp) { @@ -436,6 +438,8 @@ icp_aes_impl_get(char *buffer, zfs_kernel_param_t *kp) return (cnt); } +#endif +#endif module_param_call(icp_aes_impl, icp_aes_impl_set, icp_aes_impl_get, NULL, 0644); diff --git a/module/icp/algs/modes/gcm.c b/module/icp/algs/modes/gcm.c index 7a94d3dbb193..6eb198a94528 100644 --- a/module/icp/algs/modes/gcm.c +++ b/module/icp/algs/modes/gcm.c @@ -843,7 +843,8 @@ gcm_impl_init(void) sizeof (gcm_fastest_impl)); } - strcpy(gcm_fastest_impl.name, "fastest"); + strlcpy(gcm_fastest_impl.name, "fastest", + sizeof(gcm_fastest_impl.name)); #ifdef CAN_USE_GCM_ASM /* @@ -955,6 +956,8 @@ gcm_impl_set(const char *val) return (err); } +#ifndef __APPLE__ + #if defined(_KERNEL) static int @@ -963,6 +966,7 @@ icp_gcm_impl_set(const char *val, zfs_kernel_param_t *kp) return (gcm_impl_set(val)); } +#if defined(__linux__) || defined(__FreeBSD__) static int icp_gcm_impl_get(char *buffer, zfs_kernel_param_t *kp) { @@ -992,6 +996,8 @@ icp_gcm_impl_get(char *buffer, zfs_kernel_param_t *kp) return (cnt); } +#endif +#endif module_param_call(icp_gcm_impl, icp_gcm_impl_set, icp_gcm_impl_get, NULL, 0644); diff --git a/module/icp/os/modhash.c b/module/icp/os/modhash.c index 5e216ed6a04a..685ae53b9f3c 100644 --- a/module/icp/os/modhash.c +++ b/module/icp/os/modhash.c @@ -453,17 +453,19 @@ mod_hash_create_extended( int sleep) /* whether to sleep for mem */ { mod_hash_t *mod_hash; + int size; ASSERT(hname && keycmp && hash_alg && vdtor && kdtor); if ((mod_hash = kmem_zalloc(MH_SIZE(nchains), sleep)) == NULL) return (NULL); - mod_hash->mh_name = kmem_alloc(strlen(hname) + 1, sleep); + size = strlen(hname) + 1; + mod_hash->mh_name = kmem_alloc(size, sleep); if (mod_hash->mh_name == NULL) { kmem_free(mod_hash, MH_SIZE(nchains)); return (NULL); } - (void) strcpy(mod_hash->mh_name, hname); + (void) strlcpy(mod_hash->mh_name, hname, size); rw_init(&mod_hash->mh_contents, NULL, RW_DEFAULT, NULL); mod_hash->mh_sleep = sleep; diff --git a/module/lua/lstrlib.c b/module/lua/lstrlib.c index 49ba70fafdb8..7666614611ea 100644 --- a/module/lua/lstrlib.c +++ b/module/lua/lstrlib.c @@ -853,9 +853,9 @@ static void addquoted (lua_State *L, luaL_Buffer *b, int arg) { else if (*s == '\0' || iscntrl(uchar(*s))) { char buff[10]; if (!isdigit(uchar(*(s+1)))) - sprintf(buff, "\\%d", (int)uchar(*s)); + snprintf(buff, sizeof(buff), "\\%d", (int)uchar(*s)); else - sprintf(buff, "\\%03d", (int)uchar(*s)); + snprintf(buff, sizeof(buff), "\\%03d", (int)uchar(*s)); luaL_addstring(b, buff); } else @@ -894,7 +894,7 @@ static void addlenmod (char *form, const char *lenmod) { size_t l = strlen(form); size_t lm = strlen(lenmod); char spec = form[l - 1]; - strcpy(form + l - 1, lenmod); + strlcpy(form + l - 1, lenmod, MAX_FORMAT); form[l + lm - 1] = spec; form[l + lm] = '\0'; } diff --git a/module/os/linux/zfs/zfs_vfsops.c b/module/os/linux/zfs/zfs_vfsops.c index 6a713524ff92..dc382af010f1 100644 --- a/module/os/linux/zfs/zfs_vfsops.c +++ b/module/os/linux/zfs/zfs_vfsops.c @@ -1021,7 +1021,7 @@ zfs_statfs_project(zfsvfs_t *zfsvfs, znode_t *zp, struct kstatfs *statp, strlcpy(buf, DMU_OBJACCT_PREFIX, DMU_OBJACCT_PREFIX_LEN + 1); err = zfs_id_to_fuidstr(zfsvfs, NULL, zp->z_projid, buf + offset, - B_FALSE); + sizeof(buf) - offset, B_FALSE); if (err) return (err); diff --git a/module/zfs/ddt.c b/module/zfs/ddt.c index 5dcb36ce6f88..33dad8bdfa07 100644 --- a/module/zfs/ddt.c +++ b/module/zfs/ddt.c @@ -253,7 +253,7 @@ void ddt_object_name(ddt_t *ddt, enum ddt_type type, enum ddt_class class, char *name) { - (void) sprintf(name, DMU_POOL_DDT, + (void) snprintf(name, DDT_NAMELEN, DMU_POOL_DDT, zio_checksum_table[ddt->ddt_checksum].ci_name, ddt_ops[type]->ddt_op_name, ddt_class_name[class]); } diff --git a/module/zfs/dmu_objset.c b/module/zfs/dmu_objset.c index 5b8069bd69d2..4a87ee60451d 100644 --- a/module/zfs/dmu_objset.c +++ b/module/zfs/dmu_objset.c @@ -1870,14 +1870,14 @@ do_userquota_update(objset_t *os, userquota_cache_t *cache, uint64_t used, if (subtract) delta = -delta; - (void) sprintf(name, "%llx", (longlong_t)user); + (void) snprintf(name, sizeof(name), "%llx", (longlong_t)user); userquota_update_cache(&cache->uqc_user_deltas, name, delta); - (void) sprintf(name, "%llx", (longlong_t)group); + (void) snprintf(name, sizeof(name), "%llx", (longlong_t)group); userquota_update_cache(&cache->uqc_group_deltas, name, delta); if (dmu_objset_projectquota_enabled(os)) { - (void) sprintf(name, "%llx", (longlong_t)project); + (void) snprintf(name, sizeof(name), "%llx", (longlong_t)project); userquota_update_cache(&cache->uqc_project_deltas, name, delta); } @@ -2438,7 +2438,7 @@ dmu_snapshot_list_next(objset_t *os, int namelen, char *name, return (SET_ERROR(ENAMETOOLONG)); } - (void) strcpy(name, attr.za_name); + (void) strlcpy(name, attr.za_name, namelen); if (idp) *idp = attr.za_first_integer; if (case_conflict) @@ -2483,7 +2483,7 @@ dmu_dir_list_next(objset_t *os, int namelen, char *name, return (SET_ERROR(ENAMETOOLONG)); } - (void) strcpy(name, attr.za_name); + (void) strlcpy(name, attr.za_name, namelen); if (idp) *idp = attr.za_first_integer; zap_cursor_advance(&cursor); diff --git a/module/zfs/dmu_send.c b/module/zfs/dmu_send.c index a5df78edd855..42dc8b453737 100644 --- a/module/zfs/dmu_send.c +++ b/module/zfs/dmu_send.c @@ -2001,7 +2001,8 @@ create_begin_record(struct dmu_send_params *dspp, objset_t *os, if (dspp->savedok) { drrb->drr_toguid = dspp->saved_guid; - strcpy(drrb->drr_toname, dspp->saved_toname); + strlcpy(drrb->drr_toname, dspp->saved_toname, + sizeof(drrb->drr_toname)); } else { dsl_dataset_name(to_ds, drrb->drr_toname); if (!to_ds->ds_is_snapshot) { diff --git a/module/zfs/dsl_dataset.c b/module/zfs/dsl_dataset.c index 2d6e95e31430..74a8c1c54a9f 100644 --- a/module/zfs/dsl_dataset.c +++ b/module/zfs/dsl_dataset.c @@ -906,7 +906,7 @@ void dsl_dataset_name(dsl_dataset_t *ds, char *name) { if (ds == NULL) { - (void) strcpy(name, "mos"); + (void) strlcpy(name, "mos", MAXNAMELEN); } else { dsl_dir_name(ds->ds_dir, name); VERIFY0(dsl_dataset_get_snapname(ds)); @@ -2429,7 +2429,8 @@ get_receive_resume_stats_impl(dsl_dataset_t *ds) str = kmem_alloc(compressed_size * 2 + 1, KM_SLEEP); for (int i = 0; i < compressed_size; i++) { - (void) sprintf(str + i * 2, "%02x", compressed[i]); + (void) snprintf(str + i * 2, compressed_size * 2 + 1, + "%02x", compressed[i]); } str[compressed_size * 2] = '\0'; char *propval = kmem_asprintf("%u-%llx-%llx-%s", @@ -3911,7 +3912,8 @@ dsl_dataset_promote(const char *name, char *conflsnap) */ snap_pair = nvlist_next_nvpair(ddpa.err_ds, NULL); if (snap_pair != NULL && conflsnap != NULL) - (void) strcpy(conflsnap, nvpair_name(snap_pair)); + (void) strlcpy(conflsnap, nvpair_name(snap_pair), + ZFS_MAX_DATASET_NAME_LEN); fnvlist_free(ddpa.err_ds); return (error); diff --git a/module/zfs/dsl_dir.c b/module/zfs/dsl_dir.c index 63ecb1d39e8f..0afac9045a1f 100644 --- a/module/zfs/dsl_dir.c +++ b/module/zfs/dsl_dir.c @@ -245,7 +245,8 @@ dsl_dir_hold_obj(dsl_pool_t *dp, uint64_t ddobj, if (err != 0) goto errout; } else { - (void) strcpy(dd->dd_myname, spa_name(dp->dp_spa)); + (void) strlcpy(dd->dd_myname, spa_name(dp->dp_spa), + sizeof (dd->dd_myname)); } if (dsl_dir_is_clone(dd)) { @@ -423,7 +424,7 @@ getcomponent(const char *path, char *component, const char **nextp) return (SET_ERROR(EINVAL)); if (strlen(path) >= ZFS_MAX_DATASET_NAME_LEN) return (SET_ERROR(ENAMETOOLONG)); - (void) strcpy(component, path); + (void) strlcpy(component, path, MAXNAMELEN); p = NULL; } else if (p[0] == '/') { if (p - path >= ZFS_MAX_DATASET_NAME_LEN) diff --git a/module/zfs/dsl_prop.c b/module/zfs/dsl_prop.c index 0b4bf23ee51c..f6ff9ae47192 100644 --- a/module/zfs/dsl_prop.c +++ b/module/zfs/dsl_prop.c @@ -132,8 +132,9 @@ dsl_prop_get_dd(dsl_dir_t *dd, const char *propname, if (inheriting) { dsl_dir_name(dd, setpoint); } else { - (void) strcpy(setpoint, - ZPROP_SOURCE_VAL_RECVD); + (void) strlcpy(setpoint, + ZPROP_SOURCE_VAL_RECVD, + MAXNAMELEN); } } break; @@ -206,8 +207,9 @@ dsl_prop_get_ds(dsl_dataset_t *ds, const char *propname, kmem_strfree(recvdstr); if (err != ENOENT) { if (setpoint != NULL && err == 0) - (void) strcpy(setpoint, - ZPROP_SOURCE_VAL_RECVD); + (void) strlcpy(setpoint, + ZPROP_SOURCE_VAL_RECVD, + MAXNAMELEN); return (err); } } diff --git a/module/zfs/dsl_scan.c b/module/zfs/dsl_scan.c index f095017936c0..1a933e3e63a3 100644 --- a/module/zfs/dsl_scan.c +++ b/module/zfs/dsl_scan.c @@ -360,7 +360,7 @@ scan_init(void) for (int i = 0; i < SPA_DVAS_PER_BP; i++) { char name[36]; - (void) sprintf(name, "sio_cache_%d", i); + (void) snprintf(name, sizeof(name), "sio_cache_%d", i); sio_cache[i] = kmem_cache_create(name, (sizeof (scan_io_t) + ((i + 1) * sizeof (dva_t))), 0, NULL, NULL, NULL, NULL, NULL, 0); diff --git a/module/zfs/dsl_userhold.c b/module/zfs/dsl_userhold.c index 181fc3946b46..75d153194a00 100644 --- a/module/zfs/dsl_userhold.c +++ b/module/zfs/dsl_userhold.c @@ -101,9 +101,9 @@ dsl_dataset_user_hold_check(void *arg, dmu_tx_t *tx) size_t len = strlen(nvpair_name(pair)) + strlen(fnvpair_value_string(pair)); char *nameval = kmem_zalloc(len + 2, KM_SLEEP); - (void) strcpy(nameval, nvpair_name(pair)); - (void) strcat(nameval, "@"); - (void) strcat(nameval, fnvpair_value_string(pair)); + (void) strlcpy(nameval, nvpair_name(pair), len + 2); + (void) strlcat(nameval, "@", len + 2); + (void) strlcat(nameval, fnvpair_value_string(pair), len + 2); fnvlist_add_string(tmp_holds, nameval, ""); kmem_free(nameval, len + 2); } diff --git a/module/zfs/spa.c b/module/zfs/spa.c index 73d63f849ee0..0a98e9a622d2 100644 --- a/module/zfs/spa.c +++ b/module/zfs/spa.c @@ -6647,7 +6647,9 @@ spa_vdev_attach(spa_t *spa, uint64_t guid, nvlist_t *nvroot, int replacing) spa_strfree(oldvd->vdev_path); oldvd->vdev_path = kmem_alloc(strlen(newvd->vdev_path) + 5, KM_SLEEP); - (void) sprintf(oldvd->vdev_path, "%s/%s", + (void) snprintf(oldvd->vdev_path, + strlen(newvd->vdev_path) + 5, + "%s/%s", newvd->vdev_path, "old"); if (oldvd->vdev_devid != NULL) { spa_strfree(oldvd->vdev_devid); diff --git a/module/zfs/vdev_raidz_math.c b/module/zfs/vdev_raidz_math.c index 14120e110693..9ca93f21f7a5 100644 --- a/module/zfs/vdev_raidz_math.c +++ b/module/zfs/vdev_raidz_math.c @@ -638,6 +638,7 @@ zfs_vdev_raidz_impl_set(const char *val, zfs_kernel_param_t *kp) return (vdev_raidz_impl_set(val)); } +#if defined(__linux__) || defined(__FreeBSD__) static int zfs_vdev_raidz_impl_get(char *buffer, zfs_kernel_param_t *kp) { @@ -661,6 +662,7 @@ zfs_vdev_raidz_impl_get(char *buffer, zfs_kernel_param_t *kp) return (cnt); } +#endif module_param_call(zfs_vdev_raidz_impl, zfs_vdev_raidz_impl_set, zfs_vdev_raidz_impl_get, NULL, 0644); diff --git a/module/zfs/zap.c b/module/zfs/zap.c index 01c06aa3fdd3..1abb32fdf00b 100644 --- a/module/zfs/zap.c +++ b/module/zfs/zap.c @@ -1030,7 +1030,7 @@ zap_value_search(objset_t *os, uint64_t zapobj, uint64_t value, uint64_t mask, (err = zap_cursor_retrieve(&zc, za)) == 0; zap_cursor_advance(&zc)) { if ((za->za_first_integer & mask) == (value & mask)) { - (void) strcpy(name, za->za_name); + (void) strlcpy(name, za->za_name, MAXNAMELEN); break; } } diff --git a/module/zfs/zap_micro.c b/module/zfs/zap_micro.c index c3d42d0ee159..33e951afc339 100644 --- a/module/zfs/zap_micro.c +++ b/module/zfs/zap_micro.c @@ -1602,7 +1602,8 @@ zap_cursor_retrieve(zap_cursor_t *zc, zap_attribute_t *za) za->za_integer_length = 8; za->za_num_integers = 1; za->za_first_integer = mzep->mze_value; - (void) strcpy(za->za_name, mzep->mze_name); + (void) strlcpy(za->za_name, mzep->mze_name, + sizeof (za->za_name)); zc->zc_hash = mze->mze_hash; zc->zc_cd = mze->mze_cd; err = 0; diff --git a/module/zfs/zcp_get.c b/module/zfs/zcp_get.c index 311875583dfe..6ba4d9178550 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,7 @@ 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 +693,9 @@ 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, sizeof(name), "%s@%s", dataset_name, name); } else { - (void) strcpy(snap_name, name); + (void) strlcpy(snap_name, name, ZFS_MAX_DATASET_NAME_LEN); } } diff --git a/module/zfs/zfs_fuid.c b/module/zfs/zfs_fuid.c index dbf9d31a9ae1..fbd06be4f98a 100644 --- a/module/zfs/zfs_fuid.c +++ b/module/zfs/zfs_fuid.c @@ -778,7 +778,7 @@ zfs_fuid_txhold(zfsvfs_t *zfsvfs, dmu_tx_t *tx) */ int zfs_id_to_fuidstr(zfsvfs_t *zfsvfs, const char *domain, uid_t rid, - char *buf, boolean_t addok) + char *buf, size_t len, boolean_t addok) { uint64_t fuid; int domainid = 0; @@ -789,7 +789,7 @@ zfs_id_to_fuidstr(zfsvfs_t *zfsvfs, const char *domain, uid_t rid, return (SET_ERROR(ENOENT)); } fuid = FUID_ENCODE(domainid, rid); - (void) sprintf(buf, "%llx", (longlong_t)fuid); + (void) snprintf(buf, len, "%llx", (longlong_t)fuid); return (0); } #endif diff --git a/module/zfs/zfs_ioctl.c b/module/zfs/zfs_ioctl.c index d55ce20ef76f..1f52b6931197 100644 --- a/module/zfs/zfs_ioctl.c +++ b/module/zfs/zfs_ioctl.c @@ -2504,7 +2504,7 @@ 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 +5271,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'; diff --git a/module/zfs/zfs_quota.c b/module/zfs/zfs_quota.c index 1acfbf1ea618..97057d536b83 100644 --- a/module/zfs/zfs_quota.c +++ b/module/zfs/zfs_quota.c @@ -269,7 +269,8 @@ zfs_userspace_one(zfsvfs_t *zfsvfs, zfs_userquota_prop_t type, offset = DMU_OBJACCT_PREFIX_LEN; } - err = zfs_id_to_fuidstr(zfsvfs, domain, rid, buf + offset, B_FALSE); + err = zfs_id_to_fuidstr(zfsvfs, domain, rid, buf + offset, + sizeof(buf) - offset, B_FALSE); if (err) return (err); @@ -325,7 +326,7 @@ zfs_set_userquota(zfsvfs_t *zfsvfs, zfs_userquota_prop_t type, return (SET_ERROR(EINVAL)); } - err = zfs_id_to_fuidstr(zfsvfs, domain, rid, buf, B_TRUE); + err = zfs_id_to_fuidstr(zfsvfs, domain, rid, buf, sizeof(buf), B_TRUE); if (err) return (err); fuid_dirtied = zfsvfs->z_fuid_dirty; @@ -407,12 +408,13 @@ zfs_id_overobjquota(zfsvfs_t *zfsvfs, uint64_t usedobj, uint64_t id) if (quotaobj == 0 || zfsvfs->z_replay) return (B_FALSE); - (void) sprintf(buf, "%llx", (longlong_t)id); + (void) snprintf(buf, sizeof(buf), "%llx", (longlong_t)id); err = zap_lookup(zfsvfs->z_os, quotaobj, buf, 8, 1, "a); if (err != 0) return (B_FALSE); - (void) sprintf(buf, DMU_OBJACCT_PREFIX "%llx", (longlong_t)id); + (void) snprintf(buf, sizeof(buf), DMU_OBJACCT_PREFIX "%llx", + (longlong_t)id); err = zap_lookup(zfsvfs->z_os, usedobj, buf, 8, 1, &used); if (err != 0) return (B_FALSE); @@ -448,7 +450,7 @@ zfs_id_overblockquota(zfsvfs_t *zfsvfs, uint64_t usedobj, uint64_t id) if (quotaobj == 0 || zfsvfs->z_replay) return (B_FALSE); - (void) sprintf(buf, "%llx", (longlong_t)id); + (void) snprintf(buf, sizeof(buf), "%llx", (longlong_t)id); err = zap_lookup(zfsvfs->z_os, quotaobj, buf, 8, 1, "a); if (err != 0) return (B_FALSE); diff --git a/module/zfs/zio.c b/module/zfs/zio.c index b9a3ddcf237e..52d68663dfc8 100644 --- a/module/zfs/zio.c +++ b/module/zfs/zio.c @@ -203,11 +203,13 @@ zio_init(void) if (align != 0) { char name[36]; - (void) sprintf(name, "zio_buf_%lu", (ulong_t)size); + (void) snprintf(name, sizeof(name), "zio_buf_%lu", + (ulong_t)size); zio_buf_cache[c] = kmem_cache_create(name, size, align, NULL, NULL, NULL, NULL, NULL, cflags); - (void) sprintf(name, "zio_data_buf_%lu", (ulong_t)size); + (void) snprintf(name, sizeof(name), "zio_data_buf_%lu", + (ulong_t)size); zio_data_buf_cache[c] = kmem_cache_create(name, size, align, NULL, NULL, NULL, NULL, data_alloc_arena, data_cflags);