php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #1423 snmprealwalk() returns wrong oid for array key values.
Submitted: 1999-05-18 13:27 UTC Modified: 1999-05-18 13:35 UTC
From: mhjack at tscnet dot com Assigned:
Status: Closed Package: Other
PHP Version: 3.0.7 OS: Linux 2.0.36
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: mhjack at tscnet dot com
New email:
PHP Version: OS:

 

 [1999-05-18 13:27 UTC] mhjack at tscnet dot com
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..





Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [1999-05-18 13:35 UTC] rasmus at cvs dot php dot net
Thanks for the fix.  It has been applied and will be in 3.0.8.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sun Jul 06 11:02:27 2025 UTC