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/icp | |
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/icp')
-rw-r--r-- | module/icp/algs/aes/aes_impl.c | 4 | ||||
-rw-r--r-- | module/icp/algs/modes/gcm.c | 4 | ||||
-rw-r--r-- | module/icp/os/modhash.c | 6 |
3 files changed, 8 insertions, 6 deletions
diff --git a/module/icp/algs/aes/aes_impl.c b/module/icp/algs/aes/aes_impl.c index 2c123b8f5..037be0db6 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", AES_IMPL_NAME_MAX); /* Finish initialization */ atomic_swap_32(&icp_aes_impl, user_sel_impl); @@ -405,7 +405,7 @@ aes_impl_set(const char *val) return (err); } -#if defined(_KERNEL) +#if defined(_KERNEL) && defined(__linux__) static int icp_aes_impl_set(const char *val, zfs_kernel_param_t *kp) diff --git a/module/icp/algs/modes/gcm.c b/module/icp/algs/modes/gcm.c index 7a94d3dbb..6b732808a 100644 --- a/module/icp/algs/modes/gcm.c +++ b/module/icp/algs/modes/gcm.c @@ -843,7 +843,7 @@ gcm_impl_init(void) sizeof (gcm_fastest_impl)); } - strcpy(gcm_fastest_impl.name, "fastest"); + strlcpy(gcm_fastest_impl.name, "fastest", GCM_IMPL_NAME_MAX); #ifdef CAN_USE_GCM_ASM /* @@ -955,7 +955,7 @@ gcm_impl_set(const char *val) return (err); } -#if defined(_KERNEL) +#if defined(_KERNEL) && defined(__linux__) static int icp_gcm_impl_set(const char *val, zfs_kernel_param_t *kp) diff --git a/module/icp/os/modhash.c b/module/icp/os/modhash.c index 5e216ed6a..a89787100 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; + size_t 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; |