summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorQuentin Young <qlyoung@cumulusnetworks.com>2019-02-26 21:25:24 +0100
committerQuentin Young <qlyoung@cumulusnetworks.com>2019-02-26 21:50:17 +0100
commitaab9a0a0cb3f75d37bd81588c65d4232def1c8d5 (patch)
tree5c3aca66bfb33b337453770ba77c4357cd97c868 /lib
parentripd: strncpy -> strlcpy (diff)
downloadfrr-aab9a0a0cb3f75d37bd81588c65d4232def1c8d5.tar.xz
frr-aab9a0a0cb3f75d37bd81588c65d4232def1c8d5.zip
lib: strncpy -> strlcpy | memcpy
strncpy is a byte copy function not a string copy function Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/event_counter.c2
-rw-r--r--lib/prefix.c6
-rw-r--r--lib/yang_translator.c2
3 files changed, 5 insertions, 5 deletions
diff --git a/lib/event_counter.c b/lib/event_counter.c
index c520937a3..57dbfb5fd 100644
--- a/lib/event_counter.c
+++ b/lib/event_counter.c
@@ -62,7 +62,7 @@ const char *event_counter_format(const struct event_counter *counter)
|| strftime(timebuf, sizeof(timebuf), "%a, %d %b %Y %T %z",
last_change)
== 0) {
- strncpy(timebuf, "???", sizeof(timebuf));
+ strlcpy(timebuf, "???", sizeof(timebuf));
}
snprintf(rv, sizeof(rv), "%5llu last: %s", counter->count,
diff --git a/lib/prefix.c b/lib/prefix.c
index babd4304d..80a89cc3c 100644
--- a/lib/prefix.c
+++ b/lib/prefix.c
@@ -866,7 +866,7 @@ int str2prefix_ipv4(const char *str, struct prefix_ipv4 *p)
return ret;
} else {
cp = XMALLOC(MTYPE_TMP, (pnt - str) + 1);
- strncpy(cp, str, pnt - str);
+ memcpy(cp, str, pnt - str);
*(cp + (pnt - str)) = '\0';
ret = inet_aton(cp, &p->prefix);
XFREE(MTYPE_TMP, cp);
@@ -913,7 +913,7 @@ int str2prefix_eth(const char *str, struct prefix_eth *p)
}
cp = XMALLOC(MTYPE_TMP, (pnt - str) + 1);
- strncpy(cp, str, pnt - str);
+ memcpy(cp, str, pnt - str);
*(cp + (pnt - str)) = '\0';
str_addr = cp;
@@ -1030,7 +1030,7 @@ int str2prefix_ipv6(const char *str, struct prefix_ipv6 *p)
int plen;
cp = XMALLOC(MTYPE_TMP, (pnt - str) + 1);
- strncpy(cp, str, pnt - str);
+ memcpy(cp, str, pnt - str);
*(cp + (pnt - str)) = '\0';
ret = inet_pton(AF_INET6, cp, &p->prefix);
XFREE(MTYPE_TMP, cp);
diff --git a/lib/yang_translator.c b/lib/yang_translator.c
index 6d6f92836..76a6cc5fd 100644
--- a/lib/yang_translator.c
+++ b/lib/yang_translator.c
@@ -511,7 +511,7 @@ static void str_replace(char *o_string, const char *s_string,
if (!ch)
return;
- strncpy(buffer, o_string, ch - o_string);
+ memcpy(buffer, o_string, ch - o_string);
buffer[ch - o_string] = 0;
sprintf(buffer + (ch - o_string), "%s%s", r_string,