mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2026-05-22 18:40:43 +03:00
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.
This commit is contained in:
committed by
Tony Hutter
parent
7b98b55282
commit
04837c8dcb
@@ -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__)
|
||||
#include <linux/mod_compat.h>
|
||||
|
||||
static int
|
||||
|
||||
@@ -857,7 +857,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
|
||||
/*
|
||||
@@ -969,7 +969,7 @@ gcm_impl_set(const char *val)
|
||||
return (err);
|
||||
}
|
||||
|
||||
#if defined(_KERNEL)
|
||||
#if defined(_KERNEL) && defined(__linux__)
|
||||
#include <linux/mod_compat.h>
|
||||
|
||||
static int
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user