* [PATCH] commands: hwclock: replace strncpy with strlcpy
@ 2025-03-14 21:33 Jules Maselbas
0 siblings, 0 replies; only message in thread
From: Jules Maselbas @ 2025-03-14 21:33 UTC (permalink / raw)
To: barebox; +Cc: Jules Maselbas
strncpy could leave the rtc_name buffer not nul-terminated, strlcpy will
always nul-terminate the dst buffer.
Also replace the hardcoded size with sizeof(rtc_name)
Signed-off-by: Jules Maselbas <jmaselbas@zdiv.net>
---
commands/hwclock.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/commands/hwclock.c b/commands/hwclock.c
index c594e070ac..33829e4118 100644
--- a/commands/hwclock.c
+++ b/commands/hwclock.c
@@ -95,7 +95,7 @@ static int do_hwclock(int argc, char *argv[])
switch (opt) {
case 'f':
- strncpy(rtc_name, optarg, 16);
+ strlcpy(rtc_name, optarg, sizeof(rtc_name));
break;
case 's':
memset(&stm, 0, sizeof(stm));
--
2.48.1
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2025-03-14 21:34 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-03-14 21:33 [PATCH] commands: hwclock: replace strncpy with strlcpy Jules Maselbas
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox