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
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
17 + 31 = ?
Subscribe to this entry?

 
 [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-2024 The PHP Group
All rights reserved.
Last updated: Thu Mar 28 13:01:28 2024 UTC