#48359 [Opn]: Script hangs on snmprealwalk if OID is not increasing
| From: | simonov at gmail dot com | Date: | Fri, 22 May 2009 04:41:01 +0000 |
| Subject: | #48359 [Opn]: Script hangs on snmprealwalk if OID is not increasing | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-137629@lists.php.net to get a copy of this message | ||
ID: 48359
User updated by: simonov at gmail dot com
Reported By: simonov at gmail dot com
Status: Open
Bug Type: SNMP related
Operating System: FreeBSD 7.2
PHP Version: 5.2.9
New Comment:
Patch without formatting issues:
http://cl1p.net/phpsnmpoidincreasing/
Previous Comments:
------------------------------------------------------------------------
[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