Replace all strncpy with strlcpy
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
This commit is contained in:
parent
6f6fce95a2
commit
325f395300
@ -262,8 +262,8 @@ int sim_rptun_init(const char *shmemname, const char *cpuname, bool master)
|
||||
|
||||
dev->master = master;
|
||||
dev->rptun.ops = &g_sim_rptun_ops;
|
||||
strncpy(dev->cpuname, cpuname, RPMSG_NAME_SIZE);
|
||||
strncpy(dev->shmemname, shmemname, RPMSG_NAME_SIZE);
|
||||
strlcpy(dev->cpuname, cpuname, RPMSG_NAME_SIZE);
|
||||
strlcpy(dev->shmemname, shmemname, RPMSG_NAME_SIZE);
|
||||
list_add_tail(&g_dev_list, &dev->node);
|
||||
|
||||
ret = rptun_initialize(&dev->rptun);
|
||||
|
@ -314,7 +314,7 @@ int himem_chardev_register(char *name, size_t size)
|
||||
|
||||
dev->size = size;
|
||||
|
||||
strncpy(dev->name, name, 32);
|
||||
strlcpy(dev->name, name, 32);
|
||||
ret = esp_himem_alloc(dev->size, &dev->mem_handle);
|
||||
if (ret != 0)
|
||||
{
|
||||
|
@ -186,8 +186,7 @@ static int init_ota_partitions(void)
|
||||
const struct ota_partition_s *part = &g_ota_partition_table[i];
|
||||
mtd = progmem_alloc_mtdpart(part->offset, part->size);
|
||||
|
||||
strncpy(path, (char *)part->devpath, PARTITION_LABEL_LEN);
|
||||
path[PARTITION_LABEL_LEN] = '\0';
|
||||
strlcpy(path, (char *)part->devpath, PARTITION_LABEL_LEN);
|
||||
|
||||
finfo("INFO: [label]: %s\n", path);
|
||||
finfo("INFO: [offset]: 0x%08" PRIx32 "\n", part->offset);
|
||||
|
@ -187,8 +187,7 @@ static int init_ota_partitions(void)
|
||||
const struct ota_partition_s *part = &g_ota_partition_table[i];
|
||||
mtd = progmem_alloc_mtdpart(part->offset, part->size);
|
||||
|
||||
strncpy(path, (char *)part->devpath, PARTITION_LABEL_LEN);
|
||||
path[PARTITION_LABEL_LEN] = '\0';
|
||||
strlcpy(path, (char *)part->devpath, PARTITION_LABEL_LEN);
|
||||
|
||||
finfo("INFO: [label]: %s\n", path);
|
||||
finfo("INFO: [offset]: 0x%08" PRIx32 "\n", part->offset);
|
||||
|
@ -790,9 +790,9 @@ int32_t altcombs_set_pdninfo(struct apicmd_pdnset_s *cmd_pdn,
|
||||
for (i = 0; i < lte_pdn->ipaddr_num; i++)
|
||||
{
|
||||
lte_pdn->address[i].ip_type = cmd_pdn->ip_address[i].iptype;
|
||||
strncpy(lte_pdn->address[i].address,
|
||||
strlcpy(lte_pdn->address[i].address,
|
||||
(FAR char *)cmd_pdn->ip_address[i].address,
|
||||
LTE_IPADDR_MAX_LEN - 1);
|
||||
LTE_IPADDR_MAX_LEN);
|
||||
}
|
||||
|
||||
lte_pdn->ims_register = cmd_pdn->imsregister == APICMD_PDN_IMS_REG ?
|
||||
@ -826,9 +826,9 @@ int32_t altcombs_set_pdninfo_v4(FAR struct apicmd_pdnset_v4_s *cmd_pdn,
|
||||
for (i = 0; i < lte_pdn->ipaddr_num; i++)
|
||||
{
|
||||
lte_pdn->address[i].ip_type = cmd_pdn->ip_address[i].iptype;
|
||||
strncpy(lte_pdn->address[i].address,
|
||||
strlcpy(lte_pdn->address[i].address,
|
||||
(FAR char *)cmd_pdn->ip_address[i].address,
|
||||
LTE_IPADDR_MAX_LEN - 1);
|
||||
LTE_IPADDR_MAX_LEN);
|
||||
}
|
||||
|
||||
lte_pdn->ims_register = cmd_pdn->imsregister;
|
||||
@ -1420,10 +1420,10 @@ static void getver_parse_response(FAR struct apicmd_cmddat_getverres_s *resp,
|
||||
FAR lte_version_t *version)
|
||||
{
|
||||
memset(version, 0, sizeof(*version));
|
||||
strncpy(version->bb_product,
|
||||
(FAR const char *)resp->bb_product, LTE_VER_BB_PRODUCT_LEN - 1);
|
||||
strncpy(version->np_package,
|
||||
(FAR const char *)resp->np_package, LTE_VER_NP_PACKAGE_LEN - 1);
|
||||
strlcpy(version->bb_product,
|
||||
(FAR const char *)resp->bb_product, LTE_VER_BB_PRODUCT_LEN);
|
||||
strlcpy(version->np_package,
|
||||
(FAR const char *)resp->np_package, LTE_VER_NP_PACKAGE_LEN);
|
||||
}
|
||||
|
||||
static void getpinset_parse_response(
|
||||
@ -1822,7 +1822,7 @@ static int copy_logfilename(FAR char *filename, size_t fnamelen,
|
||||
|
||||
if (pathlen <= fnamelen)
|
||||
{
|
||||
strncpy(filename, path, fnamelen);
|
||||
strlcpy(filename, path, fnamelen);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1977,7 +1977,7 @@ static int32_t setpinlock_pkt_compose(FAR void **arg,
|
||||
(FAR struct apicmd_cmddat_setpinlock_s *)pktbuf;
|
||||
|
||||
out->mode = *enable;
|
||||
strncpy((FAR char *)out->pincode, pincode, sizeof(out->pincode));
|
||||
strlcpy((FAR char *)out->pincode, pincode, sizeof(out->pincode));
|
||||
|
||||
size = sizeof(struct apicmd_cmddat_setpinlock_s);
|
||||
|
||||
@ -2018,9 +2018,8 @@ static int32_t setpincode_pkt_compose(FAR void **arg,
|
||||
out->chgtype = APICMD_SETPINCODE_CHGTYPE_PIN2;
|
||||
}
|
||||
|
||||
strncpy((FAR char *)out->pincode, pincode, sizeof(out->pincode));
|
||||
|
||||
strncpy((FAR char *)out->newpincode, new_pincode, sizeof(out->newpincode));
|
||||
strlcpy((FAR char *)out->pincode, pincode, sizeof(out->pincode));
|
||||
strlcpy((FAR char *)out->newpincode, new_pincode, sizeof(out->newpincode));
|
||||
|
||||
size = sizeof(struct apicmd_cmddat_setpincode_s);
|
||||
|
||||
@ -2051,11 +2050,11 @@ static int32_t enterpin_pkt_compose(FAR void **arg,
|
||||
FAR struct apicmd_cmddat_enterpin_s *out =
|
||||
(FAR struct apicmd_cmddat_enterpin_s *)pktbuf;
|
||||
|
||||
strncpy((FAR char *)out->pincode, pincode, sizeof(out->pincode));
|
||||
strlcpy((FAR char *)out->pincode, pincode, sizeof(out->pincode));
|
||||
if (new_pincode)
|
||||
{
|
||||
out->newpincodeuse = APICMD_ENTERPIN_NEWPINCODE_USE;
|
||||
strncpy((FAR char *)out->newpincode,
|
||||
strlcpy((FAR char *)out->newpincode,
|
||||
new_pincode, sizeof(out->newpincode));
|
||||
}
|
||||
else
|
||||
@ -2531,14 +2530,14 @@ static int32_t actpdn_pkt_compose(FAR void **arg,
|
||||
out->iptype = apn->ip_type;
|
||||
out->authtype = apn->auth_type;
|
||||
|
||||
strncpy((FAR char *)out->apnname, (FAR const char *)apn->apn,
|
||||
strlcpy((FAR char *)out->apnname, (FAR const char *)apn->apn,
|
||||
sizeof(out->apnname));
|
||||
if (apn->auth_type != LTE_APN_AUTHTYPE_NONE)
|
||||
{
|
||||
strncpy((FAR char *)out->username, (FAR const char *)apn->user_name,
|
||||
sizeof(out->username));
|
||||
strncpy((FAR char *)out->password, (FAR const char *)apn->password,
|
||||
sizeof(out->password));
|
||||
strlcpy((FAR char *)out->username, (FAR const char *)apn->user_name,
|
||||
sizeof(out->username));
|
||||
strlcpy((FAR char *)out->password, (FAR const char *)apn->password,
|
||||
sizeof(out->password));
|
||||
}
|
||||
|
||||
size = sizeof(struct apicmd_cmddat_activatepdn_s);
|
||||
@ -4248,7 +4247,7 @@ static int32_t getphone_pkt_parse(FAR struct alt1250_dev_s *dev,
|
||||
}
|
||||
}
|
||||
|
||||
strncpy(phoneno, (FAR const char *)in->phoneno, LTE_PHONENO_LEN);
|
||||
strlcpy(phoneno, (FAR const char *)in->phoneno, LTE_PHONENO_LEN);
|
||||
}
|
||||
|
||||
return 0;
|
||||
@ -4285,7 +4284,7 @@ static int32_t getimsi_pkt_parse(FAR struct alt1250_dev_s *dev,
|
||||
}
|
||||
}
|
||||
|
||||
strncpy(imsi, (FAR const char *)in->imsi, APICMD_IMSI_LEN);
|
||||
strlcpy(imsi, (FAR const char *)in->imsi, APICMD_IMSI_LEN);
|
||||
}
|
||||
|
||||
return 0;
|
||||
@ -4319,7 +4318,7 @@ static int32_t getimei_pkt_parse(FAR struct alt1250_dev_s *dev,
|
||||
}
|
||||
}
|
||||
|
||||
strncpy(imei, (FAR const char *)in->imei, LTE_IMEI_LEN);
|
||||
strlcpy(imei, (FAR const char *)in->imei, LTE_IMEI_LEN);
|
||||
}
|
||||
|
||||
return 0;
|
||||
@ -4455,7 +4454,7 @@ static int32_t getoper_pkt_parse(FAR struct alt1250_dev_s *dev,
|
||||
}
|
||||
}
|
||||
|
||||
strncpy(oper, (FAR const char *)in->oper, LTE_OPERATOR_LEN);
|
||||
strlcpy(oper, (FAR const char *)in->oper, LTE_OPERATOR_LEN);
|
||||
}
|
||||
}
|
||||
else if (altver == ALTCOM_VER4)
|
||||
@ -4482,7 +4481,7 @@ static int32_t getoper_pkt_parse(FAR struct alt1250_dev_s *dev,
|
||||
}
|
||||
}
|
||||
|
||||
strncpy(oper, (FAR const char *)in->oper, LTE_OPERATOR_LEN);
|
||||
strlcpy(oper, (FAR const char *)in->oper, LTE_OPERATOR_LEN);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -33,7 +33,7 @@
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: strncpy
|
||||
* Name: swab
|
||||
*
|
||||
* Description:
|
||||
* The swab() function will copy nbytes bytes, which are pointed to by
|
||||
|
@ -92,8 +92,7 @@ static inline void pthread_tcb_setup(FAR struct pthread_tcb_s *ptcb,
|
||||
#if CONFIG_TASK_NAME_SIZE > 0
|
||||
/* Copy the pthread name into the TCB */
|
||||
|
||||
strncpy(ptcb->cmn.name, parent->name, CONFIG_TASK_NAME_SIZE);
|
||||
ptcb->cmn.name[CONFIG_TASK_NAME_SIZE] = '\0';
|
||||
strlcpy(ptcb->cmn.name, parent->name, CONFIG_TASK_NAME_SIZE);
|
||||
#endif /* CONFIG_TASK_NAME_SIZE */
|
||||
|
||||
/* For pthreads, args are strictly pass-by-value; that actual
|
||||
|
Loading…
Reference in New Issue
Block a user