|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2009-05-22 04:41 UTC] simonov at gmail dot com
[2009-05-22 04:43 UTC] simonov at gmail dot com
[2009-05-31 14:12 UTC] iliaa@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 01:00:02 2025 UTC |
Description: ------------ snmprealwalk function gets into indefinite loop if OID is not increasing, so script hangs. The following change corrects the problem: --- snmp.c.orig 2009-05-22 10:12:14.000000000 +0600 +++ snmp.c 2009-05-22 10:17:58.000000000 +0600 @@ -490,9 +490,16 @@ if (st >= SNMP_CMD_WALK && st != SNMP_CMD_SET) { if (vars->type != SNMP_ENDOFMIBVIEW && vars->type != SNMP_NOSUCHOBJECT && vars->type != SNMP_NOSUCHINSTANCE) { - memmove((char *)name, (char *)vars->name,vars->name_length * sizeof(oid)); - name_length = vars->name_length; - keepwalking = 1; + if (snmp_oid_compare(name, name_length, + vars->name, + vars->name_length) >= 0) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error: OID not increasing: %s",name); + keepwalking = 0; + } else { + memmove((char *)name, (char *)vars->name,vars->name_length * sizeof(oid)); + name_length = vars->name_length; + keepwalking = 1; + } } } } Reproduce code: --------------- $temp_array = @snmprealwalk("$hostname:$port", "$community", "$oid", ($timeout * 1000), $retries); Expected result: ---------------- (snip from tcpdump): 10:19:10.392849 IP 3.3.3.3.161 > 1.1.1.1.50706: GetResponse(34) .1.3.6.1.2.1.4.20.1.2.127.0.0.1=2 10:19:10.392908 IP 1.1.1.1.50706 > 3.3.3.3.161: GetNextRequest(33) .1.3.6.1.2.1.4.20.1.2.127.0.0.1 10:19:10.422741 IP 3.3.3.3.161 > 1.1.1.1.50706: GetResponse(34) .1.3.6.1.2.1.4.20.1.2.127.0.0.1=1 10:19:10.444217 IP 1.1.1.1.58395 > 3.3.3.3.161: GetRequest(28) .1.3.6.1.2.1.1.3.0 Actual result: -------------- Indefinite cycle (snip from tcpdump): 10:00:34.955679 IP 3.3.3.3.161 > 1.1.1.1.51705: GetResponse(34) .1.3.6.1.2.1.4.20.1.2.127.0.0.1=1 10:00:34.955787 IP 1.1.1.1.51705 > 3.3.3.3.161: GetNextRequest(33) .1.3.6.1.2.1.4.20.1.2.127.0.0.1 10:00:34.985357 IP 3.3.3.3.161 > 1.1.1.1.51705: GetResponse(34) .1.3.6.1.2.1.4.20.1.2.127.0.0.1=1 10:00:34.985452 IP 1.1.1.1.51705 > 3.3.3.3.161: GetNextRequest(33) .1.3.6.1.2.1.4.20.1.2.127.0.0.1