summaryrefslogtreecommitdiffstats
path: root/sbin/ifconfig
diff options
context:
space:
mode:
authorjhb <jhb@FreeBSD.org>2015-03-13 09:45:06 +0000
committerjhb <jhb@FreeBSD.org>2015-03-13 09:45:06 +0000
commitdfbeeb5833dea1dff822ac815e689445b17d0553 (patch)
tree976fa112d5aa62dce9229048198bdce65eb6ab9c /sbin/ifconfig
parenta61394dda9985c2ff2697ab318133299f73def3a (diff)
downloadFreeBSD-src-dfbeeb5833dea1dff822ac815e689445b17d0553.zip
FreeBSD-src-dfbeeb5833dea1dff822ac815e689445b17d0553.tar.gz
Simplify string mangling in ifmaybeload().
- Use strlcpy() instead of strcpy(). - Use strlcat() instead of a strlcpy() with a magic number subtracted from the length. - Replace strncmp(..., strlen(foo) + 1) with strcmp(...). Differential Revision: https://reviews.freebsd.org/D1814 Reviewed by: rpaulo MFC after: 2 weeks
Diffstat (limited to 'sbin/ifconfig')
-rw-r--r--sbin/ifconfig/ifconfig.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/sbin/ifconfig/ifconfig.c b/sbin/ifconfig/ifconfig.c
index 5a805a7..9d38a27 100644
--- a/sbin/ifconfig/ifconfig.c
+++ b/sbin/ifconfig/ifconfig.c
@@ -1280,9 +1280,8 @@ ifmaybeload(const char *name)
}
/* turn interface and unit into module name */
- strcpy(ifkind, "if_");
- strlcpy(ifkind + MOD_PREFIX_LEN, ifname,
- sizeof(ifkind) - MOD_PREFIX_LEN);
+ strlcpy(ifkind, "if_", sizeof(ifkind));
+ strlcat(ifkind, ifname, sizeof(ifkind));
/* scan files in kernel */
mstat.version = sizeof(struct module_stat);
@@ -1299,8 +1298,8 @@ ifmaybeload(const char *name)
cp = mstat.name;
}
/* already loaded? */
- if (strncmp(ifname, cp, strlen(ifname) + 1) == 0 ||
- strncmp(ifkind, cp, strlen(ifkind) + 1) == 0)
+ if (strcmp(ifname, cp) == 0 ||
+ strcmp(ifkind, cp) == 0)
return;
}
}
OpenPOWER on IntegriCloud