1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-21 13:34:40 +03:00

cov: replace strcpy with memcpy

This commit is contained in:
Zdenek Kabelac 2024-05-04 21:56:34 +02:00
parent 04b407674c
commit 4761753a6f
3 changed files with 18 additions and 10 deletions

View File

@ -1451,9 +1451,10 @@ struct node_op_parms {
static void _store_str(char **pos, char **ptr, const char *str)
{
strcpy(*pos, str);
size_t len = strlen(str);
memcpy(*pos, str, len + 1);
*ptr = *pos;
*pos += strlen(*ptr) + 1;
*pos += len;
}
static void _del_node_op(struct node_op_parms *nop)
@ -1703,15 +1704,17 @@ const char *dm_sysfs_dir(void)
*/
int dm_set_uuid_prefix(const char *uuid_prefix)
{
size_t len;
if (!uuid_prefix)
return_0;
if (strlen(uuid_prefix) > DM_MAX_UUID_PREFIX_LEN) {
if ((len = strlen(uuid_prefix)) > DM_MAX_UUID_PREFIX_LEN) {
log_error("New uuid prefix %s too long.", uuid_prefix);
return 0;
}
strcpy(_default_uuid_prefix, uuid_prefix);
memcpy(_default_uuid_prefix, uuid_prefix, len + 1);
return 1;
}

View File

@ -1449,9 +1449,10 @@ struct node_op_parms {
static void _store_str(char **pos, char **ptr, const char *str)
{
strcpy(*pos, str);
size_t len = strlen(str);
memcpy(*pos, str, len + 1);
*ptr = *pos;
*pos += strlen(*ptr) + 1;
*pos += len;
}
static void _del_node_op(struct node_op_parms *nop)
@ -1701,15 +1702,17 @@ const char *dm_sysfs_dir(void)
*/
int dm_set_uuid_prefix(const char *uuid_prefix)
{
size_t len;
if (!uuid_prefix)
return_0;
if (strlen(uuid_prefix) > DM_MAX_UUID_PREFIX_LEN) {
if ((len = strlen(uuid_prefix)) > DM_MAX_UUID_PREFIX_LEN) {
log_error("New uuid prefix %s too long.", uuid_prefix);
return 0;
}
strcpy(_default_uuid_prefix, uuid_prefix);
memcpy(_default_uuid_prefix, uuid_prefix, len + 1);
return 1;
}

View File

@ -42,14 +42,16 @@ void dm_bounds_check_debug(void);
char *dm_strdup_aux(const char *str, const char *file, int line)
{
char *ret;
size_t len;
if (!str) {
log_error(INTERNAL_ERROR "dm_strdup called with NULL pointer");
return NULL;
}
if ((ret = dm_malloc_aux_debug(strlen(str) + 1, file, line)))
strcpy(ret, str);
len = strlen(str) + 1;
if ((ret = dm_malloc_aux_debug(len, file, line)))
memcpy(ret, str, len);
return ret;
}