php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #31772 [PATCH] Net-SNMP 5.2.x ++ Workaround in PHP_SNMP Incorrectly Coded
Submitted: 2005-01-31 01:05 UTC Modified: 2011-08-21 07:04 UTC
From: harrie@php.net Assigned: lytboris (profile)
Status: Closed Package: SNMP related
PHP Version: 5.0.3 OS: Win32
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: harrie@php.net
New email:
PHP Version: OS:

 

 [2005-01-31 01:05 UTC] harrie@php.net
Description:
------------
The following code in snmp.c from lines: 794 through 831 is not valid.  If both HAVE_AES and SNMP_VALIDATE_ERR are defined, the ifdef's will not function properly.  Please review the code below.

Reproduce code:
---------------
Incorrect code (starting on 810):

"* symbol on purpose, as it's defined to be the same as the former.
*/
			|| !strcasecmp(prot, "AES")) {
#else			
		) {
			s->securityPrivProto = usmAES128PrivProtocol;
			s->securityPrivProtoLen = OIDSIZE(usmAES128PrivProtocol);
			return (0);"


Correct Code (starting on 810):

"* symbol on purpose, as it's defined to be the same as the former.
*/
			|| !strcasecmp(prot, "AES")) {
			s->securityPrivProto = usmAES128PrivProtocol;
			s->securityPrivProtoLen = OIDSIZE(usmAES128PrivProtocol);
			return (0);
#else			
		) {
			s->securityPrivProto = usmAES128PrivProtocol;
			s->securityPrivProtoLen = OIDSIZE(usmAES128PrivProtocol);
			return (0);"


Expected result:
----------------
N/A.  Please review code snippet.

Actual result:
--------------
N/A.  Please review code snippet.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-02-01 03:17 UTC] larryjadams at comcast dot net
I have submitted fixes for the following PHP CVS Branches:

PHP 4.3.x
PHP 5.0.x
PHP 5.1.x

The fix also included the snmpv2 feature set.  I hope you all enjoy it as much as I will.

Larry
 [2005-02-28 20:54 UTC] sniper@php.net
Please provide the unified diff somewhere in the web and add the url to it here.

 [2005-03-01 00:52 UTC] LarryJAdams at comcast dot net
Your links are as follows:

php_snmp for php4.3.x
http://home.comcast.net/~larryjadams/snmp4.3.x.diff

php_snmp for php5.0.x
http://home.comcast.net/~larryjadams/snmp5.0.x.diff

php_snmp for php5.1.x
http://home.comcast.net/~larryjadams/snmp5.1.x.diff

TheWitness
 [2005-03-01 01:24 UTC] LarryJAdams at comcast dot net
The prior post was for the snmp.c files.  The php_snmp.h files are patched as follows:

php_snmp.h for php4.3.x
http://home.comcast.net/~larryjadams/php_snmp.4.3.x.diff

php_snmp.h for php5.0.x
http://home.comcast.net/~larryjadams/php_snmp.5.0.x.diff

php_snmp.h for php5.1.x
http://home.comcast.net/~larryjadams/php_snmp.5.1.x.diff

TheWitness
 [2005-03-06 17:40 UTC] sniper@php.net
What's wrong with adding something like 'snmp_set_version()' func instead of having separate functions for v1/v2/v3 ???

 [2005-03-06 20:39 UTC] LarryJAdams at comcast dot net
I had the same question for Harrie (one of the authors) and he did not want to go that way.  However, there is another workaround that was sent to me by another user that could be incorporated except for the "bulk" operations.

Either way, this code works and the SNMPv3 is so different anyway, we can't go down to one function easily.
 [2005-03-16 13:47 UTC] harrie@php.net
I do not see this patch as the correct solution.
It duplicates the same function of parsing the SNMPv1
arguments with the exception of the version itself.

Therefore, a proper solution would be to add a version
parameter to the parsing of the SNMPv1 arguments and
use that to configure the version.
This avoids the duplicated code where the handling of
SNMPv1 and SNMPv2c (both community based) are simply
equal except the version number.

 [2005-03-16 13:52 UTC] harrie@php.net
As for creating a set_version function this is not
useful if in a single PHP script multiple SNMP versions
are needed. This is not that unlikely if one wants to
access more then one single SNMP agent.

A better solution would be to setup a SNMP session and use
this struct as the argument for SNMP retrieval functions.
But since backwards compatibility seems an issue the
solution of adding version specific functions is easier.
Maybe even clearer to a user (PHP programmer).

 [2005-03-16 14:02 UTC] harrie@php.net
Harrie,

Per my e-mail, I have patch code that performs the exact thing.  Only question to remain is do we want the default walk behavior to be "bulk" when performing snmpv2 calls?

I would suggest that we hold off on "bulk" get's until a later date.  Please let me know.

Larry
 [2011-04-08 21:49 UTC] jani@php.net
-Package: Feature/Change Request +Package: SNMP related
 [2011-08-21 07:03 UTC] lytboris@php.net
-Status: Open +Status: Feedback
 [2011-08-21 07:03 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/

Solved adding OO API
 [2011-08-21 07:04 UTC] lytboris@php.net
-Assigned To: +Assigned To: lytboris
 [2011-08-21 07:04 UTC] lytboris@php.net
-Status: Feedback +Status: Closed
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 07 06:01:28 2024 UTC