From owner-svn-src-user@freebsd.org Wed Feb 3 02:06:49 2016 Return-Path: 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 73572A9A236 for ; Wed, 3 Feb 2016 02:06:49 +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 4736C113B; Wed, 3 Feb 2016 02:06:49 +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 u1326mRU054985; Wed, 3 Feb 2016 02:06:48 GMT (envelope-from ngie@FreeBSD.org) Received: (from ngie@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u1326mcP054984; Wed, 3 Feb 2016 02:06:48 GMT (envelope-from ngie@FreeBSD.org) Message-Id: <201602030206.u1326mcP054984@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ngie set sender to ngie@FreeBSD.org using -f From: Garrett Cooper Date: Wed, 3 Feb 2016 02:06:48 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r295191 - 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" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 03 Feb 2016 02:06:49 -0000 Author: ngie Date: Wed Feb 3 02:06:48 2016 New Revision: 295191 URL: https://svnweb.freebsd.org/changeset/base/295191 Log: 1. Use destination buffer instead of source buffer size to mute valid security concerns with strlcpy related to their respective buffer sizes (-Wstrlcpy-strlcat-size) 2. Don't try free'ing string in snmp_oid2asn_oid(..) -- it's allocated on the stack in the function, not the heap. Reported by: Jenkins (clang job) [1], Jenkins (gcc 4.9 job) [2] Sponsored by: EMC / Isilon Storage Division 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 Wed Feb 3 02:03:00 2016 (r295190) +++ user/ngie/bsnmp_cleanup/usr.sbin/bsnmpd/tools/libbsnmptools/bsnmptools.c Wed Feb 3 02:06:48 2016 (r295191) @@ -266,7 +266,7 @@ add_filename(struct snmp_toolinfo *snmpt if (cut != NULL) asn_append_oid(&(entry->cut), cut); - strlcpy(fstring, filename, strlen(filename) + 1); + strlcpy(fstring, filename, sizeof(fstring)); entry->name = fstring; entry->done = done; SLIST_INSERT_HEAD(&snmptoolctx->filelist, entry, link); @@ -1076,13 +1076,11 @@ 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, i + 1); - string[i] = '\0'; + strlcpy(string, str, MAX(i + 1, sizeof(string))); if (snmp_lookup_enumoid(snmptoolctx, &obj, string) < 0) { warnx("Unknown string - %s",string); return (NULL); } - free(string); } asn_append_oid(oid, &(obj.val.var));