|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #69739 PHP SNMP Real Walk returns bad characters
Submitted: 2015-06-01 15:24 UTC Modified: 2016-06-19 04:22 UTC
Avg. Score:5.0 ± 0.0
Reproduced:2 of 2 (100.0%)
Same Version:1 (50.0%)
Same OS:1 (50.0%)
From: kriz at mysafira dot net Assigned: lytboris (profile)
Status: No Feedback Package: SNMP related
PHP Version: Irrelevant OS: Ubuntu 14.04.2, Windows 7 x64
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2015-06-01 15:24 UTC] kriz at mysafira dot net
I read via PHP function snmp2_real_walk OID value '.' for get MAC address from Cisco switch device. Problem is, that some results (randomly around the 50 results of the 200) return bad characters (yet I have found a mistake if I read only MAC addresses). Ie.:

correct output examples:
 [Dot1dTpFdbAddres] => 30 05 5C 38 A7 8C
 [Dot1dTpFdbAddres] => C0 7B BC 0E 56 18

wrong output examples - device return randomly none-hex value for hex values, ie.:
[iso.] => Hex-STRING: 5C 26 0A 81 7B 1B 
[iso.] => Hex-STRING: 78 45 C4 2A 19 F1 
[iso.] => Hex-STRING: 78 45 C4 2A 1B A9 
[iso.] => STRING: "xE�*\"-"
[iso.] => STRING: "x�����"
[iso.] => Hex-STRING: 7C 1E B3 FE 09 C9 

If I try read OID '.' from program Getif, I have got correct results.

The tested solution that fails:
 PHP - Chnaged snmp2_real_walk by snmprealwalk
 Changed encoding of files (UTF8, ANSI)
 SNMP longer timeout and try add PHP sleep() function
 PHP directive: snmp_set_oid_numeric_print(1)
 PHP directive: snmp_set_quick_print(true)
 PHP directive: snmp_set_enum_print(true)
 PHP directive: snmp_set_valueretrieval(SNMP_VALUE_LIBRARY and SNMP_VALUE_PLAIN)

Resolution - add new parameter for:
for forced return Hex-STRING result.

Test script:
$arrDot1dTpFdbAddress = snmprealwalk("SomeIp:161", "ReadCommunity", ".", (1000000 * 1), 3);
    echo '<pre>';
    echo '</pre>'; 


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2016-06-06 07:45 UTC]
-Status: Open +Status: Feedback
 [2016-06-06 07:45 UTC]
Do you have MIB file loaded for this OID subtree on script launch? As far as I can see from your output, SNMP library does not know exact type of HEX string that is being returned by the agent so it does it's best.

So you have two possible approaches for this:
  1) use SNMP_VALUE_PLAIN. That will return all strings in that subtree as binary strings so you can handle them properly in PHP (see bin2hex());
  2) load MIB so SNMP library will know how to handle those strings.

There is no real reason to pull this conversion into php-snmp library.
 [2016-06-06 07:49 UTC]
-Assigned To: +Assigned To: lytboris
 [2016-06-19 04:22 UTC] php-bugs at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue May 28 15:01:30 2024 UTC