Bug #1423: snmprealwalk() returns wrong oid for array key values.

From: Date: Tue, 18 May 1999 17:27:04 +0000
Subject: Bug #1423: snmprealwalk() returns wrong oid for array key values.
Groups: php.dev 
Request: Send a blank email to php-dev+get-5765@lists.php.net to get a copy of this message
From: mhjack@tscnet.com Operating system: Linux 2.0.36 PHP version: 3.0.7 PHP Bug Type: Other Bug description: snmprealwalk() returns wrong oid for array key values. snmprealwalk() - see /* $Id: snmp.c,v 1.11 1999/04/05 18:07:05 sas Exp $ */ The snmprealwalk() function returns an array of OID/value pairs; however, the OID/value pairs are offset because the returned OID is the requested OID and not the returned OID. Here is an example: <script language="php"> $walk = snmprealwalk("127.0.0.1", "public", "interfaces.ifTable.ifEntry.ifIndex"); reset($walk); while ( list($key,$val) = each($walk) ){ echo "$key => $val<br>"; } echo "</PRE>"; </script> </BODY> </HTML> This produces the following (incorrect) output: interfaces.ifTable.ifEntry.ifIndex => 1 interfaces.ifTable.ifEntry.ifIndex.1 => 2 interfaces.ifTable.ifEntry.ifIndex.2 => 3 interfaces.ifTable.ifEntry.ifIndex.3 => 4 ... The following change corrects the problem: 29,30c29 < /* $Id: snmp.c,v 1.12 1999/04/05 18:07:05 mhjack Exp $ */ < --- > /* $Id: snmp.c,v 1.11 1999/04/05 18:07:05 sas Exp $ */ 234c233 < sprint_objid(buf2, vars->name, vars->name_length); --- > sprint_objid(buf2, name, name_length); This changes the output to be correct: interfaces.ifTable.ifEntry.ifIndex.1 => 1 interfaces.ifTable.ifEntry.ifIndex.2 => 2 interfaces.ifTable.ifEntry.ifIndex.3 => 3 interfaces.ifTable.ifEntry.ifIndex.4 => 4 ... A full context diff file is available at: http://kes.tscnet.com/snmp.c.diff Thanks.. -- PHP Development Mailing List http://www.php.net/ To unsubscribe send an empty message to php-dev-unsubscribe@lists.php.net For help: php-dev-help@lists.php.net

« previous php.dev (#5765) next »