diff options
author | John Baldwin <jhb@FreeBSD.org> | 2015-03-13 09:45:06 +0000 |
---|---|---|
committer | John Baldwin <jhb@FreeBSD.org> | 2015-03-13 09:45:06 +0000 |
commit | 07bf9879f3b921d6c692ae61440fc6a1d64b1baa (patch) | |
tree | 976fa112d5aa62dce9229048198bdce65eb6ab9c /sbin/ifconfig/ifconfig.c | |
parent | 02cbfd02baddb29c4ec40c9fbf2fad272bd2f195 (diff) | |
download | src-07bf9879f3b921d6c692ae61440fc6a1d64b1baa.tar.gz src-07bf9879f3b921d6c692ae61440fc6a1d64b1baa.zip |
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
Notes
Notes:
svn path=/head/; revision=279951
Diffstat (limited to 'sbin/ifconfig/ifconfig.c')
-rw-r--r-- | sbin/ifconfig/ifconfig.c | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/sbin/ifconfig/ifconfig.c b/sbin/ifconfig/ifconfig.c index 5a805a7e60fd..9d38a27f5ec0 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; } } |