mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH 1/2] eeprom: at25: replace strncpy with strlcpy
@ 2025-03-14 10:45 Jules Maselbas
  2025-03-14 10:45 ` [PATCH 2/2] eeprom: at25: add explicit fallthrough Jules Maselbas
  2025-03-17  8:31 ` [PATCH 1/2] eeprom: at25: replace strncpy with strlcpy Sascha Hauer
  0 siblings, 2 replies; 3+ messages in thread
From: Jules Maselbas @ 2025-03-14 10:45 UTC (permalink / raw)
  To: barebox; +Cc: Jules Maselbas

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@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




^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH 2/2] eeprom: at25: add explicit fallthrough
  2025-03-14 10:45 [PATCH 1/2] eeprom: at25: replace strncpy with strlcpy Jules Maselbas
@ 2025-03-14 10:45 ` Jules Maselbas
  2025-03-17  8:31 ` [PATCH 1/2] eeprom: at25: replace strncpy with strlcpy Sascha Hauer
  1 sibling, 0 replies; 3+ messages in thread
From: Jules Maselbas @ 2025-03-14 10:45 UTC (permalink / raw)
  To: barebox; +Cc: Jules Maselbas

Signed-off-by: Jules Maselbas <jmaselbas@zdiv.net>
---
 drivers/eeprom/at25.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/eeprom/at25.c b/drivers/eeprom/at25.c
index 43e72677c9..f58e554616 100644
--- a/drivers/eeprom/at25.c
+++ b/drivers/eeprom/at25.c
@@ -87,8 +87,10 @@ static ssize_t at25_ee_read(struct cdev *cdev,
 	switch (at25->addrlen) {
 	default:	/* case 3 */
 		*cp++ = offset >> 16;
+		fallthrough;
 	case 2:
 		*cp++ = offset >> 8;
+		fallthrough;
 	case 1:
 	case 0:	/* can't happen: for better codegen */
 		*cp++ = offset >> 0;
@@ -168,8 +170,10 @@ static ssize_t at25_ee_write(struct cdev *cdev,
 		switch (at25->addrlen) {
 		default:	/* case 3 */
 			*cp++ = offset >> 16;
+			fallthrough;
 		case 2:
 			*cp++ = offset >> 8;
+			fallthrough;
 		case 1:
 		case 0:	/* can't happen: for better codegen */
 			*cp++ = offset >> 0;
-- 
2.48.1




^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH 1/2] eeprom: at25: replace strncpy with strlcpy
  2025-03-14 10:45 [PATCH 1/2] eeprom: at25: replace strncpy with strlcpy Jules Maselbas
  2025-03-14 10:45 ` [PATCH 2/2] eeprom: at25: add explicit fallthrough Jules Maselbas
@ 2025-03-17  8:31 ` Sascha Hauer
  1 sibling, 0 replies; 3+ messages in thread
From: Sascha Hauer @ 2025-03-17  8:31 UTC (permalink / raw)
  To: barebox, Jules Maselbas


On Fri, 14 Mar 2025 11:45:01 +0100, Jules Maselbas wrote:
> 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.
> 
> 

Applied, thanks!

[1/2] eeprom: at25: replace strncpy with strlcpy
      https://git.pengutronix.de/cgit/barebox/commit/?id=8265cfe43587 (link may not be stable)
[2/2] eeprom: at25: add explicit fallthrough
      https://git.pengutronix.de/cgit/barebox/commit/?id=6a2c56c934d1 (link may not be stable)

Best regards,
-- 
Sascha Hauer <s.hauer@pengutronix.de>




^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-03-17  8:31 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-03-14 10:45 [PATCH 1/2] eeprom: at25: replace strncpy with strlcpy Jules Maselbas
2025-03-14 10:45 ` [PATCH 2/2] eeprom: at25: add explicit fallthrough Jules Maselbas
2025-03-17  8:31 ` [PATCH 1/2] eeprom: at25: replace strncpy with strlcpy Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox