]> git.puffer.fish Git - mirror/frr.git/commitdiff
tools: remove `strncpy()` use 17156/head
authorDavid Lamparter <equinox@opensourcerouting.org>
Thu, 17 Oct 2024 12:36:07 +0000 (14:36 +0200)
committerDavid Lamparter <equinox@opensourcerouting.org>
Tue, 22 Oct 2024 12:53:52 +0000 (14:53 +0200)
`checkpatch` has sufficiently annoyed me to fix this.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
tools/start-stop-daemon.c
tools/subdir.am

index 9f566bd1e24fecf8e9ec7d721ed427284da67227..4406a68f61960004b7fb2577300d172b4e94f157 100644 (file)
 #include <linux/sched.h>
 #endif
 
+/* this is in zebra.h, but including that here isn't a good fit... */
+#ifndef HAVE_STRLCPY
+size_t strlcpy(char *__restrict dest,
+              const char *__restrict src, size_t destsize);
+#endif
+
 static int testmode = 0;
 static int quietmode = 0;
 static int exitnodo = 1;
@@ -749,8 +755,7 @@ static void do_stop(int signal_nr, int quietmode, int *n_killed,
 
 static void set_what_stop(const char *str)
 {
-       strncpy(what_stop, str, sizeof(what_stop));
-       what_stop[sizeof(what_stop) - 1] = '\0';
+       strlcpy(what_stop, str, sizeof(what_stop));
 }
 
 static int run_stop_schedule(void)
index f2ed2332b8bd27930ee21513cba1442b1edaf516..d88e4946b48139ce12fae3cc915ee91ca0d1c9a2 100644 (file)
@@ -39,7 +39,7 @@ tools_gen_northbound_callbacks_LDADD = lib/libfrr.la $(LIBYANG_LIBS)
 tools_gen_yang_deviations_SOURCES = tools/gen_yang_deviations.c
 tools_gen_yang_deviations_LDADD = lib/libfrr.la $(LIBYANG_LIBS)
 
-tools_ssd_SOURCES = tools/start-stop-daemon.c
+tools_ssd_SOURCES = tools/start-stop-daemon.c lib/strlcpy.c
 tools_ssd_CPPFLAGS =
 
 # don't bother autoconf'ing these for a simple optional tool