mirror of
https://github.com/Cacti/spine.git
synced 2026-10-23 03:27:10 +09:00
fix(snmp): move count++ inside valid-type branch in snmp_count() (#427)
Fixes #422 `count++` at `snmp.c:899` fired before the `SNMP_ENDOFMIBVIEW` type check. When an agent returns ENDOFMIBVIEW with the OID still within the requested subtree (RFC 3416 permits this), the out-of-subtree guard does not fire and count reaches 1 for an empty table. The poller reindex assertion then incorrectly triggers a reindex every poll cycle. Move `count++` inside the `if (vars->type != SNMP_ENDOFMIBVIEW && ...)` branch so only real entries increment the counter. Verified by `tests/snmpv3/scripts/run_test.sh` Phase 4: inserts a `poller_reindex` row with `action=10` for a non-existent OID subtree and confirms spine logs `output: 0`. --------- Signed-off-by: Thomas Vincent <thomasvincent@gmail.com> Co-authored-by: TheWitness <thewitness@cacti.net>
This commit is contained in:
1 parent
1e806be3de
commit
c501bc8499
11 files changed
+499
-4
No files matched your search
@@ -896,12 +896,12 @@ int snmp_count(host_t *current_host, char *snmp_oid) {
|
||||
ok = 0;
|
||||
continue;
|
||||
}
|
||||
count++;
|
||||
|
||||
/* END OF MIB or NO SUCH OBJECT or NO SUCH INSTANCE */
|
||||
if ((vars->type != SNMP_ENDOFMIBVIEW) &&
|
||||
(vars->type != SNMP_NOSUCHOBJECT) &&
|
||||
(vars->type != SNMP_NOSUCHINSTANCE)) {
|
||||
/* count only real entries, not the walk terminator */
|
||||
count++;
|
||||
/* valid data, so perform a compare */
|
||||
if (snmp_oid_compare(anOID, anOID_len, vars->name, vars->name_length) >= 0) {
|
||||
SPINE_LOG(("ERROR: OID not increasing"));
|
||||
|
||||
Reference in new issue
Block a user