]> git.puffer.fish Git - matthieu/frr.git/commitdiff
lib: strncpy -> strlcpy | memcpy
authorQuentin Young <qlyoung@cumulusnetworks.com>
Tue, 26 Feb 2019 20:25:24 +0000 (20:25 +0000)
committerQuentin Young <qlyoung@cumulusnetworks.com>
Tue, 26 Feb 2019 20:50:17 +0000 (20:50 +0000)
strncpy is a byte copy function not a string copy function

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
lib/event_counter.c
lib/prefix.c
lib/yang_translator.c

index c520937a3827a4d94e3e356d88d9e570f53da461..57dbfb5fd1839a686aa980610f34985020bc131d 100644 (file)
@@ -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,
index babd4304d13f29a47ef9e6778266be63b328ea66..80a89cc3c707bb86a66d95bf3acf1e2e0b738f68 100644 (file)
@@ -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);
index 6d6f92836fbf247167cfe1c86e204355ff934d25..76a6cc5fd1954d40b54683c436cb88c0fa783c38 100644 (file)
@@ -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,