From owner-svn-src-all@FreeBSD.ORG Thu Apr 9 21:06:52 2015 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id E9DD68F3; Thu, 9 Apr 2015 21:06:52 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id D47B3B7F; Thu, 9 Apr 2015 21:06:52 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t39L6quM029902; Thu, 9 Apr 2015 21:06:52 GMT (envelope-from jhb@FreeBSD.org) Received: (from jhb@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t39L6quP029901; Thu, 9 Apr 2015 21:06:52 GMT (envelope-from jhb@FreeBSD.org) Message-Id: <201504092106.t39L6quP029901@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: jhb set sender to jhb@FreeBSD.org using -f From: John Baldwin Date: Thu, 9 Apr 2015 21:06:52 +0000 (UTC) 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 X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 09 Apr 2015 21:06:53 -0000 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; } }