Closed
Description
Describe the bug
If a blank path is passed to the is_resource_writable() function, this will cause PHP to generate a notice of Uninitialized string offset: -1 in /usr/share/cacti/site/lib/functions.php on line 5141
This was found during an upgrade from 1.2.3 to 1.2.5
Expected behavior
No notice should be given as is_resource_writable()
should check for an empty string before attempting to manipulate it.
function is_resource_writable($path) {
if ($path{strlen($path)-1}=='/') {
return is_resource_writable($path.uniqid(mt_rand()).'.tmp');
}
should be
function is_resource_writable($path) {
if (empty($path)) {
return false;
}
if ($path{strlen($path)-1}=='/') {
return is_resource_writable($path.uniqid(mt_rand()).'.tmp');
}