From owner-svn-src-stable-9@freebsd.org Wed Jun 8 17:50:53 2016 Return-Path: Delivered-To: svn-src-stable-9@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 4B522B6FC10; Wed, 8 Jun 2016 17:50:53 +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 2369D1BC2; Wed, 8 Jun 2016 17:50:53 +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 u58Hoqau037415; Wed, 8 Jun 2016 17:50:52 GMT (envelope-from ngie@FreeBSD.org) Received: (from ngie@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u58HopMR037411; Wed, 8 Jun 2016 17:50:51 GMT (envelope-from ngie@FreeBSD.org) Message-Id: <201606081750.u58HopMR037411@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ngie set sender to ngie@FreeBSD.org using -f From: Garrett Cooper Date: Wed, 8 Jun 2016 17:50:51 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r301664 - in stable/9/contrib/bsnmp: snmp_mibII snmpd X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 08 Jun 2016 17:50:53 -0000 Author: ngie Date: Wed Jun 8 17:50:51 2016 New Revision: 301664 URL: https://svnweb.freebsd.org/changeset/base/301664 Log: MFstable/10 r301663: MFC r294507,r294567,r299466: r294507 (by harti): Fill the ifAlias leaf of the ifXTable with the interface description if there is one available and it fits into the maximum size (64 characters). r294567 (by bz): Change the variable to a #define in order to make gcc happy which otherwise will complain about "variably modified 'alias' at file scope". Unbreaks the build on gcc platforms. r299466 (by cem): bsnmpd: Fix size of trapsink::comm to match other community arrays This fixes a number of possible strcpy() buffer overruns between the various community strings in trap.c. CIDs: 1006820, 1006821, 1006822 Modified: stable/9/contrib/bsnmp/snmp_mibII/mibII.c stable/9/contrib/bsnmp/snmp_mibII/mibII.h stable/9/contrib/bsnmp/snmp_mibII/mibII_interfaces.c stable/9/contrib/bsnmp/snmpd/snmpd.h Directory Properties: stable/9/ (props changed) stable/9/contrib/ (props changed) stable/9/contrib/bsnmp/ (props changed) stable/9/contrib/bsnmp/snmp_mibII/ (props changed) Modified: stable/9/contrib/bsnmp/snmp_mibII/mibII.c ============================================================================== --- stable/9/contrib/bsnmp/snmp_mibII/mibII.c Wed Jun 8 17:49:03 2016 (r301663) +++ stable/9/contrib/bsnmp/snmp_mibII/mibII.c Wed Jun 8 17:50:51 2016 (r301664) @@ -443,6 +443,7 @@ mib_fetch_ifmib(struct mibif *ifp) size_t len; void *newmib; struct ifmibdata oldmib = ifp->mib; + struct ifreq irr; if (fetch_generic_mib(ifp, &oldmib) == -1) return (-1); @@ -514,6 +515,18 @@ mib_fetch_ifmib(struct mibif *ifp) } out: + strncpy(irr.ifr_name, ifp->name, sizeof(irr.ifr_name)); + irr.ifr_buffer.buffer = MIBIF_PRIV(ifp)->alias; + irr.ifr_buffer.length = sizeof(MIBIF_PRIV(ifp)->alias); + if (ioctl(mib_netsock, SIOCGIFDESCR, &irr) == -1) { + MIBIF_PRIV(ifp)->alias[0] = 0; + if (errno != ENOMSG) + syslog(LOG_WARNING, "SIOCGIFDESCR (%s): %m", ifp->name); + } else if (irr.ifr_buffer.buffer == NULL) { + MIBIF_PRIV(ifp)->alias[0] = 0; + syslog(LOG_WARNING, "SIOCGIFDESCR (%s): too long (%zu)", + ifp->name, irr.ifr_buffer.length); + } ifp->mibtick = get_ticks(); return (0); } Modified: stable/9/contrib/bsnmp/snmp_mibII/mibII.h ============================================================================== --- stable/9/contrib/bsnmp/snmp_mibII/mibII.h Wed Jun 8 17:49:03 2016 (r301663) +++ stable/9/contrib/bsnmp/snmp_mibII/mibII.h Wed Jun 8 17:50:51 2016 (r301664) @@ -56,6 +56,9 @@ #include "snmp_mibII.h" #include "mibII_tree.h" +/* maximum size of the interface alias */ +#define MIBIF_ALIAS_SIZE (64 + 1) + /* * Interface list and flags. */ @@ -76,6 +79,9 @@ struct mibif_private { uint64_t hc_opackets; uint64_t hc_imcasts; uint64_t hc_ipackets; + + /* this should be made public */ + char alias[MIBIF_ALIAS_SIZE]; }; #define MIBIF_PRIV(IFP) ((struct mibif_private *)((IFP)->private)) Modified: stable/9/contrib/bsnmp/snmp_mibII/mibII_interfaces.c ============================================================================== --- stable/9/contrib/bsnmp/snmp_mibII/mibII_interfaces.c Wed Jun 8 17:49:03 2016 (r301663) +++ stable/9/contrib/bsnmp/snmp_mibII/mibII_interfaces.c Wed Jun 8 17:50:51 2016 (r301664) @@ -528,7 +528,7 @@ op_ifxtable(struct snmp_context *ctx, st break; case LEAF_ifAlias: - ret = string_get(value, "", -1); + ret = string_get(value, MIBIF_PRIV(ifp)->alias, -1); break; case LEAF_ifCounterDiscontinuityTime: Modified: stable/9/contrib/bsnmp/snmpd/snmpd.h ============================================================================== --- stable/9/contrib/bsnmp/snmpd/snmpd.h Wed Jun 8 17:49:03 2016 (r301663) +++ stable/9/contrib/bsnmp/snmpd/snmpd.h Wed Jun 8 17:50:51 2016 (r301664) @@ -307,7 +307,7 @@ struct trapsink { struct asn_oid index; u_int status; int socket; - u_char comm[SNMP_COMMUNITY_MAXLEN]; + u_char comm[SNMP_COMMUNITY_MAXLEN + 1]; int version; }; enum {