From: Amos Jeffries Date: Mon, 14 Jan 2013 10:00:45 +0000 (-0700) Subject: Polish NULL detection in SNMP X-Git-Tag: SQUID_3_4_0_1~377 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=86c9eeb3992f5066c4b8e2e871e84a5c74bbf6e3;p=thirdparty%2Fsquid.git Polish NULL detection in SNMP * Several places were ignoring the possibility that pointers may be NULL Detected by Coverity Scan. Issues 434107, 740455 --- diff --git a/src/snmp_core.cc b/src/snmp_core.cc index 7ac54ddd37..d705de90f2 100644 --- a/src/snmp_core.cc +++ b/src/snmp_core.cc @@ -617,7 +617,6 @@ static oid_ParseFn * snmpTreeNext(oid * Current, snint CurrentLen, oid ** Next, snint * NextLen) { oid_ParseFn *Fn = NULL; - mib_tree_entry *mibTreeEntry = NULL, *nextoid = NULL; int count = 0; debugs(49, 5, "snmpTreeNext: Called"); @@ -625,9 +624,9 @@ snmpTreeNext(oid * Current, snint CurrentLen, oid ** Next, snint * NextLen) MemBuf tmp; debugs(49, 6, "snmpTreeNext: Current : " << snmpDebugOid(Current, CurrentLen, tmp)); - mibTreeEntry = mib_tree_head; + mib_tree_entry *mibTreeEntry = mib_tree_head; - if (Current[count] == mibTreeEntry->name[count]) { + if (mibTreeEntry && Current[count] == mibTreeEntry->name[count]) { ++count; while ((mibTreeEntry) && (count < CurrentLen) && (!mibTreeEntry->parsefunction)) { @@ -660,7 +659,7 @@ snmpTreeNext(oid * Current, snint CurrentLen, oid ** Next, snint * NextLen) if ((mibTreeEntry) && (mibTreeEntry->parsefunction)) { --count; - nextoid = snmpTreeSiblingEntry(Current[count], count, mibTreeEntry->parent); + mib_tree_entry *nextoid = snmpTreeSiblingEntry(Current[count], count, mibTreeEntry->parent); if (nextoid) { debugs(49, 5, "snmpTreeNext: Next OID found for sibling" << nextoid ); mibTreeEntry = nextoid; @@ -758,6 +757,9 @@ peer_Inst(oid * name, snint * len, mib_tree_entry * current, oid_ParseFn ** Fn) while ((current) && (!current->parsefunction)) current = current->leaves[0]; + if(!current) + return (instance); + instance = client_Inst(current->name, len, current, Fn); } else if (*len <= current->len) { debugs(49, 6, "snmp peer_Inst: *len <= current->len ???");