1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-14 10:09:48 +00:00

Initialize ret to SNMPD_INPUT_OK at the top of snmp_input_start(..) to

avoid returning an uninitialized value

There are some really complicated, snakey if-statements combined with
switch statements that could result in an invalid value being returned
as `ret`

MFC after:	1 week
Reported by:	Coverity
CID:		1006551
This commit is contained in:
Enji Cooper 2016-12-31 12:30:14 +00:00
parent 8e02b381d3
commit 39ebb4e1e0
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=310958

View File

@ -492,6 +492,8 @@ snmp_input_start(const u_char *buf, size_t len, const char *source,
b.asn_cptr = buf;
b.asn_len = len;
ret = SNMPD_INPUT_OK;
/* look whether we have enough bytes for the entire PDU. */
switch (sret = snmp_pdu_snoop(&b)) {
@ -520,8 +522,6 @@ snmp_input_start(const u_char *buf, size_t len, const char *source,
}
code = snmp_pdu_decode_scoped(&b, pdu, ip);
ret = SNMPD_INPUT_OK;
decoded:
snmpd_stats.inPkts++;