summaryrefslogtreecommitdiffstats
path: root/sbin
diff options
context:
space:
mode:
authorjhb <jhb@FreeBSD.org>2015-04-09 21:06:51 +0000
committerjhb <jhb@FreeBSD.org>2015-04-09 21:06:51 +0000
commit0fbe5b3df813c02a8ba34d7696447fa1b2ed0b89 (patch)
treea90da15c29c6205813714df43a55bf2ac626ad00 /sbin
parenta251dcdd5c550663dea0a2db7ec7ce2336256e0c (diff)
downloadFreeBSD-src-0fbe5b3df813c02a8ba34d7696447fa1b2ed0b89.zip
FreeBSD-src-0fbe5b3df813c02a8ba34d7696447fa1b2ed0b89.tar.gz
MFC 279951:
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(...).
Diffstat (limited to 'sbin')
-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 6d29f20..dafb0f0 100644
--- a/sbin/ifconfig/ifconfig.c
+++ b/sbin/ifconfig/ifconfig.c
@@ -1121,9 +1121,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);
@@ -1140,8 +1139,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