mirror of
https://github.com/FRRouting/frr.git
synced 2025-04-30 13:37:17 +02:00
Merge pull request #17156 from opensourcerouting/eradicate-strncpy
*: remove remaining `strncpy()` users
This commit is contained in:
commit
172a2aa533
|
@ -573,7 +573,7 @@ void csv_decode(csv_t *csv, char *inbuf)
|
|||
log_error("field str malloc failed\n");
|
||||
return;
|
||||
}
|
||||
strncpy(rec->record, buf, pos - buf + 1);
|
||||
memcpy(rec->record, buf, MIN(pos - buf + 1, csv->buflen - 1));
|
||||
}
|
||||
rec->rec_len = pos - buf + 1;
|
||||
/* decode record into fields */
|
||||
|
|
|
@ -3,9 +3,7 @@
|
|||
* Copyright (C) 2015 Cumulus Networks, Inc.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
#include <zebra.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
@ -450,7 +448,7 @@ ptm_lib_handle_t *ptm_lib_register(char *client_name, ptm_cmd_cb cmd_cb,
|
|||
hdl = calloc(1, sizeof(*hdl));
|
||||
|
||||
if (hdl) {
|
||||
strncpy(hdl->client_name, client_name, PTMLIB_MAXNAMELEN - 1);
|
||||
strlcpy(hdl->client_name, client_name, sizeof(hdl->client_name));
|
||||
hdl->cmd_cb = cmd_cb;
|
||||
hdl->notify_cb = notify_cb;
|
||||
hdl->response_cb = response_cb;
|
||||
|
|
|
@ -49,16 +49,17 @@ const char *prng_fuzz(struct prng *prng, const char *string,
|
|||
const char *charset, unsigned int operations)
|
||||
{
|
||||
static char buf[256];
|
||||
unsigned int charset_len;
|
||||
size_t charset_len = strlen(charset);
|
||||
size_t str_len = strlen(string);
|
||||
unsigned int i;
|
||||
unsigned int offset;
|
||||
unsigned int op;
|
||||
unsigned int character;
|
||||
|
||||
assert(strlen(string) < sizeof(buf));
|
||||
assert(str_len < sizeof(buf));
|
||||
|
||||
strncpy(buf, string, sizeof(buf));
|
||||
charset_len = strlen(charset);
|
||||
memset(buf, 0, sizeof(buf));
|
||||
memcpy(buf, string, str_len);
|
||||
|
||||
for (i = 0; i < operations; i++) {
|
||||
offset = prng_rand(prng) % strlen(buf);
|
||||
|
|
|
@ -43,7 +43,7 @@ static char *sortlines(char *in)
|
|||
}
|
||||
|
||||
if (line_count == 1) {
|
||||
strncpy(rv, in, rv_len);
|
||||
memcpy(rv, in, rv_len);
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue