Date: Thu, 9 Apr 2015 21:06:52 +0000 (UTC) From: John Baldwin <jhb@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r281326 - in stable: 10/sbin/ifconfig 9/sbin/ifconfig Message-ID: <201504092106.t39L6quP029901@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: jhb Date: Thu Apr 9 21:06:51 2015 New Revision: 281326 URL: https://svnweb.freebsd.org/changeset/base/281326 Log: 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(...). Modified: stable/10/sbin/ifconfig/ifconfig.c Directory Properties: stable/10/ (props changed) Changes in other areas also in this revision: Modified: stable/9/sbin/ifconfig/ifconfig.c Directory Properties: stable/9/sbin/ifconfig/ (props changed) Modified: stable/10/sbin/ifconfig/ifconfig.c ============================================================================== --- stable/10/sbin/ifconfig/ifconfig.c Thu Apr 9 21:05:48 2015 (r281325) +++ stable/10/sbin/ifconfig/ifconfig.c Thu Apr 9 21:06:51 2015 (r281326) @@ -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; } }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201504092106.t39L6quP029901>