php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #48359 [PATCH] Script hangs on snmprealwalk if OID is not increasing
Submitted: 2009-05-22 04:36 UTC Modified: 2009-05-31 14:12 UTC
From: simonov at gmail dot com Assigned:
Status: Closed Package: SNMP related
PHP Version: 5.2.9 OS: *
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: simonov at gmail dot com
New email:
PHP Version: OS:

 

 [2009-05-22 04:36 UTC] 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


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-05-22 04:41 UTC] simonov at gmail dot com
Patch without formatting issues:
http://cl1p.net/phpsnmpoidincreasing/
 [2009-05-22 04:43 UTC] simonov at gmail dot com
This problem applies to php for every OS.
 [2009-05-31 14:12 UTC] iliaa@php.net
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.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Dec 11 11:01:27 2024 UTC