From owner-svn-src-stable-10@freebsd.org Tue May 24 04:50:02 2016 Return-Path: Delivered-To: svn-src-stable-10@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 4C524B47AE8; Tue, 24 May 2016 04:50:02 +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 C5C421945; Tue, 24 May 2016 04:50:00 +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 u4O4nx4f029162; Tue, 24 May 2016 04:49:59 GMT (envelope-from ngie@FreeBSD.org) Received: (from ngie@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u4O4nxQQ029157; Tue, 24 May 2016 04:49:59 GMT (envelope-from ngie@FreeBSD.org) Message-Id: <201605240449.u4O4nxQQ029157@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ngie set sender to ngie@FreeBSD.org using -f From: Garrett Cooper Date: Tue, 24 May 2016 04:49:59 +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: r300561 - in stable/10: contrib/bsnmp/snmp_usm contrib/bsnmp/snmpd usr.sbin/bsnmpd/bsnmpd X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 May 2016 04:50:02 -0000 Author: ngie Date: Tue May 24 04:49:58 2016 New Revision: 300561 URL: https://svnweb.freebsd.org/changeset/base/300561 Log: MFC r299465,r299807,r299808,r299817,r299831,r299832,r300167: r299465 (by cem): bsnmp: Don't overrun privkey buffer by copying wrong size The 'priv_key' array is SNMP_PRIV_KEY_SIZ bytes, not SNMP_AUTH_KEY_SIZ. CIDs: 1008326, 1009675 r299807: Replace QUADFMT with %ju and QUADXFMT with %jx and cast values with uintmax_t This will cure some -Wformat warnings r299808: Use sizeof(..)s for the destination buffers instead of hardcoded values corresponding to the destination buffer sizes r299817: Use SNMPD_INPUT_FAILED instead of SNMP_CODE_FAILED SNMPD_INPUT_FAILED is `enum snmpd_input_err` type (which matches the return code from the function). SNMP_CODE_FAILED is `enum snmp_code` type. r299831: Remove NO_WERROR and add WARNS?= 6 This now compiles cleanly on all architectures Tested with: clang 3.8, gcc 4.2.1, gcc 4.5, make tinderbox r299832: Remove trailing whitespace in license tort r300167 (by glebius): Revert r299830, it has couple of fatal errors. The CMSG_ family of macros take care of alignment, so we don't need r299830 at all, even if it was correct. Put NO_WCAST_ALIGN into Makefile. Together with: peter Modified: stable/10/contrib/bsnmp/snmp_usm/usm_snmp.c stable/10/contrib/bsnmp/snmpd/bsnmpd.1 stable/10/contrib/bsnmp/snmpd/config.c stable/10/contrib/bsnmp/snmpd/main.c stable/10/usr.sbin/bsnmpd/bsnmpd/Makefile Directory Properties: stable/10/ (props changed) Modified: stable/10/contrib/bsnmp/snmp_usm/usm_snmp.c ============================================================================== --- stable/10/contrib/bsnmp/snmp_usm/usm_snmp.c Tue May 24 04:34:45 2016 (r300560) +++ stable/10/contrib/bsnmp/snmp_usm/usm_snmp.c Tue May 24 04:49:58 2016 (r300561) @@ -262,7 +262,7 @@ op_usm_users(struct snmp_context *ctx, s if (ctx->scratch->ptr1 == NULL) return (SNMP_ERR_GENERR); memcpy(ctx->scratch->ptr1, uuser->suser.priv_key, - SNMP_PRIV_KEY_SIZ); + sizeof(uuser->suser.priv_key)); memcpy(uuser->suser.priv_key, val->v.octetstring.octets, val->v.octetstring.len); break; @@ -286,7 +286,7 @@ op_usm_users(struct snmp_context *ctx, s uuser->user_public_len = val->v.octetstring.len; } else { memset(uuser->user_public, 0, - SNMP_ADM_STR32_SIZ); + sizeof(uuser->user_public)); uuser->user_public_len = 0; } break; @@ -351,7 +351,7 @@ op_usm_users(struct snmp_context *ctx, s case LEAF_usmUserAuthKeyChange: case LEAF_usmUserOwnAuthKeyChange: memcpy(uuser->suser.auth_key, ctx->scratch->ptr1, - SNMP_AUTH_KEY_SIZ); + sizeof(uuser->suser.auth_key)); free(ctx->scratch->ptr1); break; case LEAF_usmUserPrivProtocol: @@ -360,7 +360,7 @@ op_usm_users(struct snmp_context *ctx, s case LEAF_usmUserPrivKeyChange: case LEAF_usmUserOwnPrivKeyChange: memcpy(uuser->suser.priv_key, ctx->scratch->ptr1, - SNMP_AUTH_KEY_SIZ); + sizeof(uuser->suser.priv_key)); free(ctx->scratch->ptr1); break; case LEAF_usmUserPublic: @@ -371,7 +371,7 @@ op_usm_users(struct snmp_context *ctx, s free(ctx->scratch->ptr2); } else { memset(uuser->user_public, 0, - SNMP_ADM_STR32_SIZ); + sizeof(uuser->user_public)); uuser->user_public_len = 0; } break; Modified: stable/10/contrib/bsnmp/snmpd/bsnmpd.1 ============================================================================== --- stable/10/contrib/bsnmp/snmpd/bsnmpd.1 Tue May 24 04:34:45 2016 (r300560) +++ stable/10/contrib/bsnmp/snmpd/bsnmpd.1 Tue May 24 04:49:58 2016 (r300561) @@ -7,7 +7,7 @@ .\" All rights reserved. .\" .\" Author: Harti Brandt -.\" +.\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: @@ -16,7 +16,7 @@ .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. -.\" +.\" .\" THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE Modified: stable/10/contrib/bsnmp/snmpd/config.c ============================================================================== --- stable/10/contrib/bsnmp/snmpd/config.c Tue May 24 04:34:45 2016 (r300560) +++ stable/10/contrib/bsnmp/snmpd/config.c Tue May 24 04:49:58 2016 (r300561) @@ -823,7 +823,8 @@ parse_oid(const char *varname, struct as while (token == '.') { if (gettoken() == TOK_NUM) { if (numval > ASN_MAXID) - report("subid too large %#"QUADXFMT, numval); + report("subid too large %#jx", + (uintmax_t)numval); if (oid->len == ASN_MAXOIDLEN) report("index too long"); if (gettoken() != ':') @@ -878,7 +879,7 @@ parse_syntax_integer(struct snmp_value * if (token != TOK_NUM) report("bad INTEGER syntax"); if (numval > 0x7fffffff) - report("INTEGER too large %"QUADFMT, numval); + report("INTEGER too large %ju", (uintmax_t)numval); value->v.integer = numval; gettoken(); Modified: stable/10/contrib/bsnmp/snmpd/main.c ============================================================================== --- stable/10/contrib/bsnmp/snmpd/main.c Tue May 24 04:34:45 2016 (r300560) +++ stable/10/contrib/bsnmp/snmpd/main.c Tue May 24 04:49:58 2016 (r300561) @@ -648,11 +648,11 @@ decoded: } else if (usm_user->suser.auth_proto != SNMP_AUTH_NOAUTH && (pdu->engine.engine_boots == 0 || pdu->engine.engine_time == 0)) { snmpd_usmstats.not_in_time_windows++; - ret = SNMP_CODE_FAILED; + ret = SNMPD_INPUT_FAILED; } if ((code = snmp_pdu_auth_access(pdu, ip)) != SNMP_CODE_OK) - ret = SNMP_CODE_FAILED; + ret = SNMPD_INPUT_FAILED; return (ret); } Modified: stable/10/usr.sbin/bsnmpd/bsnmpd/Makefile ============================================================================== --- stable/10/usr.sbin/bsnmpd/bsnmpd/Makefile Tue May 24 04:34:45 2016 (r300560) +++ stable/10/usr.sbin/bsnmpd/bsnmpd/Makefile Tue May 24 04:49:58 2016 (r300561) @@ -16,7 +16,6 @@ XSYM= snmpMIB begemotSnmpdModuleTable be freeBSD freeBSDVersion CLEANFILES= oid.h tree.c tree.h MAN= bsnmpd.1 snmpmod.3 -NO_WERROR= FILESGROUPS= BMIBS DEFS @@ -27,7 +26,7 @@ DEFSDIR= ${SHAREDIR}/snmp/defs CFLAGS+= -DSNMPTREE_TYPES CFLAGS+= -I${CONTRIB}/lib -I${CONTRIB}/snmpd -I. -DUSE_LIBBEGEMOT -CFLAGS+= -DUSE_TCPWRAPPERS -DQUADFMT='"llu"' -DQUADXFMT='"llx"' +CFLAGS+= -DUSE_TCPWRAPPERS CFLAGS+= -DHAVE_STDINT_H -DHAVE_INTTYPES_H -DHAVE_ERR_H -DHAVE_STRLCPY DPADD= ${LIBBEGEMOT} ${LIBBSNMP} ${LIBWRAP} LDADD= -lbegemot -lbsnmp -lwrap @@ -49,4 +48,7 @@ MANFILTER= sed -e 's%@MODPATH@%${LIBDIR} -e 's%@DEFPATH@%${DEFSDIR}/%g' \ -e 's%@MIBSPATH@%${BMIBSDIR}/%g' +NO_WCAST_ALIGN= yes +WARNS?= 6 + .include