change strcpy to strlcpy
Signed-off-by: lilei19 <lilei19@xiaomi.com>
This commit is contained in:
parent
68ff73c5fb
commit
38f64f559d
@ -2816,7 +2816,7 @@ void arm_serialinit(void)
|
|||||||
|
|
||||||
/* Register all remaining USARTs */
|
/* Register all remaining USARTs */
|
||||||
|
|
||||||
strcpy(devname, "/dev/ttySx");
|
strlcpy(devname, "/dev/ttySx", sizeof(devname));
|
||||||
|
|
||||||
for (i = 0; i < GD32_NUSART; i++)
|
for (i = 0; i < GD32_NUSART; i++)
|
||||||
{
|
{
|
||||||
|
@ -782,7 +782,7 @@ void arm_serialinit(void)
|
|||||||
|
|
||||||
/* Register all remaining UARTs */
|
/* Register all remaining UARTs */
|
||||||
|
|
||||||
strcpy(devname, "/dev/ttySx");
|
strlcpy(devname, "/dev/ttySx", sizeof(devname));
|
||||||
|
|
||||||
for (i = 0; i < NRF52_NUART; i++)
|
for (i = 0; i < NRF52_NUART; i++)
|
||||||
{
|
{
|
||||||
|
@ -782,7 +782,7 @@ void arm_serialinit(void)
|
|||||||
|
|
||||||
/* Register all remaining UARTs */
|
/* Register all remaining UARTs */
|
||||||
|
|
||||||
strcpy(devname, "/dev/ttySx");
|
strlcpy(devname, "/dev/ttySx", sizeof(devname));
|
||||||
|
|
||||||
for (i = 0; i < NRF53_NUART; i++)
|
for (i = 0; i < NRF53_NUART; i++)
|
||||||
{
|
{
|
||||||
|
@ -3240,7 +3240,7 @@ void arm_serialinit(void)
|
|||||||
|
|
||||||
/* Register all remaining USARTs */
|
/* Register all remaining USARTs */
|
||||||
|
|
||||||
strcpy(devname, "/dev/ttySx");
|
strlcpy(devname, "/dev/ttySx", sizeof(devname));
|
||||||
|
|
||||||
for (i = 0; i < STM32_NUSART; i++)
|
for (i = 0; i < STM32_NUSART; i++)
|
||||||
{
|
{
|
||||||
|
@ -2480,7 +2480,7 @@ void arm_serialinit(void)
|
|||||||
|
|
||||||
/* Register all remaining USARTs */
|
/* Register all remaining USARTs */
|
||||||
|
|
||||||
strcpy(devname, "/dev/ttySx");
|
strlcpy(devname, "/dev/ttySx", sizeof(devname));
|
||||||
|
|
||||||
for (i = 0; i < STM32_NUSART; i++)
|
for (i = 0; i < STM32_NUSART; i++)
|
||||||
{
|
{
|
||||||
|
@ -1970,7 +1970,7 @@ void arm_serialinit(void)
|
|||||||
|
|
||||||
/* Register all remaining USARTs */
|
/* Register all remaining USARTs */
|
||||||
|
|
||||||
strcpy(devname, "/dev/ttySx");
|
strlcpy(devname, "/dev/ttySx", sizeof(devname));
|
||||||
|
|
||||||
for (i = 0; i < STM32_NSERIAL; i++)
|
for (i = 0; i < STM32_NSERIAL; i++)
|
||||||
{
|
{
|
||||||
|
@ -3677,7 +3677,7 @@ void arm_serialinit(void)
|
|||||||
|
|
||||||
/* Register all remaining USARTs */
|
/* Register all remaining USARTs */
|
||||||
|
|
||||||
strcpy(devname, "/dev/ttySx");
|
strlcpy(devname, "/dev/ttySx", sizeof(devname));
|
||||||
|
|
||||||
for (i = 0; i < STM32_NSERIAL; i++)
|
for (i = 0; i < STM32_NSERIAL; i++)
|
||||||
{
|
{
|
||||||
|
@ -3890,7 +3890,7 @@ void arm_serialinit(void)
|
|||||||
|
|
||||||
/* Register all remaining USARTs */
|
/* Register all remaining USARTs */
|
||||||
|
|
||||||
strcpy(devname, "/dev/ttySx");
|
strlcpy(devname, "/dev/ttySx", sizeof(devname));
|
||||||
|
|
||||||
for (i = 0; i < STM32_NSERIAL; i++)
|
for (i = 0; i < STM32_NSERIAL; i++)
|
||||||
{
|
{
|
||||||
|
@ -3160,7 +3160,7 @@ void arm_serialinit(void)
|
|||||||
|
|
||||||
/* Register all remaining USARTs */
|
/* Register all remaining USARTs */
|
||||||
|
|
||||||
strcpy(devname, "/dev/ttySx");
|
strlcpy(devname, "/dev/ttySx", sizeof(devname));
|
||||||
|
|
||||||
for (i = 0; i < STM32L4_NLPUART + STM32L4_NUSART + STM32L4_NUART; i++)
|
for (i = 0; i < STM32L4_NLPUART + STM32L4_NUSART + STM32L4_NUART; i++)
|
||||||
{
|
{
|
||||||
|
@ -3093,7 +3093,7 @@ void arm_serialinit(void)
|
|||||||
|
|
||||||
/* Register all remaining USARTs */
|
/* Register all remaining USARTs */
|
||||||
|
|
||||||
strcpy(devname, "/dev/ttySx");
|
strlcpy(devname, "/dev/ttySx", sizeof(devname));
|
||||||
|
|
||||||
for (i = 0; i < STM32L5_NLPUART + STM32L5_NUSART + STM32L5_NUART; i++)
|
for (i = 0; i < STM32L5_NLPUART + STM32L5_NUSART + STM32L5_NUART; i++)
|
||||||
{
|
{
|
||||||
|
@ -3093,7 +3093,7 @@ void arm_serialinit(void)
|
|||||||
|
|
||||||
/* Register all remaining USARTs */
|
/* Register all remaining USARTs */
|
||||||
|
|
||||||
strcpy(devname, "/dev/ttySx");
|
strlcpy(devname, "/dev/ttySx", sizeof(devname));
|
||||||
|
|
||||||
for (i = 0; i < STM32_NLPUART + STM32_NUSART + STM32_NUART; i++)
|
for (i = 0; i < STM32_NLPUART + STM32_NUSART + STM32_NUART; i++)
|
||||||
{
|
{
|
||||||
|
@ -2754,7 +2754,7 @@ void arm_serialinit(void)
|
|||||||
|
|
||||||
/* Register all remaining USARTs */
|
/* Register all remaining USARTs */
|
||||||
|
|
||||||
strcpy(devname, "/dev/ttySx");
|
strlcpy(devname, "/dev/ttySx", sizeof(devname));
|
||||||
|
|
||||||
for (i = 0; i < STM32WB_NLPUART + STM32WB_NUSART; i++)
|
for (i = 0; i < STM32WB_NLPUART + STM32WB_NUSART; i++)
|
||||||
{
|
{
|
||||||
|
@ -2848,7 +2848,7 @@ void arm_serialinit(void)
|
|||||||
|
|
||||||
/* Register all remaining USARTs */
|
/* Register all remaining USARTs */
|
||||||
|
|
||||||
strcpy(devname, "/dev/ttySx");
|
strlcpy(devname, "/dev/ttySx", sizeof(devname));
|
||||||
|
|
||||||
for (i = 0; i < STM32WL5_NLPUART + STM32WL5_NUSART; i++)
|
for (i = 0; i < STM32WL5_NLPUART + STM32WL5_NUSART; i++)
|
||||||
{
|
{
|
||||||
|
@ -855,7 +855,7 @@ void riscv_serialinit(void)
|
|||||||
|
|
||||||
/* Register all UARTs */
|
/* Register all UARTs */
|
||||||
|
|
||||||
strcpy(devname, "/dev/ttySx");
|
strlcpy(devname, "/dev/ttySx", sizeof(devname));
|
||||||
for (i = 0; i < sizeof(g_uart_devs) / sizeof(g_uart_devs[0]); i++)
|
for (i = 0; i < sizeof(g_uart_devs) / sizeof(g_uart_devs[0]); i++)
|
||||||
{
|
{
|
||||||
if (g_uart_devs[i] == 0)
|
if (g_uart_devs[i] == 0)
|
||||||
|
@ -951,8 +951,8 @@ int audio_register(FAR const char *name, FAR struct audio_lowerhalf_s *dev)
|
|||||||
|
|
||||||
/* This is the simple case ... No need to make a directory */
|
/* This is the simple case ... No need to make a directory */
|
||||||
|
|
||||||
strcpy(path, "/dev/");
|
strlcpy(path, "/dev/", sizeof(path));
|
||||||
strcat(path, name);
|
strlcat(path, name, sizeof(path));
|
||||||
|
|
||||||
#else
|
#else
|
||||||
/* Ensure the path begins with "/dev" as we don't support placing device
|
/* Ensure the path begins with "/dev" as we don't support placing device
|
||||||
@ -973,7 +973,7 @@ int audio_register(FAR const char *name, FAR struct audio_lowerhalf_s *dev)
|
|||||||
ptr++;
|
ptr++;
|
||||||
}
|
}
|
||||||
|
|
||||||
strcpy(path, "/dev/");
|
strlcpy(path, "/dev/", sizeof(path));
|
||||||
pathptr = &path[5];
|
pathptr = &path[5];
|
||||||
|
|
||||||
/* Do mkdir for each segment of the path */
|
/* Do mkdir for each segment of the path */
|
||||||
@ -1009,13 +1009,13 @@ int audio_register(FAR const char *name, FAR struct audio_lowerhalf_s *dev)
|
|||||||
|
|
||||||
/* Now build the path for registration */
|
/* Now build the path for registration */
|
||||||
|
|
||||||
strcpy(path, devname);
|
strlcpy(path, devname, sizeof(path));
|
||||||
if (devname[sizeof(devname)-1] != '/')
|
if (devname[sizeof(devname)-1] != '/')
|
||||||
{
|
{
|
||||||
strcat(path, "/");
|
strlcat(path, "/", sizeof(path));
|
||||||
}
|
}
|
||||||
|
|
||||||
strcat(path, name);
|
strlcat(path, name, sizeof(path));
|
||||||
|
|
||||||
#endif /* CONFIG_AUDIO_DEV_PATH=="/dev" */
|
#endif /* CONFIG_AUDIO_DEV_PATH=="/dev" */
|
||||||
|
|
||||||
@ -1036,10 +1036,9 @@ int audio_register(FAR const char *name, FAR struct audio_lowerhalf_s *dev)
|
|||||||
|
|
||||||
/* Register the Audio device */
|
/* Register the Audio device */
|
||||||
|
|
||||||
memset(path, 0, AUDIO_MAX_DEVICE_PATH);
|
strlcpy(path, devname, sizeof(path));
|
||||||
strcpy(path, devname);
|
strlcat(path, "/", sizeof(path));
|
||||||
strcat(path, "/");
|
strlcat(path, name, sizeof(path));
|
||||||
strncat(path, name, AUDIO_MAX_DEVICE_PATH - 11);
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Give the lower-half a context to the upper half */
|
/* Give the lower-half a context to the upper half */
|
||||||
|
@ -1136,6 +1136,7 @@ FAR struct clk_s *clk_register(FAR const char *name,
|
|||||||
FAR void *private_data, size_t private_size)
|
FAR void *private_data, size_t private_size)
|
||||||
{
|
{
|
||||||
FAR struct clk_s *clk;
|
FAR struct clk_s *clk;
|
||||||
|
size_t size;
|
||||||
size_t off;
|
size_t off;
|
||||||
size_t len;
|
size_t len;
|
||||||
int i;
|
int i;
|
||||||
@ -1163,14 +1164,15 @@ FAR struct clk_s *clk_register(FAR const char *name,
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
clk = kmm_zalloc(len + strlen(name) + 1);
|
size = strlen(name) + 1;
|
||||||
|
clk = kmm_zalloc(len + size);
|
||||||
if (!clk)
|
if (!clk)
|
||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
clk->name = (char *)clk + len;
|
clk->name = (char *)clk + len;
|
||||||
strcpy((char *)clk->name, name);
|
strlcpy((char *)clk->name, name, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
clk->ops = ops;
|
clk->ops = ops;
|
||||||
@ -1190,7 +1192,7 @@ FAR struct clk_s *clk_register(FAR const char *name,
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
clk->parent_names[i] = (char *)clk + off;
|
clk->parent_names[i] = (char *)clk + off;
|
||||||
strcpy((char *)clk->parent_names[i], parent_names[i]);
|
strlcpy((char *)clk->parent_names[i], parent_names[i], len - off);
|
||||||
off += strlen(parent_names[i]) + 1;
|
off += strlen(parent_names[i]) + 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -638,7 +638,7 @@ static int clk_rpmsg_enable(FAR struct clk_s *clk)
|
|||||||
|
|
||||||
DEBUGASSERT(len <= size);
|
DEBUGASSERT(len <= size);
|
||||||
|
|
||||||
strcpy(msg->name, name);
|
strlcpy(msg->name, name, size - sizeof(*msg));
|
||||||
|
|
||||||
return clk_rpmsg_sendrecv(ept, CLK_RPMSG_ENABLE,
|
return clk_rpmsg_sendrecv(ept, CLK_RPMSG_ENABLE,
|
||||||
(struct clk_rpmsg_header_s *)msg,
|
(struct clk_rpmsg_header_s *)msg,
|
||||||
@ -669,7 +669,7 @@ static void clk_rpmsg_disable(FAR struct clk_s *clk)
|
|||||||
|
|
||||||
DEBUGASSERT(len <= size);
|
DEBUGASSERT(len <= size);
|
||||||
|
|
||||||
strcpy(msg->name, name);
|
strlcpy(msg->name, name, size - sizeof(*msg));
|
||||||
|
|
||||||
clk_rpmsg_sendrecv(ept, CLK_RPMSG_DISABLE,
|
clk_rpmsg_sendrecv(ept, CLK_RPMSG_DISABLE,
|
||||||
(struct clk_rpmsg_header_s *)msg, len);
|
(struct clk_rpmsg_header_s *)msg, len);
|
||||||
@ -699,7 +699,7 @@ static int clk_rpmsg_is_enabled(FAR struct clk_s *clk)
|
|||||||
|
|
||||||
DEBUGASSERT(len <= size);
|
DEBUGASSERT(len <= size);
|
||||||
|
|
||||||
strcpy(msg->name, name);
|
strlcpy(msg->name, name, size - sizeof(*msg));
|
||||||
|
|
||||||
return clk_rpmsg_sendrecv(ept, CLK_RPMSG_ISENABLED,
|
return clk_rpmsg_sendrecv(ept, CLK_RPMSG_ISENABLED,
|
||||||
(struct clk_rpmsg_header_s *)msg, len);
|
(struct clk_rpmsg_header_s *)msg, len);
|
||||||
@ -732,7 +732,7 @@ static uint32_t clk_rpmsg_round_rate(FAR struct clk_s *clk, uint32_t rate,
|
|||||||
DEBUGASSERT(len <= size);
|
DEBUGASSERT(len <= size);
|
||||||
|
|
||||||
msg->rate = rate;
|
msg->rate = rate;
|
||||||
strcpy(msg->name, name);
|
strlcpy(msg->name, name, size - sizeof(*msg));
|
||||||
|
|
||||||
ret = clk_rpmsg_sendrecv(ept, CLK_RPMSG_ROUNDRATE,
|
ret = clk_rpmsg_sendrecv(ept, CLK_RPMSG_ROUNDRATE,
|
||||||
(struct clk_rpmsg_header_s *)msg, len);
|
(struct clk_rpmsg_header_s *)msg, len);
|
||||||
@ -770,7 +770,7 @@ static int clk_rpmsg_set_rate(FAR struct clk_s *clk, uint32_t rate,
|
|||||||
DEBUGASSERT(len <= size);
|
DEBUGASSERT(len <= size);
|
||||||
|
|
||||||
msg->rate = rate;
|
msg->rate = rate;
|
||||||
strcpy(msg->name, name);
|
strlcpy(msg->name, name, size - sizeof(*msg));
|
||||||
|
|
||||||
return clk_rpmsg_sendrecv(ept, CLK_RPMSG_SETRATE,
|
return clk_rpmsg_sendrecv(ept, CLK_RPMSG_SETRATE,
|
||||||
(struct clk_rpmsg_header_s *)msg, len);
|
(struct clk_rpmsg_header_s *)msg, len);
|
||||||
@ -802,7 +802,7 @@ static uint32_t clk_rpmsg_recalc_rate(FAR struct clk_s *clk,
|
|||||||
|
|
||||||
DEBUGASSERT(len <= size);
|
DEBUGASSERT(len <= size);
|
||||||
|
|
||||||
strcpy(msg->name, name);
|
strlcpy(msg->name, name, size - sizeof(*msg));
|
||||||
|
|
||||||
ret = clk_rpmsg_sendrecv(ept, CLK_RPMSG_GETRATE,
|
ret = clk_rpmsg_sendrecv(ept, CLK_RPMSG_GETRATE,
|
||||||
(struct clk_rpmsg_header_s *)msg, len);
|
(struct clk_rpmsg_header_s *)msg, len);
|
||||||
@ -838,7 +838,7 @@ static int clk_rpmsg_get_phase(FAR struct clk_s *clk)
|
|||||||
|
|
||||||
DEBUGASSERT(len <= size);
|
DEBUGASSERT(len <= size);
|
||||||
|
|
||||||
strcpy(msg->name, name);
|
strlcpy(msg->name, name, size - sizeof(*msg));
|
||||||
|
|
||||||
return clk_rpmsg_sendrecv(ept, CLK_RPMSG_GETPHASE,
|
return clk_rpmsg_sendrecv(ept, CLK_RPMSG_GETPHASE,
|
||||||
(struct clk_rpmsg_header_s *)msg, len);
|
(struct clk_rpmsg_header_s *)msg, len);
|
||||||
@ -869,7 +869,7 @@ static int clk_rpmsg_set_phase(FAR struct clk_s *clk, int degrees)
|
|||||||
DEBUGASSERT(len <= size);
|
DEBUGASSERT(len <= size);
|
||||||
|
|
||||||
msg->degrees = degrees;
|
msg->degrees = degrees;
|
||||||
strcpy(msg->name, name);
|
strlcpy(msg->name, name, size - sizeof(*msg));
|
||||||
|
|
||||||
return clk_rpmsg_sendrecv(ept, CLK_RPMSG_SETPHASE,
|
return clk_rpmsg_sendrecv(ept, CLK_RPMSG_SETPHASE,
|
||||||
(struct clk_rpmsg_header_s *)msg, len);
|
(struct clk_rpmsg_header_s *)msg, len);
|
||||||
|
@ -811,6 +811,7 @@ int ee24xx_initialize(FAR struct i2c_master_s *bus, uint8_t devaddr,
|
|||||||
FAR struct ee24xx_dev_s *eedev;
|
FAR struct ee24xx_dev_s *eedev;
|
||||||
#ifdef CONFIG_AT24CS_UUID
|
#ifdef CONFIG_AT24CS_UUID
|
||||||
FAR char *uuidname;
|
FAR char *uuidname;
|
||||||
|
size_t size;
|
||||||
int ret;
|
int ret;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -877,7 +878,8 @@ int ee24xx_initialize(FAR struct i2c_master_s *bus, uint8_t devaddr,
|
|||||||
eedev->readonly ? "readonly" : "");
|
eedev->readonly ? "readonly" : "");
|
||||||
|
|
||||||
#ifdef CONFIG_AT24CS_UUID
|
#ifdef CONFIG_AT24CS_UUID
|
||||||
uuidname = kmm_zalloc(strlen(devname) + 8);
|
size = strlen(devname) + 8;
|
||||||
|
uuidname = kmm_zalloc(size);
|
||||||
if (!uuidname)
|
if (!uuidname)
|
||||||
{
|
{
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
@ -887,8 +889,8 @@ int ee24xx_initialize(FAR struct i2c_master_s *bus, uint8_t devaddr,
|
|||||||
* EEPROM chip, but with the ".uuid" suffix
|
* EEPROM chip, but with the ".uuid" suffix
|
||||||
*/
|
*/
|
||||||
|
|
||||||
strcpy(uuidname, devname);
|
strlcpy(uuidname, devname, size);
|
||||||
strcat(uuidname, ".uuid");
|
strlcat(uuidname, ".uuid", size);
|
||||||
ret = register_driver(uuidname, &at24cs_uuid_fops, 0444, eedev);
|
ret = register_driver(uuidname, &at24cs_uuid_fops, 0444, eedev);
|
||||||
|
|
||||||
kmm_free(uuidname);
|
kmm_free(uuidname);
|
||||||
|
@ -478,7 +478,8 @@ static int ftl_geometry(FAR struct inode *inode,
|
|||||||
geometry->geo_nsectors = dev->geo.neraseblocks * dev->blkper;
|
geometry->geo_nsectors = dev->geo.neraseblocks * dev->blkper;
|
||||||
geometry->geo_sectorsize = dev->geo.blocksize;
|
geometry->geo_sectorsize = dev->geo.blocksize;
|
||||||
|
|
||||||
strcpy(geometry->geo_model, dev->geo.model);
|
strlcpy(geometry->geo_model, dev->geo.model,
|
||||||
|
sizeof(geometry->geo_model));
|
||||||
|
|
||||||
finfo("available: true mediachanged: false writeenabled: %s\n",
|
finfo("available: true mediachanged: false writeenabled: %s\n",
|
||||||
geometry->geo_writeenabled ? "true" : "false");
|
geometry->geo_writeenabled ? "true" : "false");
|
||||||
|
@ -1336,7 +1336,7 @@ retry_find:
|
|||||||
/* Save the data at this entry */
|
/* Save the data at this entry */
|
||||||
|
|
||||||
#ifdef CONFIG_MTD_CONFIG_NAMED
|
#ifdef CONFIG_MTD_CONFIG_NAMED
|
||||||
strcpy(hdr.name, pdata->name);
|
strlcpy(hdr.name, pdata->name, sizeof(hdr.name));
|
||||||
#else
|
#else
|
||||||
hdr.id = pdata->id;
|
hdr.id = pdata->id;
|
||||||
hdr.instance = pdata->instance;
|
hdr.instance = pdata->instance;
|
||||||
@ -1543,7 +1543,7 @@ static int mtdconfig_firstconfig(FAR struct mtdconfig_struct_s *dev,
|
|||||||
/* Set other return data items */
|
/* Set other return data items */
|
||||||
|
|
||||||
#ifdef CONFIG_MTD_CONFIG_NAMED
|
#ifdef CONFIG_MTD_CONFIG_NAMED
|
||||||
strcpy(pdata->name, hdr.name);
|
strlcpy(pdata->name, hdr.name, sizeof(pdata->name));
|
||||||
#else
|
#else
|
||||||
pdata->id = hdr.id;
|
pdata->id = hdr.id;
|
||||||
pdata->instance = hdr.instance;
|
pdata->instance = hdr.instance;
|
||||||
@ -1618,7 +1618,7 @@ static int mtdconfig_nextconfig(FAR struct mtdconfig_struct_s *dev,
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CONFIG_MTD_CONFIG_NAMED
|
#ifdef CONFIG_MTD_CONFIG_NAMED
|
||||||
strcpy(pdata->name, hdr.name);
|
strlcpy(pdata->name, hdr.name, sizeof(pdata->name));
|
||||||
#else
|
#else
|
||||||
pdata->id = hdr.id;
|
pdata->id = hdr.id;
|
||||||
pdata->instance = hdr.instance;
|
pdata->instance = hdr.instance;
|
||||||
|
@ -855,7 +855,7 @@ FAR struct mtd_dev_s *mtd_partition(FAR struct mtd_dev_s *mtd,
|
|||||||
part->blkpererase = blkpererase;
|
part->blkpererase = blkpererase;
|
||||||
|
|
||||||
#ifdef CONFIG_MTD_PARTITION_NAMES
|
#ifdef CONFIG_MTD_PARTITION_NAMES
|
||||||
strcpy(part->name, "(noname)");
|
strlcpy(part->name, "(noname)", sizeof(part->name));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(CONFIG_FS_PROCFS) && !defined(CONFIG_PROCFS_EXCLUDE_PARTITIONS)
|
#if defined(CONFIG_FS_PROCFS) && !defined(CONFIG_PROCFS_EXCLUDE_PARTITIONS)
|
||||||
|
@ -1066,7 +1066,8 @@ static int smart_geometry(FAR struct inode *inode, struct geometry *geometry)
|
|||||||
dev->sectorsize;
|
dev->sectorsize;
|
||||||
geometry->geo_sectorsize = dev->sectorsize;
|
geometry->geo_sectorsize = dev->sectorsize;
|
||||||
|
|
||||||
strcpy(geometry->geo_model, dev->geo.model);
|
strlcpy(geometry->geo_model, dev->geo.model,
|
||||||
|
sizeof(geometry->geo_model));
|
||||||
|
|
||||||
finfo("available: true mediachanged: false writeenabled: %s\n",
|
finfo("available: true mediachanged: false writeenabled: %s\n",
|
||||||
geometry->geo_writeenabled ? "true" : "false");
|
geometry->geo_writeenabled ? "true" : "false");
|
||||||
|
@ -1127,7 +1127,7 @@ int net_rpmsg_drv_init(FAR const char *cpuname,
|
|||||||
|
|
||||||
/* Initialize the driver structure */
|
/* Initialize the driver structure */
|
||||||
|
|
||||||
strcpy(dev->d_ifname, devname);
|
strlcpy(dev->d_ifname, devname, sizeof(dev->d_ifname));
|
||||||
dev->d_ifup = net_rpmsg_drv_ifup; /* I/F up (new IP address) callback */
|
dev->d_ifup = net_rpmsg_drv_ifup; /* I/F up (new IP address) callback */
|
||||||
dev->d_ifdown = net_rpmsg_drv_ifdown; /* I/F down callback */
|
dev->d_ifdown = net_rpmsg_drv_ifdown; /* I/F down callback */
|
||||||
dev->d_txavail = net_rpmsg_drv_txavail; /* New TX data callback */
|
dev->d_txavail = net_rpmsg_drv_txavail; /* New TX data callback */
|
||||||
|
@ -526,7 +526,7 @@ static int regulator_rpmsg_enable(FAR struct regulator_dev_s *rdev)
|
|||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
strcpy(msg->name, name);
|
strlcpy(msg->name, name, len - sizeof(*msg));
|
||||||
return regulator_rpmsg_sendrecv(ept, REGULATOR_RPMSG_ENABLE,
|
return regulator_rpmsg_sendrecv(ept, REGULATOR_RPMSG_ENABLE,
|
||||||
(struct regulator_rpmsg_header_s *)msg,
|
(struct regulator_rpmsg_header_s *)msg,
|
||||||
len);
|
len);
|
||||||
@ -552,7 +552,7 @@ static int regulator_rpmsg_disable(FAR struct regulator_dev_s *rdev)
|
|||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
strcpy(msg->name, name);
|
strlcpy(msg->name, name, len - sizeof(*msg));
|
||||||
return regulator_rpmsg_sendrecv(ept, REGULATOR_RPMSG_DISABLE,
|
return regulator_rpmsg_sendrecv(ept, REGULATOR_RPMSG_DISABLE,
|
||||||
(struct regulator_rpmsg_header_s *)msg,
|
(struct regulator_rpmsg_header_s *)msg,
|
||||||
len);
|
len);
|
||||||
@ -580,7 +580,7 @@ static int regulator_rpmsg_set_voltage(FAR struct regulator_dev_s *rdev,
|
|||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
strcpy(msg->name, name);
|
strlcpy(msg->name, name, len - sizeof(*msg));
|
||||||
msg->min_uv = min_uv;
|
msg->min_uv = min_uv;
|
||||||
msg->max_uv = max_uv;
|
msg->max_uv = max_uv;
|
||||||
|
|
||||||
@ -609,7 +609,7 @@ static int regulator_rpmsg_get_voltage(FAR struct regulator_dev_s *rdev)
|
|||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
strcpy(msg->name, name);
|
strlcpy(msg->name, name, len - sizeof(*msg));
|
||||||
return regulator_rpmsg_sendrecv(ept, REGULATOR_RPMSG_GET_VOLTAGE,
|
return regulator_rpmsg_sendrecv(ept, REGULATOR_RPMSG_GET_VOLTAGE,
|
||||||
(struct regulator_rpmsg_header_s *)msg,
|
(struct regulator_rpmsg_header_s *)msg,
|
||||||
len);
|
len);
|
||||||
@ -635,7 +635,7 @@ static int regulator_rpmsg_is_enabled(FAR struct regulator_dev_s *rdev)
|
|||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
strcpy(msg->name, name);
|
strlcpy(msg->name, name, len - sizeof(*msg));
|
||||||
return regulator_rpmsg_sendrecv(ept, REGULATOR_RPMSG_IS_ENABLED,
|
return regulator_rpmsg_sendrecv(ept, REGULATOR_RPMSG_IS_ENABLED,
|
||||||
(struct regulator_rpmsg_header_s *)msg,
|
(struct regulator_rpmsg_header_s *)msg,
|
||||||
len);
|
len);
|
||||||
|
@ -1300,13 +1300,15 @@ sensor_rpmsg_register(FAR struct sensor_lowerhalf_s *lower,
|
|||||||
{
|
{
|
||||||
FAR struct sensor_rpmsg_ept_s *sre;
|
FAR struct sensor_rpmsg_ept_s *sre;
|
||||||
FAR struct sensor_rpmsg_dev_s *dev;
|
FAR struct sensor_rpmsg_dev_s *dev;
|
||||||
|
size_t size;
|
||||||
|
|
||||||
if (lower->ops->fetch)
|
if (lower->ops->fetch)
|
||||||
{
|
{
|
||||||
return lower;
|
return lower;
|
||||||
}
|
}
|
||||||
|
|
||||||
dev = kmm_zalloc(sizeof(*dev) + strlen(path));
|
size = strlen(path);
|
||||||
|
dev = kmm_zalloc(sizeof(*dev) + size);
|
||||||
if (!dev)
|
if (!dev)
|
||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -1316,7 +1318,7 @@ sensor_rpmsg_register(FAR struct sensor_lowerhalf_s *lower,
|
|||||||
|
|
||||||
list_initialize(&dev->stublist);
|
list_initialize(&dev->stublist);
|
||||||
list_initialize(&dev->proxylist);
|
list_initialize(&dev->proxylist);
|
||||||
strcpy(dev->path, path);
|
strlcpy(dev->path, path, size + 1);
|
||||||
|
|
||||||
dev->nadvertisers = !!lower->ops->activate;
|
dev->nadvertisers = !!lower->ops->activate;
|
||||||
dev->push_event = lower->push_event;
|
dev->push_event = lower->push_event;
|
||||||
|
@ -98,9 +98,11 @@ static int usensor_register(FAR struct usensor_context_s *usensor,
|
|||||||
FAR const struct sensor_reginfo_s *info)
|
FAR const struct sensor_reginfo_s *info)
|
||||||
{
|
{
|
||||||
FAR struct usensor_lowerhalf_s *lower;
|
FAR struct usensor_lowerhalf_s *lower;
|
||||||
|
size_t size;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
lower = kmm_zalloc(sizeof(*lower) + strlen(info->path));
|
size = strlen(info->path);
|
||||||
|
lower = kmm_zalloc(sizeof(*lower) + size);
|
||||||
if (!lower)
|
if (!lower)
|
||||||
{
|
{
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
@ -109,7 +111,7 @@ static int usensor_register(FAR struct usensor_context_s *usensor,
|
|||||||
lower->driver.nbuffer = info->nbuffer;
|
lower->driver.nbuffer = info->nbuffer;
|
||||||
lower->driver.persist = info->persist;
|
lower->driver.persist = info->persist;
|
||||||
lower->driver.ops = &g_usensor_ops;
|
lower->driver.ops = &g_usensor_ops;
|
||||||
strcpy(lower->path, info->path);
|
strlcpy(lower->path, info->path, size + 1);
|
||||||
ret = sensor_custom_register(&lower->driver, lower->path, info->esize);
|
ret = sensor_custom_register(&lower->driver, lower->path, info->esize);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
|
@ -1546,7 +1546,7 @@ static int add_interface(FAR const char *path,
|
|||||||
|
|
||||||
/* Start with calling @path the interface name. */
|
/* Start with calling @path the interface name. */
|
||||||
|
|
||||||
strcpy(buf, path);
|
strlcpy(buf, path, sizeof(buf));
|
||||||
|
|
||||||
/* Is the interface actually in a directory named @path? */
|
/* Is the interface actually in a directory named @path? */
|
||||||
|
|
||||||
|
@ -428,7 +428,7 @@ static int skel_readdir(FAR struct fs_dirent_s *dir,
|
|||||||
|
|
||||||
/* TODO: Add device specific entries */
|
/* TODO: Add device specific entries */
|
||||||
|
|
||||||
strcpy(filename, "dummy");
|
strlcpy(filename, "dummy", sizeof(filename));
|
||||||
|
|
||||||
/* TODO: Specify the type of entry */
|
/* TODO: Specify the type of entry */
|
||||||
|
|
||||||
|
@ -160,6 +160,7 @@ static int romfs_open(FAR struct file *filep, FAR const char *relpath,
|
|||||||
struct romfs_nodeinfo_s nodeinfo;
|
struct romfs_nodeinfo_s nodeinfo;
|
||||||
FAR struct romfs_mountpt_s *rm;
|
FAR struct romfs_mountpt_s *rm;
|
||||||
FAR struct romfs_file_s *rf;
|
FAR struct romfs_file_s *rf;
|
||||||
|
size_t size;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
finfo("Open '%s'\n", relpath);
|
finfo("Open '%s'\n", relpath);
|
||||||
@ -247,7 +248,8 @@ static int romfs_open(FAR struct file *filep, FAR const char *relpath,
|
|||||||
* file.
|
* file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
rf = kmm_zalloc(sizeof(struct romfs_file_s) + strlen(relpath));
|
size = strlen(relpath);
|
||||||
|
rf = kmm_zalloc(sizeof(struct romfs_file_s) + size);
|
||||||
if (!rf)
|
if (!rf)
|
||||||
{
|
{
|
||||||
ferr("ERROR: Failed to allocate private data\n");
|
ferr("ERROR: Failed to allocate private data\n");
|
||||||
@ -261,7 +263,7 @@ static int romfs_open(FAR struct file *filep, FAR const char *relpath,
|
|||||||
|
|
||||||
rf->rf_size = nodeinfo.rn_size;
|
rf->rf_size = nodeinfo.rn_size;
|
||||||
rf->rf_type = (uint8_t)(nodeinfo.rn_next & RFNEXT_ALLMODEMASK);
|
rf->rf_type = (uint8_t)(nodeinfo.rn_next & RFNEXT_ALLMODEMASK);
|
||||||
strcpy(rf->rf_path, relpath);
|
strlcpy(rf->rf_path, relpath, size + 1);
|
||||||
|
|
||||||
/* Get the start of the file data */
|
/* Get the start of the file data */
|
||||||
|
|
||||||
|
@ -415,9 +415,11 @@ static int romfs_cachenode(FAR struct romfs_mountpt_s *rm,
|
|||||||
uint32_t linkoffset;
|
uint32_t linkoffset;
|
||||||
uint32_t info;
|
uint32_t info;
|
||||||
uint8_t num = 0;
|
uint8_t num = 0;
|
||||||
|
size_t nsize;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
nodeinfo = kmm_zalloc(sizeof(struct romfs_nodeinfo_s) + strlen(name));
|
nsize = strlen(name);
|
||||||
|
nodeinfo = kmm_zalloc(sizeof(struct romfs_nodeinfo_s) + nsize);
|
||||||
if (nodeinfo == NULL)
|
if (nodeinfo == NULL)
|
||||||
{
|
{
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
@ -426,8 +428,8 @@ static int romfs_cachenode(FAR struct romfs_mountpt_s *rm,
|
|||||||
*pnodeinfo = nodeinfo;
|
*pnodeinfo = nodeinfo;
|
||||||
nodeinfo->rn_offset = offset;
|
nodeinfo->rn_offset = offset;
|
||||||
nodeinfo->rn_next = next;
|
nodeinfo->rn_next = next;
|
||||||
nodeinfo->rn_namesize = strlen(name);
|
nodeinfo->rn_namesize = nsize;
|
||||||
strcpy(nodeinfo->rn_name, name);
|
strlcpy(nodeinfo->rn_name, name, nsize + 1);
|
||||||
if (!IS_DIRECTORY(next))
|
if (!IS_DIRECTORY(next))
|
||||||
{
|
{
|
||||||
nodeinfo->rn_size = size;
|
nodeinfo->rn_size = size;
|
||||||
|
@ -405,8 +405,7 @@ int rpmsgfs_client_open(FAR void *handle, FAR const char *pathname,
|
|||||||
uint32_t space;
|
uint32_t space;
|
||||||
size_t len;
|
size_t len;
|
||||||
|
|
||||||
len = sizeof(*msg);
|
len = sizeof(*msg) + strlen(pathname) + 1;
|
||||||
len += strlen(pathname) + 1;
|
|
||||||
|
|
||||||
msg = rpmsgfs_get_tx_payload_buffer(priv, &space);
|
msg = rpmsgfs_get_tx_payload_buffer(priv, &space);
|
||||||
if (!msg)
|
if (!msg)
|
||||||
@ -418,7 +417,7 @@ int rpmsgfs_client_open(FAR void *handle, FAR const char *pathname,
|
|||||||
|
|
||||||
msg->flags = flags;
|
msg->flags = flags;
|
||||||
msg->mode = mode;
|
msg->mode = mode;
|
||||||
strcpy(msg->pathname, pathname);
|
strlcpy(msg->pathname, pathname, space - sizeof(*msg));
|
||||||
|
|
||||||
return rpmsgfs_send_recv(priv, RPMSGFS_OPEN, false,
|
return rpmsgfs_send_recv(priv, RPMSGFS_OPEN, false,
|
||||||
(struct rpmsgfs_header_s *)msg, len, NULL);
|
(struct rpmsgfs_header_s *)msg, len, NULL);
|
||||||
@ -651,8 +650,7 @@ FAR void *rpmsgfs_client_opendir(FAR void *handle, FAR const char *name)
|
|||||||
size_t len;
|
size_t len;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
len = sizeof(*msg);
|
len = sizeof(*msg) + strlen(name) + 1;
|
||||||
len += strlen(name) + 1;
|
|
||||||
|
|
||||||
msg = rpmsgfs_get_tx_payload_buffer(priv, &space);
|
msg = rpmsgfs_get_tx_payload_buffer(priv, &space);
|
||||||
if (!msg)
|
if (!msg)
|
||||||
@ -662,7 +660,7 @@ FAR void *rpmsgfs_client_opendir(FAR void *handle, FAR const char *name)
|
|||||||
|
|
||||||
DEBUGASSERT(len <= space);
|
DEBUGASSERT(len <= space);
|
||||||
|
|
||||||
strcpy(msg->pathname, name);
|
strlcpy(msg->pathname, name, space - sizeof(*msg));
|
||||||
|
|
||||||
ret = rpmsgfs_send_recv(priv, RPMSGFS_OPENDIR, false,
|
ret = rpmsgfs_send_recv(priv, RPMSGFS_OPENDIR, false,
|
||||||
(struct rpmsgfs_header_s *)msg, len, NULL);
|
(struct rpmsgfs_header_s *)msg, len, NULL);
|
||||||
@ -761,8 +759,7 @@ int rpmsgfs_client_statfs(FAR void *handle, FAR const char *path,
|
|||||||
uint32_t space;
|
uint32_t space;
|
||||||
size_t len;
|
size_t len;
|
||||||
|
|
||||||
len = sizeof(*msg);
|
len = sizeof(*msg) + strlen(path) + 1;
|
||||||
len += strlen(path) + 1;
|
|
||||||
|
|
||||||
msg = rpmsgfs_get_tx_payload_buffer(priv, &space);
|
msg = rpmsgfs_get_tx_payload_buffer(priv, &space);
|
||||||
if (!msg)
|
if (!msg)
|
||||||
@ -772,7 +769,7 @@ int rpmsgfs_client_statfs(FAR void *handle, FAR const char *path,
|
|||||||
|
|
||||||
DEBUGASSERT(len <= space);
|
DEBUGASSERT(len <= space);
|
||||||
|
|
||||||
strcpy(msg->pathname, path);
|
strlcpy(msg->pathname, path, space - sizeof(*msg));
|
||||||
|
|
||||||
return rpmsgfs_send_recv(priv, RPMSGFS_STATFS, false,
|
return rpmsgfs_send_recv(priv, RPMSGFS_STATFS, false,
|
||||||
(struct rpmsgfs_header_s *)msg, len, buf);
|
(struct rpmsgfs_header_s *)msg, len, buf);
|
||||||
@ -785,8 +782,7 @@ int rpmsgfs_client_unlink(FAR void *handle, FAR const char *pathname)
|
|||||||
uint32_t space;
|
uint32_t space;
|
||||||
size_t len;
|
size_t len;
|
||||||
|
|
||||||
len = sizeof(*msg);
|
len = sizeof(*msg) + strlen(pathname) + 1;
|
||||||
len += strlen(pathname) + 1;
|
|
||||||
|
|
||||||
msg = rpmsgfs_get_tx_payload_buffer(priv, &space);
|
msg = rpmsgfs_get_tx_payload_buffer(priv, &space);
|
||||||
if (!msg)
|
if (!msg)
|
||||||
@ -796,7 +792,7 @@ int rpmsgfs_client_unlink(FAR void *handle, FAR const char *pathname)
|
|||||||
|
|
||||||
DEBUGASSERT(len <= space);
|
DEBUGASSERT(len <= space);
|
||||||
|
|
||||||
strcpy(msg->pathname, pathname);
|
strlcpy(msg->pathname, pathname, space - sizeof(*msg));
|
||||||
|
|
||||||
return rpmsgfs_send_recv(priv, RPMSGFS_UNLINK, false,
|
return rpmsgfs_send_recv(priv, RPMSGFS_UNLINK, false,
|
||||||
(struct rpmsgfs_header_s *)msg, len, NULL);
|
(struct rpmsgfs_header_s *)msg, len, NULL);
|
||||||
@ -810,8 +806,7 @@ int rpmsgfs_client_mkdir(FAR void *handle, FAR const char *pathname,
|
|||||||
uint32_t space;
|
uint32_t space;
|
||||||
size_t len;
|
size_t len;
|
||||||
|
|
||||||
len = sizeof(*msg);
|
len = sizeof(*msg) + strlen(pathname) + 1;
|
||||||
len += strlen(pathname) + 1;
|
|
||||||
|
|
||||||
msg = rpmsgfs_get_tx_payload_buffer(priv, &space);
|
msg = rpmsgfs_get_tx_payload_buffer(priv, &space);
|
||||||
if (!msg)
|
if (!msg)
|
||||||
@ -820,7 +815,7 @@ int rpmsgfs_client_mkdir(FAR void *handle, FAR const char *pathname,
|
|||||||
}
|
}
|
||||||
|
|
||||||
msg->mode = mode;
|
msg->mode = mode;
|
||||||
strcpy(msg->pathname, pathname);
|
strlcpy(msg->pathname, pathname, space - sizeof(*msg));
|
||||||
|
|
||||||
return rpmsgfs_send_recv(priv, RPMSGFS_MKDIR, false,
|
return rpmsgfs_send_recv(priv, RPMSGFS_MKDIR, false,
|
||||||
(struct rpmsgfs_header_s *)msg, len, NULL);
|
(struct rpmsgfs_header_s *)msg, len, NULL);
|
||||||
@ -833,8 +828,7 @@ int rpmsgfs_client_rmdir(FAR void *handle, FAR const char *pathname)
|
|||||||
uint32_t space;
|
uint32_t space;
|
||||||
size_t len;
|
size_t len;
|
||||||
|
|
||||||
len = sizeof(*msg);
|
len = sizeof(*msg) + strlen(pathname) + 1;
|
||||||
len += strlen(pathname) + 1;
|
|
||||||
|
|
||||||
msg = rpmsgfs_get_tx_payload_buffer(priv, &space);
|
msg = rpmsgfs_get_tx_payload_buffer(priv, &space);
|
||||||
if (!msg)
|
if (!msg)
|
||||||
@ -844,7 +838,7 @@ int rpmsgfs_client_rmdir(FAR void *handle, FAR const char *pathname)
|
|||||||
|
|
||||||
DEBUGASSERT(len <= space);
|
DEBUGASSERT(len <= space);
|
||||||
|
|
||||||
strcpy(msg->pathname, pathname);
|
strlcpy(msg->pathname, pathname, space - sizeof(*msg));
|
||||||
|
|
||||||
return rpmsgfs_send_recv(priv, RPMSGFS_RMDIR, false,
|
return rpmsgfs_send_recv(priv, RPMSGFS_RMDIR, false,
|
||||||
(struct rpmsgfs_header_s *)msg, len, NULL);
|
(struct rpmsgfs_header_s *)msg, len, NULL);
|
||||||
@ -889,8 +883,7 @@ int rpmsgfs_client_stat(FAR void *handle, FAR const char *path,
|
|||||||
uint32_t space;
|
uint32_t space;
|
||||||
size_t len;
|
size_t len;
|
||||||
|
|
||||||
len = sizeof(*msg);
|
len = sizeof(*msg) + strlen(path) + 1;
|
||||||
len += strlen(path) + 1;
|
|
||||||
|
|
||||||
msg = rpmsgfs_get_tx_payload_buffer(priv, &space);
|
msg = rpmsgfs_get_tx_payload_buffer(priv, &space);
|
||||||
if (!msg)
|
if (!msg)
|
||||||
@ -900,7 +893,7 @@ int rpmsgfs_client_stat(FAR void *handle, FAR const char *path,
|
|||||||
|
|
||||||
DEBUGASSERT(len <= space);
|
DEBUGASSERT(len <= space);
|
||||||
|
|
||||||
strcpy(msg->pathname, path);
|
strlcpy(msg->pathname, path, space - sizeof(*msg));
|
||||||
|
|
||||||
return rpmsgfs_send_recv(priv, RPMSGFS_STAT, false,
|
return rpmsgfs_send_recv(priv, RPMSGFS_STAT, false,
|
||||||
(struct rpmsgfs_header_s *)msg, len, buf);
|
(struct rpmsgfs_header_s *)msg, len, buf);
|
||||||
@ -928,8 +921,7 @@ int rpmsgfs_client_chstat(FAR void *handle, FAR const char *path,
|
|||||||
uint32_t space;
|
uint32_t space;
|
||||||
size_t len;
|
size_t len;
|
||||||
|
|
||||||
len = sizeof(*msg);
|
len = sizeof(*msg) + strlen(path) + 1;
|
||||||
len += strlen(path) + 1;
|
|
||||||
|
|
||||||
msg = rpmsgfs_get_tx_payload_buffer(priv, &space);
|
msg = rpmsgfs_get_tx_payload_buffer(priv, &space);
|
||||||
if (!msg)
|
if (!msg)
|
||||||
@ -941,7 +933,7 @@ int rpmsgfs_client_chstat(FAR void *handle, FAR const char *path,
|
|||||||
|
|
||||||
msg->flags = flags;
|
msg->flags = flags;
|
||||||
memcpy(&msg->buf, buf, sizeof(*buf));
|
memcpy(&msg->buf, buf, sizeof(*buf));
|
||||||
strcpy(msg->pathname, path);
|
strlcpy(msg->pathname, path, space - sizeof(*msg));
|
||||||
|
|
||||||
return rpmsgfs_send_recv(priv, RPMSGFS_CHSTAT, false,
|
return rpmsgfs_send_recv(priv, RPMSGFS_CHSTAT, false,
|
||||||
(struct rpmsgfs_header_s *)msg, len, NULL);
|
(struct rpmsgfs_header_s *)msg, len, NULL);
|
||||||
|
@ -600,6 +600,7 @@ static int rpmsgfs_readdir_handler(FAR struct rpmsg_endpoint *ept,
|
|||||||
FAR struct dirent *entry;
|
FAR struct dirent *entry;
|
||||||
int ret = -ENOENT;
|
int ret = -ENOENT;
|
||||||
FAR void *dir;
|
FAR void *dir;
|
||||||
|
size_t size;
|
||||||
|
|
||||||
dir = rpmsgfs_get_dir(priv, msg->fd);
|
dir = rpmsgfs_get_dir(priv, msg->fd);
|
||||||
if (dir)
|
if (dir)
|
||||||
@ -607,9 +608,12 @@ static int rpmsgfs_readdir_handler(FAR struct rpmsg_endpoint *ept,
|
|||||||
entry = readdir(dir);
|
entry = readdir(dir);
|
||||||
if (entry)
|
if (entry)
|
||||||
{
|
{
|
||||||
|
size = MIN(rpmsg_virtio_get_buffer_size(ept->rdev),
|
||||||
|
rpmsg_virtio_get_rx_buffer_size(ept->rdev));
|
||||||
|
size = MIN(size - len, strlen(entry->d_name) + 1);
|
||||||
msg->type = entry->d_type;
|
msg->type = entry->d_type;
|
||||||
strcpy(msg->name, entry->d_name);
|
strlcpy(msg->name, entry->d_name, size);
|
||||||
len += strlen(entry->d_name) + 1;
|
len += size;
|
||||||
ret = 0;
|
ret = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,6 +27,7 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
#include <limits.h>
|
||||||
|
|
||||||
#include <nuttx/kmalloc.h>
|
#include <nuttx/kmalloc.h>
|
||||||
#include <nuttx/fs/fs.h>
|
#include <nuttx/fs/fs.h>
|
||||||
@ -549,7 +550,7 @@ static int dir_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
|
|||||||
|
|
||||||
if (cmd == FIOC_FILEPATH)
|
if (cmd == FIOC_FILEPATH)
|
||||||
{
|
{
|
||||||
strcpy((FAR char *)(uintptr_t)arg, dir->fd_path);
|
strlcpy((FAR char *)(uintptr_t)arg, dir->fd_path, PATH_MAX);
|
||||||
ret = OK;
|
ret = OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -68,7 +68,8 @@
|
|||||||
(e)->entry.target_offset = sizeof((e)->entry); \
|
(e)->entry.target_offset = sizeof((e)->entry); \
|
||||||
(e)->entry.next_offset = sizeof(*(e)); \
|
(e)->entry.next_offset = sizeof(*(e)); \
|
||||||
(e)->target.target.u.target_size = sizeof(*(e)) - sizeof((e)->entry); \
|
(e)->target.target.u.target_size = sizeof(*(e)) - sizeof((e)->entry); \
|
||||||
strcpy((e)->target.target.u.user.name, (target_name)); \
|
strlcpy((e)->target.target.u.user.name, (target_name), \
|
||||||
|
sizeof((e)->target.target.u.user.name)); \
|
||||||
} \
|
} \
|
||||||
while(0)
|
while(0)
|
||||||
|
|
||||||
|
@ -196,11 +196,11 @@ static inline int bt_addr_le_to_str(FAR const bt_addr_le_t *addr, char *str,
|
|||||||
switch (addr->type)
|
switch (addr->type)
|
||||||
{
|
{
|
||||||
case BT_ADDR_LE_PUBLIC:
|
case BT_ADDR_LE_PUBLIC:
|
||||||
strcpy(type, "public");
|
strlcpy(type, "public", sizeof(type));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case BT_ADDR_LE_RANDOM:
|
case BT_ADDR_LE_RANDOM:
|
||||||
strcpy(type, "random");
|
strlcpy(type, "random", sizeof(type));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
@ -201,7 +201,7 @@ do_nftw(FAR char *path, nftw_cb_t fn, int fdlimit, int flags, int level)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
strcpy(path + j, de->d_name);
|
strlcpy(path + j, de->d_name, PATH_MAX - j);
|
||||||
r = do_nftw(path, fn, fdlimit - 1, flags, level + 1);
|
r = do_nftw(path, fn, fdlimit - 1, flags, level + 1);
|
||||||
if (r)
|
if (r)
|
||||||
{
|
{
|
||||||
|
@ -64,6 +64,8 @@ int getgrbuf_r(gid_t gid, FAR const char *name, FAR const char *passwd,
|
|||||||
{
|
{
|
||||||
size_t reqdlen;
|
size_t reqdlen;
|
||||||
size_t padlen;
|
size_t padlen;
|
||||||
|
size_t namesize;
|
||||||
|
size_t passwdsize;
|
||||||
|
|
||||||
/* In 'buf' a NULL pointer value will be stored, which must be naturally
|
/* In 'buf' a NULL pointer value will be stored, which must be naturally
|
||||||
* aligned, followed by the null terminated group name string and the null
|
* aligned, followed by the null terminated group name string and the null
|
||||||
@ -71,8 +73,10 @@ int getgrbuf_r(gid_t gid, FAR const char *name, FAR const char *passwd,
|
|||||||
* sufficient buffer space was supplied by the caller.
|
* sufficient buffer space was supplied by the caller.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
namesize = strlen(name) + 1;
|
||||||
|
passwdsize = strlen(passwd) + 1;
|
||||||
padlen = sizeof(FAR void *) - ((uintptr_t)buf % sizeof(FAR char *));
|
padlen = sizeof(FAR void *) - ((uintptr_t)buf % sizeof(FAR char *));
|
||||||
reqdlen = sizeof(FAR void *) + strlen(name) + 1 + strlen(passwd) + 1;
|
reqdlen = sizeof(FAR void *) + namesize + passwdsize;
|
||||||
|
|
||||||
if (buflen < padlen + reqdlen)
|
if (buflen < padlen + reqdlen)
|
||||||
{
|
{
|
||||||
@ -84,10 +88,10 @@ int getgrbuf_r(gid_t gid, FAR const char *name, FAR const char *passwd,
|
|||||||
|
|
||||||
grp->gr_mem = (FAR char **)&buf[padlen];
|
grp->gr_mem = (FAR char **)&buf[padlen];
|
||||||
grp->gr_name = &buf[padlen + sizeof(FAR char *)];
|
grp->gr_name = &buf[padlen + sizeof(FAR char *)];
|
||||||
grp->gr_passwd = &buf[padlen + sizeof(FAR char *) + strlen(name) + 1];
|
grp->gr_passwd = &buf[padlen + sizeof(FAR char *) + namesize];
|
||||||
|
|
||||||
strcpy(grp->gr_name, name);
|
strlcpy(grp->gr_name, name, namesize);
|
||||||
strcpy(grp->gr_passwd, passwd);
|
strlcpy(grp->gr_passwd, passwd, passwdsize);
|
||||||
grp->gr_gid = gid;
|
grp->gr_gid = gid;
|
||||||
*grp->gr_mem = NULL;
|
*grp->gr_mem = NULL;
|
||||||
|
|
||||||
|
@ -84,6 +84,7 @@ ENVPATH_HANDLE envpath_init(FAR const char *name)
|
|||||||
{
|
{
|
||||||
FAR struct envpath_s *envpath;
|
FAR struct envpath_s *envpath;
|
||||||
FAR char *path;
|
FAR char *path;
|
||||||
|
size_t size;
|
||||||
|
|
||||||
/* Get the value of the PATH variable */
|
/* Get the value of the PATH variable */
|
||||||
|
|
||||||
@ -99,8 +100,9 @@ ENVPATH_HANDLE envpath_init(FAR const char *name)
|
|||||||
|
|
||||||
/* Allocate a container for the PATH variable contents */
|
/* Allocate a container for the PATH variable contents */
|
||||||
|
|
||||||
|
size = strlen(path) + 1;
|
||||||
envpath = (FAR struct envpath_s *)
|
envpath = (FAR struct envpath_s *)
|
||||||
lib_malloc(SIZEOF_ENVPATH_S(strlen(path) + 1));
|
lib_malloc(SIZEOF_ENVPATH_S(size));
|
||||||
|
|
||||||
if (!envpath)
|
if (!envpath)
|
||||||
{
|
{
|
||||||
@ -111,7 +113,7 @@ ENVPATH_HANDLE envpath_init(FAR const char *name)
|
|||||||
|
|
||||||
/* Populate the container */
|
/* Populate the container */
|
||||||
|
|
||||||
strcpy(envpath->path, path);
|
strlcpy(envpath->path, path, size);
|
||||||
envpath->next = envpath->path;
|
envpath->next = envpath->path;
|
||||||
|
|
||||||
/* And return the containing cast to an opaque handle */
|
/* And return the containing cast to an opaque handle */
|
||||||
|
@ -69,9 +69,16 @@ int getpwbuf_r(uid_t uid, gid_t gid, FAR const char *name,
|
|||||||
FAR char *buf, size_t buflen, FAR struct passwd **result)
|
FAR char *buf, size_t buflen, FAR struct passwd **result)
|
||||||
{
|
{
|
||||||
size_t reqdlen;
|
size_t reqdlen;
|
||||||
|
size_t nsize;
|
||||||
|
size_t gsize;
|
||||||
|
size_t dsize;
|
||||||
|
size_t ssize;
|
||||||
|
|
||||||
reqdlen = strlen(name) + 1 + strlen(gecos) + 1 + strlen(dir) + 1 +
|
nsize = strlen(name) + 1;
|
||||||
strlen(shell) + 1;
|
gsize = strlen(gecos) + 1;
|
||||||
|
dsize = strlen(dir) + 1;
|
||||||
|
ssize = strlen(shell) + 1;
|
||||||
|
reqdlen = nsize + gsize + dsize + ssize;
|
||||||
|
|
||||||
if (buflen < reqdlen)
|
if (buflen < reqdlen)
|
||||||
{
|
{
|
||||||
@ -82,16 +89,16 @@ int getpwbuf_r(uid_t uid, gid_t gid, FAR const char *name,
|
|||||||
}
|
}
|
||||||
|
|
||||||
pwd->pw_name = buf;
|
pwd->pw_name = buf;
|
||||||
pwd->pw_gecos = &buf[strlen(name) + 1];
|
pwd->pw_gecos = &buf[nsize];
|
||||||
pwd->pw_dir = &buf[strlen(name) + strlen(gecos) + 2];
|
pwd->pw_dir = &buf[nsize + gsize];
|
||||||
pwd->pw_shell = &buf[strlen(name) + strlen(gecos) + strlen(dir) + 3];
|
pwd->pw_shell = &buf[nsize + gsize + dsize];
|
||||||
|
|
||||||
pwd->pw_uid = uid;
|
pwd->pw_uid = uid;
|
||||||
pwd->pw_gid = gid;
|
pwd->pw_gid = gid;
|
||||||
strcpy(pwd->pw_name, name);
|
strlcpy(pwd->pw_name, name, nsize);
|
||||||
strcpy(pwd->pw_gecos, gecos);
|
strlcpy(pwd->pw_gecos, gecos, gsize);
|
||||||
strcpy(pwd->pw_dir, dir);
|
strlcpy(pwd->pw_dir, dir, dsize);
|
||||||
strcpy(pwd->pw_shell, shell);
|
strlcpy(pwd->pw_shell, shell, ssize);
|
||||||
|
|
||||||
*result = pwd;
|
*result = pwd;
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -28,6 +28,7 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#include <limits.h>
|
||||||
|
|
||||||
#include <nuttx/serial/pty.h>
|
#include <nuttx/serial/pty.h>
|
||||||
|
|
||||||
@ -162,7 +163,7 @@ int openpty(FAR int *master, FAR int *slave, FAR char *name,
|
|||||||
|
|
||||||
if (name != NULL)
|
if (name != NULL)
|
||||||
{
|
{
|
||||||
strcpy(name, buf);
|
strlcpy(name, buf, NAME_MAX);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Configure the pseudo terminal slave */
|
/* Configure the pseudo terminal slave */
|
||||||
|
@ -35,11 +35,12 @@
|
|||||||
#undef strdup /* See mm/README.txt */
|
#undef strdup /* See mm/README.txt */
|
||||||
FAR char *strdup(FAR const char *s)
|
FAR char *strdup(FAR const char *s)
|
||||||
{
|
{
|
||||||
FAR char *news = (FAR char *)lib_malloc(strlen(s) + 1);
|
size_t size = strlen(s) + 1;
|
||||||
|
FAR char *news = (FAR char *)lib_malloc(size);
|
||||||
|
|
||||||
if (news)
|
if (news)
|
||||||
{
|
{
|
||||||
strcpy(news, s);
|
strlcpy(news, s, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
return news;
|
return news;
|
||||||
|
@ -79,7 +79,7 @@ int ttyname_r(int fd, FAR char *buf, size_t buflen)
|
|||||||
return ERANGE;
|
return ERANGE;
|
||||||
}
|
}
|
||||||
|
|
||||||
strcpy(buf, name);
|
strlcpy(buf, name, buflen);
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -624,7 +624,7 @@ static int tzload(FAR const char *name,
|
|||||||
size_t namelen = strlen(name);
|
size_t namelen = strlen(name);
|
||||||
const char tzdirslash[sizeof(TZDIR)] = TZDIR "/";
|
const char tzdirslash[sizeof(TZDIR)] = TZDIR "/";
|
||||||
|
|
||||||
if (sizeof(fullname) - sizeof(tzdirslash) <= namelen)
|
if (sizeof(lsp->fullname) - sizeof(tzdirslash) <= namelen)
|
||||||
{
|
{
|
||||||
goto oops;
|
goto oops;
|
||||||
}
|
}
|
||||||
@ -635,7 +635,8 @@ static int tzload(FAR const char *name,
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
memcpy(fullname, tzdirslash, sizeof(tzdirslash));
|
memcpy(fullname, tzdirslash, sizeof(tzdirslash));
|
||||||
strcpy(fullname + sizeof(tzdirslash), name);
|
strlcpy(fullname + sizeof(tzdirslash), name,
|
||||||
|
sizeof(lsp->fullname) - sizeof(tzdirslash));
|
||||||
|
|
||||||
/* Set doaccess if NAME contains a ".." file name
|
/* Set doaccess if NAME contains a ".." file name
|
||||||
* component, as such a name could read a file outside
|
* component, as such a name could read a file outside
|
||||||
@ -947,7 +948,7 @@ static int tzload(FAR const char *name,
|
|||||||
|
|
||||||
if (j + tsabbrlen < TZ_MAX_CHARS)
|
if (j + tsabbrlen < TZ_MAX_CHARS)
|
||||||
{
|
{
|
||||||
strcpy(sp->chars + j, tsabbr);
|
strlcpy(sp->chars + j, tsabbr, sizeof(sp->chars) - j);
|
||||||
charcnt = j + tsabbrlen + 1;
|
charcnt = j + tsabbrlen + 1;
|
||||||
ts->ttis[i].tt_desigidx = j;
|
ts->ttis[i].tt_desigidx = j;
|
||||||
gotabbr++;
|
gotabbr++;
|
||||||
@ -2721,7 +2722,7 @@ static int zoneinit(FAR const char *name)
|
|||||||
g_lcl_ptr->goback = 0;
|
g_lcl_ptr->goback = 0;
|
||||||
g_lcl_ptr->goahead = 0;
|
g_lcl_ptr->goahead = 0;
|
||||||
init_ttinfo(&g_lcl_ptr->ttis[0], 0, FALSE, 0);
|
init_ttinfo(&g_lcl_ptr->ttis[0], 0, FALSE, 0);
|
||||||
strcpy(g_lcl_ptr->chars, g_utc);
|
strlcpy(g_lcl_ptr->chars, g_utc, sizeof(g_lcl_ptr->chars));
|
||||||
g_lcl_ptr->defaulttype = 0;
|
g_lcl_ptr->defaulttype = 0;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -2792,7 +2793,7 @@ void tzset(void)
|
|||||||
zoneinit("");
|
zoneinit("");
|
||||||
}
|
}
|
||||||
|
|
||||||
strcpy(g_lcl_tzname, name);
|
strlcpy(g_lcl_tzname, name, sizeof(g_lcl_tzname));
|
||||||
|
|
||||||
tzname:
|
tzname:
|
||||||
settzname();
|
settzname();
|
||||||
|
@ -121,7 +121,7 @@ FAR char *getcwd(FAR char *buf, size_t size)
|
|||||||
|
|
||||||
/* Copy the cwd to the user buffer */
|
/* Copy the cwd to the user buffer */
|
||||||
|
|
||||||
strcpy(buf, pwd);
|
strlcpy(buf, pwd, size);
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
#endif /* !CONFIG_DISABLE_ENVIRON */
|
#endif /* !CONFIG_DISABLE_ENVIRON */
|
||||||
|
@ -362,7 +362,7 @@ FAR struct ipt_replace *ipt_alloc_table(FAR const char *table,
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
strcpy(repl->name, table);
|
strlcpy(repl->name, table, sizeof(repl->name));
|
||||||
repl->valid_hooks = valid_hooks;
|
repl->valid_hooks = valid_hooks;
|
||||||
repl->num_entries = num_hooks + 1;
|
repl->num_entries = num_hooks + 1;
|
||||||
repl->size = entry_size;
|
repl->size = entry_size;
|
||||||
@ -386,7 +386,8 @@ FAR struct ipt_replace *ipt_alloc_table(FAR const char *table,
|
|||||||
}
|
}
|
||||||
|
|
||||||
error_entry = (FAR struct ipt_error_entry_s *)entry;
|
error_entry = (FAR struct ipt_error_entry_s *)entry;
|
||||||
strcpy(error_entry->target.errorname, XT_ERROR_TARGET);
|
strlcpy(error_entry->target.errorname, XT_ERROR_TARGET,
|
||||||
|
sizeof(error_entry->target.errorname));
|
||||||
IPT_FILL_ENTRY(error_entry, XT_ERROR_TARGET);
|
IPT_FILL_ENTRY(error_entry, XT_ERROR_TARGET);
|
||||||
|
|
||||||
return repl;
|
return repl;
|
||||||
|
@ -65,6 +65,7 @@ int env_dup(FAR struct task_group_s *group, FAR char * const *envcp)
|
|||||||
{
|
{
|
||||||
FAR char **envp = NULL;
|
FAR char **envp = NULL;
|
||||||
size_t envc = 0;
|
size_t envc = 0;
|
||||||
|
size_t size;
|
||||||
int ret = OK;
|
int ret = OK;
|
||||||
|
|
||||||
DEBUGASSERT(group != NULL);
|
DEBUGASSERT(group != NULL);
|
||||||
@ -112,7 +113,8 @@ int env_dup(FAR struct task_group_s *group, FAR char * const *envcp)
|
|||||||
|
|
||||||
while (envc-- > 0)
|
while (envc-- > 0)
|
||||||
{
|
{
|
||||||
envp[envc] = group_malloc(group, strlen(envcp[envc]) + 1);
|
size = strlen(envcp[envc]) + 1;
|
||||||
|
envp[envc] = group_malloc(group, size);
|
||||||
if (envp[envc] == NULL)
|
if (envp[envc] == NULL)
|
||||||
{
|
{
|
||||||
while (envp[++envc] != NULL)
|
while (envp[++envc] != NULL)
|
||||||
@ -125,7 +127,7 @@ int env_dup(FAR struct task_group_s *group, FAR char * const *envcp)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
strcpy(envp[envc], envcp[envc]);
|
strlcpy(envp[envc], envcp[envc], size);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -591,8 +591,9 @@ static int nxtask_setup_stackargs(FAR struct task_tcb_s *tcb,
|
|||||||
|
|
||||||
stackargv[0] = str;
|
stackargv[0] = str;
|
||||||
nbytes = strlen(name) + 1;
|
nbytes = strlen(name) + 1;
|
||||||
strcpy(str, name);
|
strlcpy(str, name, strtablen);
|
||||||
str += nbytes;
|
str += nbytes;
|
||||||
|
strtablen -= nbytes;
|
||||||
|
|
||||||
/* Copy each argument */
|
/* Copy each argument */
|
||||||
|
|
||||||
@ -605,8 +606,9 @@ static int nxtask_setup_stackargs(FAR struct task_tcb_s *tcb,
|
|||||||
|
|
||||||
stackargv[i + 1] = str;
|
stackargv[i + 1] = str;
|
||||||
nbytes = strlen(argv[i]) + 1;
|
nbytes = strlen(argv[i]) + 1;
|
||||||
strcpy(str, argv[i]);
|
strlcpy(str, argv[i], strtablen);
|
||||||
str += nbytes;
|
str += nbytes;
|
||||||
|
strtablen -= nbytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Put a terminator entry at the end of the argv[] array. Then save the
|
/* Put a terminator entry at the end of the argv[] array. Then save the
|
||||||
|
Loading…
Reference in New Issue
Block a user