ID: 48359 Updated by: il...@php.net Reported By: simonov at gmail dot com -Status: Open +Status: Closed Bug Type: SNMP related Operating System: * PHP Version: 5.2.9 New Comment:
This bug has been fixed in CVS. Snapshots of the sources are packaged every three hours; this change will be in the next snapshot. You can grab the snapshot at http://snaps.php.net/. Thank you for the report, and for helping us make PHP better. Previous Comments: ------------------------------------------------------------------------ [2009-05-22 04:43:58] simonov at gmail dot com This problem applies to php for every OS. ------------------------------------------------------------------------ [2009-05-22 04:41:01] simonov at gmail dot com Patch without formatting issues: http://cl1p.net/phpsnmpoidincreasing/ ------------------------------------------------------------------------ [2009-05-22 04:36:30] simonov at gmail dot com 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 ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=48359&edit=1