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
This commit is contained in:
parent
b9d11f2c24
commit
790252a1c5
@ -262,7 +262,7 @@ op_usm_users(struct snmp_context *ctx, struct snmp_value *val,
|
||||
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, struct snmp_value *val,
|
||||
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, struct snmp_value *val,
|
||||
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, struct snmp_value *val,
|
||||
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, struct snmp_value *val,
|
||||
free(ctx->scratch->ptr2);
|
||||
} else {
|
||||
memset(uuser->user_public, 0,
|
||||
SNMP_ADM_STR32_SIZ);
|
||||
sizeof(uuser->user_public));
|
||||
uuser->user_public_len = 0;
|
||||
}
|
||||
break;
|
||||
|
@ -7,7 +7,7 @@
|
||||
.\" All rights reserved.
|
||||
.\"
|
||||
.\" Author: Harti Brandt <harti@FreeBSD.org>
|
||||
.\"
|
||||
.\"
|
||||
.\" 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
|
||||
|
@ -823,7 +823,8 @@ parse_oid(const char *varname, struct asn_oid *oid)
|
||||
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 *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();
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -16,7 +16,6 @@ XSYM= snmpMIB begemotSnmpdModuleTable begemotSnmpd begemotTrapSinkTable \
|
||||
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}/%g' \
|
||||
-e 's%@DEFPATH@%${DEFSDIR}/%g' \
|
||||
-e 's%@MIBSPATH@%${BMIBSDIR}/%g'
|
||||
|
||||
NO_WCAST_ALIGN= yes
|
||||
WARNS?= 6
|
||||
|
||||
.include <bsd.prog.mk>
|
||||
|
Loading…
x
Reference in New Issue
Block a user