diff options
author | Phil Sutter <phil@nwl.cc> | 2017-09-01 18:52:52 +0200 |
---|---|---|
committer | Stephen Hemminger <stephen@networkplumber.org> | 2017-09-01 12:10:54 -0700 |
commit | 18f156bfecda20166c2fb543ba8c9c6559edef9c (patch) | |
tree | f5ce6f81f6f7846d2468899859b356bf14f9d06b /ip | |
parent | 8d15e012a3227d79295cd95582bb6d8a6f0bdc92 (diff) | |
download | platform_external_iproute2-18f156bfecda20166c2fb543ba8c9c6559edef9c.tar.gz platform_external_iproute2-18f156bfecda20166c2fb543ba8c9c6559edef9c.tar.bz2 platform_external_iproute2-18f156bfecda20166c2fb543ba8c9c6559edef9c.zip |
Convert the obvious cases to strlcpy()
This converts the typical idiom of manually terminating the buffer after
a call to strncpy().
Signed-off-by: Phil Sutter <phil@nwl.cc>
Diffstat (limited to 'ip')
-rw-r--r-- | ip/ipnetns.c | 3 | ||||
-rw-r--r-- | ip/iproute_lwtunnel.c | 3 | ||||
-rw-r--r-- | ip/ipvrf.c | 3 |
3 files changed, 3 insertions, 6 deletions
diff --git a/ip/ipnetns.c b/ip/ipnetns.c index 9ee1fe6a..afb4978a 100644 --- a/ip/ipnetns.c +++ b/ip/ipnetns.c @@ -518,8 +518,7 @@ int netns_identify_pid(const char *pidstr, char *name, int len) if ((st.st_dev == netst.st_dev) && (st.st_ino == netst.st_ino)) { - strncpy(name, entry->d_name, len - 1); - name[len - 1] = '\0'; + strlcpy(name, entry->d_name, len); } } closedir(dir); diff --git a/ip/iproute_lwtunnel.c b/ip/iproute_lwtunnel.c index 1a3dc4d4..4c2d3b07 100644 --- a/ip/iproute_lwtunnel.c +++ b/ip/iproute_lwtunnel.c @@ -325,8 +325,7 @@ static int parse_encap_seg6(struct rtattr *rta, size_t len, int *argcp, invarg("\"segs\" provided before \"mode\"\n", *argv); - strncpy(segbuf, *argv, 1024); - segbuf[1023] = 0; + strlcpy(segbuf, *argv, 1024); } else if (strcmp(*argv, "hmac") == 0) { NEXT_ARG(); if (hmac_ok++) @@ -336,8 +336,7 @@ static int vrf_path(char *vpath, size_t len) if (vrf) *vrf = '\0'; - strncpy(vpath, start, len - 1); - vpath[len - 1] = '\0'; + strlcpy(vpath, start, len); /* if vrf path is just / then return nothing */ if (!strcmp(vpath, "/")) |