php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #54111 read_mib does not return correct response
Submitted: 2011-02-27 18:04 UTC Modified: 2011-07-23 04:05 UTC
From: jthijsse at noxlogic dot nl Assigned: lytboris (profile)
Status: Not a bug Package: SNMP related
PHP Version: Irrelevant OS: *
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: jthijsse at noxlogic dot nl
New email:
PHP Version: OS:

 

 [2011-02-27 18:04 UTC] jthijsse at noxlogic dot nl
Description:
------------
snmp_read_mib() returns a boolean depending on success of the read. Internally, the reab_mib() call returns either NULL or the root of the mib-tree, depending on succes. This problem here is that read_mib ONLY returns NULL when the mib-file is not found and not when there is a parse-error inside the file. In that case it will just return the mib root tree (which is !null) and thus it will return true back to the php user.


As a sidenote (maybe a different bug): snmp_disable_stderrlog() does not work 100% for disabling snmp error logging. Net-snmp wants at least 1 type of log handler active at all times. A simple fix would be to add snmp_enable_calllog(), so it would use the callback handler for logging (and since there are no handlers registered, no logging would occur). It would be nicer though to actually have a callback registered which can return info back to php level (snmp_[clear|get]_log for instance). The code for this functional and can be supplied as a patch against php5.3 and the new OO api in trunk. 

Test script:
---------------
var_dump(snmp_read_mib("cannotfindthisfile")); 
var_dump(snmp_read_mib("incorrectmibfile")); 


Expected result:
----------------
bool(false)
bool(false)

Actual result:
--------------
bool(false)
Warning: snmp_read_mib(): Error while reading MIB file '%s': No such file or directory in %s on line %d
bool(true)

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-02-28 01:11 UTC] cataphract@php.net
-Assigned To: +Assigned To: lytboris
 [2011-07-23 04:05 UTC] lytboris@php.net
-Status: Assigned +Status: Bogus
 [2011-07-23 04:05 UTC] lytboris@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

snmp_read_mib(): this is a Net-SNMP library bug, not php-snmp: read_module_internal() should return some error if parse(fp, NULL) returned NULL.

And for logging facility you may open a new bug report and attach the patch you propose.
 
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Thu Apr 02 10:01:23 2020 UTC