From owner-svn-src-user@freebsd.org Thu Feb 4 08:42:34 2016 Return-Path: <owner-svn-src-user@freebsd.org> Delivered-To: svn-src-user@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id E25C4A9B16A for <svn-src-user@mailman.ysv.freebsd.org>; Thu, 4 Feb 2016 08:42:34 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::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 B36CD12B2; Thu, 4 Feb 2016 08:42:34 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u148gXsN000490; Thu, 4 Feb 2016 08:42:33 GMT (envelope-from ngie@FreeBSD.org) Received: (from ngie@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u148gXTV000489; Thu, 4 Feb 2016 08:42:33 GMT (envelope-from ngie@FreeBSD.org) Message-Id: <201602040842.u148gXTV000489@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ngie set sender to ngie@FreeBSD.org using -f From: Garrett Cooper <ngie@FreeBSD.org> Date: Thu, 4 Feb 2016 08:42:33 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r295242 - user/ngie/bsnmp_cleanup/usr.sbin/bsnmpd/tools/libbsnmptools X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" <svn-src-user.freebsd.org> List-Unsubscribe: <https://lists.freebsd.org/mailman/options/svn-src-user>, <mailto:svn-src-user-request@freebsd.org?subject=unsubscribe> List-Archive: <http://lists.freebsd.org/pipermail/svn-src-user/> List-Post: <mailto:svn-src-user@freebsd.org> List-Help: <mailto:svn-src-user-request@freebsd.org?subject=help> List-Subscribe: <https://lists.freebsd.org/mailman/listinfo/svn-src-user>, <mailto:svn-src-user-request@freebsd.org?subject=subscribe> X-List-Received-Date: Thu, 04 Feb 2016 08:42:35 -0000 Author: ngie Date: Thu Feb 4 08:42:33 2016 New Revision: 295242 URL: https://svnweb.freebsd.org/changeset/base/295242 Log: - Fix some broken logic committed in r295191. I should have used MIN, not MAX, when capping the buffer length with strlcpy in snmp_oid2asn_oid(..) [*]. - Make `i` in to size_t to get the types of i and sizeof in sync and fix a -Wsign-compare warning. Reported by: bde [*] Modified: user/ngie/bsnmp_cleanup/usr.sbin/bsnmpd/tools/libbsnmptools/bsnmptools.c Modified: user/ngie/bsnmp_cleanup/usr.sbin/bsnmpd/tools/libbsnmptools/bsnmptools.c ============================================================================== --- user/ngie/bsnmp_cleanup/usr.sbin/bsnmpd/tools/libbsnmptools/bsnmptools.c Thu Feb 4 08:38:13 2016 (r295241) +++ user/ngie/bsnmp_cleanup/usr.sbin/bsnmpd/tools/libbsnmptools/bsnmptools.c Thu Feb 4 08:42:33 2016 (r295242) @@ -1060,8 +1060,8 @@ static char * snmp_oid2asn_oid(struct snmp_toolinfo *snmptoolctx, char *str, struct asn_oid *oid) { - int32_t i; char string[MAXSTR], *endptr; + size_t i; struct snmp_object obj; for (i = 0; i < MAXSTR; i++) @@ -1076,7 +1076,7 @@ snmp_oid2asn_oid(struct snmp_toolinfo *s if (snmp_suboid_append(oid, (asn_subid_t) obj.val.var.len) < 0) return (NULL); } else { - strlcpy(string, str, MAX(i + 1, sizeof(string))); + strlcpy(string, str, MIN(i + 1, nitems(string))); if (snmp_lookup_enumoid(snmptoolctx, &obj, string) < 0) { warnx("Unknown string - %s",string); return (NULL);