diff options
author | David Lamparter <equinox@opensourcerouting.org> | 2024-10-17 14:36:07 +0200 |
---|---|---|
committer | David Lamparter <equinox@opensourcerouting.org> | 2024-10-22 14:53:52 +0200 |
commit | cf4fc9c48457746f0ef34773f6c9aa0dcebef6dd (patch) | |
tree | 0f9ef54b09be6dbe00485af425af305a6df1bc7e /tools | |
parent | lib: remove `strncpy()` use (diff) | |
download | frr-cf4fc9c48457746f0ef34773f6c9aa0dcebef6dd.tar.xz frr-cf4fc9c48457746f0ef34773f6c9aa0dcebef6dd.zip |
tools: remove `strncpy()` use
`checkpatch` has sufficiently annoyed me to fix this.
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/start-stop-daemon.c | 9 | ||||
-rw-r--r-- | tools/subdir.am | 2 |
2 files changed, 8 insertions, 3 deletions
diff --git a/tools/start-stop-daemon.c b/tools/start-stop-daemon.c index 9f566bd1e..4406a68f6 100644 --- a/tools/start-stop-daemon.c +++ b/tools/start-stop-daemon.c @@ -66,6 +66,12 @@ #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) diff --git a/tools/subdir.am b/tools/subdir.am index f2ed2332b..d88e4946b 100644 --- a/tools/subdir.am +++ b/tools/subdir.am @@ -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 |