diff options
author | Harsha Sharma <harshasharmaiitr@gmail.com> | 2017-10-09 00:53:43 +0530 |
---|---|---|
committer | Florian Westphal <fw@strlen.de> | 2018-03-03 10:37:31 +0100 |
commit | f128afe52159b65712d47f17353c5f84ca837cf4 (patch) | |
tree | 6ddfd0560bc27ab82456be6854a06c2b2efc7789 /src/iface.c | |
parent | cc8c5fd02448a415473e1afc3f7155bed3940e0d (diff) |
src: Use snprintf() over strncpy()
Use snprintf() over strncpy() functions as the buffer is not null
terminated in strncpy().
Signed-off-by: Harsha Sharma <harshasharmaiitr@gmail.com>
Diffstat (limited to 'src/iface.c')
-rw-r--r-- | src/iface.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/iface.c b/src/iface.c index 9936388b..d0e1834c 100644 --- a/src/iface.c +++ b/src/iface.c @@ -53,7 +53,7 @@ static int data_cb(const struct nlmsghdr *nlh, void *data) iface = xmalloc(sizeof(struct iface)); iface->ifindex = ifm->ifi_index; mnl_attr_parse(nlh, sizeof(*ifm), data_attr_cb, tb); - strncpy(iface->name, mnl_attr_get_str(tb[IFLA_IFNAME]), IFNAMSIZ); + snprintf(iface->name, IFNAMSIZ, "%s", mnl_attr_get_str(tb[IFLA_IFNAME])); list_add(&iface->list, &iface_list); return MNL_CB_OK; @@ -139,7 +139,7 @@ char *nft_if_indextoname(unsigned int ifindex, char *name) list_for_each_entry(iface, &iface_list, list) { if (iface->ifindex == ifindex) { - strncpy(name, iface->name, IFNAMSIZ); + snprintf(name, IFNAMSIZ, "%s", iface->name); return name; } } |