markabrahams / node-net-snmp

JavaScript implementation of the Simple Network Management Protocol (SNMP)
207 stars 97 forks source link

Fixup getNext when called for a non-node #188

Closed diwic closed 2 years ago

diwic commented 2 years ago

GetNext should always return a value that is >= start oid, but this is not always the case.

E g, if a tree has nodes nnn.2.2 and nnn.2.4 (with values at nnn.2.2.0 and nnn.2.4.0), but not nnn.2.3, and nnn.2.3 is requested, GetNext will return 2.2.0 instead of the expected 2.4.0. The proposed code fixes that case by letting Mib.getTextNode return the last descendant.

getTreeNode is only used from Agent/Subagent.getNext, and the relevant code path is executed only if the node suggested is not in the tree, so changing getTreeNode seems safe enough.

markabrahams commented 2 years ago

Hi @diwic - thanks heaps for the PR - much appreciated!

diwic commented 2 years ago

@markabrahams Thanks for the quick review and merge :-)