From: simonov at gmail dot com Operating system: FreeBSD 7.2 PHP version: 5.2.9 PHP Bug Type: SNMP related Bug description: Script hangs on snmprealwalk if OID is not increasing
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 bug report at http://bugs.php.net/?id=48359&edit=1 -- Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=48359&r=trysnapshot52 Try a CVS snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=48359&r=trysnapshot53 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=48359&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=48359&r=fixedcvs Fixed in CVS and need be documented: http://bugs.php.net/fix.php?id=48359&r=needdocs Fixed in release: http://bugs.php.net/fix.php?id=48359&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=48359&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=48359&r=needscript Try newer version: http://bugs.php.net/fix.php?id=48359&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=48359&r=support Expected behavior: http://bugs.php.net/fix.php?id=48359&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=48359&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=48359&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=48359&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=48359&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=48359&r=dst IIS Stability: http://bugs.php.net/fix.php?id=48359&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=48359&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=48359&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=48359&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=48359&r=mysqlcfg