php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #64159 Truncated snmpget
Submitted: 2013-02-05 16:18 UTC Modified: 2013-09-13 05:45 UTC
Votes:4
Avg. Score:4.2 ± 0.8
Reproduced:4 of 4 (100.0%)
Same Version:3 (75.0%)
Same OS:1 (25.0%)
From: loic dot blot at unix-experience dot fr Assigned: lytboris (profile)
Status: Closed Package: SNMP related
PHP Version: 5.4.11 OS: *
Private report: No CVE-ID: None
 [2013-02-05 16:18 UTC] loic dot blot at unix-experience dot fr
Description:
------------
Hello,
Since php 5.4.11 i get a problem on snmpget function. I haven't the problem with system snmpget command.

large responses for snmpget are truncated.

I think there is a buffer problem.

Expected result:
----------------
but instead i get:
7F FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF

Actual result:
--------------
For example, snmpget (on CISCO switches), really returns:
7F FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2013-02-06 21:54 UTC] johannes@php.net
Thank you for this bug report. To properly diagnose the problem, we
need a short but complete example script to be able to reproduce
this bug ourselves. 

A proper reproducing script starts with <?php and ends with ?>,
is max. 10-20 lines long and does not require any external 
resources such as databases, etc. If the script requires a 
database to demonstrate the issue, please make sure it creates 
all necessary tables, stored procedures etc.

Please avoid embedding huge scripts into the report.


 [2013-02-06 21:54 UTC] johannes@php.net
-Status: Open +Status: Feedback
 [2013-02-06 22:00 UTC] loic dot blot at unix-experience dot fr
-Status: Feedback +Status: Open
 [2013-02-06 22:00 UTC] loic dot blot at unix-experience dot fr
do this on a CISCO 2950, 2960, 3750 or 4500 (that's all devices i have tested) with proper community and ip.

<?php echo snmpget("192.168.1.1","2c","public","1.3.6.1.4.1.9.9.46.1.6.1.1.4"); ?>
 [2013-02-20 18:40 UTC] yordan dot yordanov at innologica dot com
Happening to me aslo. Here's my reproduction:

[root@monitor ~]# snmpwalk -cpublic -v1 192.168.0.232 -On 
.1.3.6.1.4.1.9.9.46.1.6.1.1.4.10003
.1.3.6.1.4.1.9.9.46.1.6.1.1.4.10003 = Hex-STRING: 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 04 00 00 00
[root@monitor ~]# php -r 
'print_r(snmprealwalk("192.168.0.232","public",".1.3.6.1.4.1.9.9.46.1.6.1.1.4.10
003"));'
Array
(
    [SNMPv2-SMI::enterprises.9.9.46.1.6.1.1.4.10003] => Hex-STRING: 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

)
[root@monitor ~]# php -v
PHP 5.4.11 (cli) (built: Jan 16 2013 16:51:38)
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2013 Zend Technologies
[root@monitor ~]# uname -a
Linux xxxxxxxx 2.6.32-279.19.1.el6.x86_64 #1 SMP Wed Dec 19 07:05:20 UTC 2012 
x86_64 x86_64 x86_64 GNU/Linux
[root@monitor ~]# cat /etc/centos-release
CentOS release 6.3 (Final)
 [2013-05-03 09:35 UTC] lytboris@php.net
-Operating System: FreeBSD 9.1 +Operating System: *
 [2013-05-03 09:35 UTC] lytboris@php.net
Basically this is because of loosy algorithm predicting string length produced by snmp library function that prints OID values.
As a walkaround one can set
===
snmp_set_valueretrieval(SNMP_VALUE_PLAIN);
===
(or OO API [SNMP Object]->valueretrieval)
and then use bin2hex to decode binary string into hex string.
 [2013-05-03 11:16 UTC] lytboris@php.net
-Assigned To: +Assigned To: lytboris
 [2013-05-03 12:08 UTC] lytboris@php.net
Automatic comment on behalf of lytboris
Revision: http://git.php.net/?p=php-src.git;a=commit;h=e36adfe94a663bc1eeb5d9d378dc80883de179db
Log: Fixed bug #64159 (Truncated snmpget)
 [2013-05-03 12:08 UTC] lytboris@php.net
-Status: Assigned +Status: Closed
 [2013-05-03 12:08 UTC] lytboris@php.net
Automatic comment on behalf of lytboris
Revision: http://git.php.net/?p=php-src.git;a=commit;h=2c336c9cde524cb6465bbd75924b7e40251aefab
Log: Fixed bug #64159 (Truncated snmpget)
 [2013-05-03 12:08 UTC] lytboris@php.net
Please try using this snapshot:

  http://snaps.php.net/php5.4-latest.tar.gz
 
For Windows:

  http://windows.php.net/snapshots/


 [2013-05-03 12:08 UTC] lytboris@php.net
-Status: Closed +Status: Feedback
 [2013-09-13 05:45 UTC] lytboris@php.net
-Status: Feedback +Status: No Feedback
 [2013-09-13 05:45 UTC] lytboris@php.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.


 [2013-11-17 09:31 UTC] laruence@php.net
Automatic comment on behalf of lytboris
Revision: http://git.php.net/?p=php-src.git;a=commit;h=2c336c9cde524cb6465bbd75924b7e40251aefab
Log: Fixed bug #64159 (Truncated snmpget)
 [2013-11-17 09:31 UTC] laruence@php.net
-Status: No Feedback +Status: Closed
 [2014-10-07 23:19 UTC] stas@php.net
Automatic comment on behalf of lytboris
Revision: http://git.php.net/?p=php-src-security.git;a=commit;h=e36adfe94a663bc1eeb5d9d378dc80883de179db
Log: Fixed bug #64159 (Truncated snmpget)
 [2014-10-07 23:30 UTC] stas@php.net
Automatic comment on behalf of lytboris
Revision: http://git.php.net/?p=php-src-security.git;a=commit;h=e36adfe94a663bc1eeb5d9d378dc80883de179db
Log: Fixed bug #64159 (Truncated snmpget)
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Mar 19 11:01:28 2024 UTC