From fcb072cdbfa87ffff0a5c94c29217a3235bbe8f3 Mon Sep 17 00:00:00 2001 From: Quentin Young Date: Wed, 8 May 2019 18:33:53 +0000 Subject: [PATCH] lib, zebra: remove uses of strncpy This removes the last removable uses of strncpy in FRR. Signed-off-by: Quentin Young --- lib/command_match.c | 4 ++-- lib/vty.c | 2 +- zebra/ioctl.c | 4 ++-- zebra/ioctl_solaris.c | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/command_match.c b/lib/command_match.c index 8b34d1e3eb..9456e1585a 100644 --- a/lib/command_match.c +++ b/lib/command_match.c @@ -723,7 +723,7 @@ static enum match_type match_ipv4(const char *str) if (str - sp > 3) return no_match; - strncpy(buf, sp, str - sp); + memcpy(buf, sp, str - sp); if (atoi(buf) > 255) return no_match; @@ -774,7 +774,7 @@ static enum match_type match_ipv4_prefix(const char *str) if (str - sp > 3) return no_match; - strncpy(buf, sp, str - sp); + memcpy(buf, sp, str - sp); if (atoi(buf) > 255) return no_match; diff --git a/lib/vty.c b/lib/vty.c index 91ba0a43c8..9bee7b6c83 100644 --- a/lib/vty.c +++ b/lib/vty.c @@ -998,7 +998,7 @@ static void vty_describe_fold(struct vty *vty, int cmd_width, if (pos == 0) break; - strncpy(buf, p, pos); + memcpy(buf, p, pos); buf[pos] = '\0'; vty_out(vty, " %-*s %s\n", cmd_width, cmd, buf); diff --git a/zebra/ioctl.c b/zebra/ioctl.c index 322527015b..8202e076af 100644 --- a/zebra/ioctl.c +++ b/zebra/ioctl.c @@ -245,7 +245,7 @@ static int if_set_prefix_ctx(const struct zebra_dplane_ctx *ctx) p = (struct prefix_ipv4 *)dplane_ctx_get_intf_addr(ctx); memset(&addreq, 0, sizeof(addreq)); - strncpy((char *)&addreq.ifra_name, dplane_ctx_get_ifname(ctx), + strlcpy((char *)&addreq.ifra_name, dplane_ctx_get_ifname(ctx), sizeof(addreq.ifra_name)); memset(&addr, 0, sizeof(struct sockaddr_in)); @@ -296,7 +296,7 @@ static int if_unset_prefix_ctx(const struct zebra_dplane_ctx *ctx) p = (struct prefix_ipv4 *)dplane_ctx_get_intf_addr(ctx); memset(&addreq, 0, sizeof(addreq)); - strncpy((char *)&addreq.ifra_name, dplane_ctx_get_ifname(ctx), + strlcpy((char *)&addreq.ifra_name, dplane_ctx_get_ifname(ctx), sizeof(addreq.ifra_name)); memset(&addr, 0, sizeof(struct sockaddr_in)); diff --git a/zebra/ioctl_solaris.c b/zebra/ioctl_solaris.c index ccfa7a4a4c..1f96fa23ea 100644 --- a/zebra/ioctl_solaris.c +++ b/zebra/ioctl_solaris.c @@ -286,7 +286,7 @@ static int if_unset_prefix_ctx(const struct zebra_dplane_ctx *ctx) p = (struct prefix_ipv4 *)dplane_ctx_get_intf_addr(ctx); - strncpy(ifreq.ifr_name, dplane_ctx_get_ifname(ctx), + strlcpy(ifreq.ifr_name, dplane_ctx_get_ifname(ctx), sizeof(ifreq.ifr_name)); memset(&addr, 0, sizeof(struct sockaddr_in)); -- 2.39.5