[PATCH 1/2] eeprom: at25: replace strncpy with strlcpy
Jules Maselbas
jmaselbas at zdiv.net
Fri Mar 14 03:45:01 PDT 2025
strncpy will not nul terminate the dst string in case the src is longer
than the the dst size, strlcpy will truncate and nul terminate the string.
Signed-off-by: Jules Maselbas <jmaselbas at zdiv.net>
---
drivers/eeprom/at25.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/eeprom/at25.c b/drivers/eeprom/at25.c
index ca1df82122..43e72677c9 100644
--- a/drivers/eeprom/at25.c
+++ b/drivers/eeprom/at25.c
@@ -243,7 +243,7 @@ static int at25_np_to_chip(struct device *dev,
return -ENODEV;
memset(chip, 0, sizeof(*chip));
- strncpy(chip->name, np->name, sizeof(chip->name));
+ strlcpy(chip->name, np->name, sizeof(chip->name));
if (of_property_read_u32(np, "size", &val) == 0 ||
of_property_read_u32(np, "at25,byte-len", &val) == 0) {
--
2.48.1
More information about the barebox
mailing list