Skip to content

Commit 791fce6

Browse files
hardening: guard variable function call with function_exists() check
Prevent a fatal error if an action map entry names a non-existent function. Also fix indentation in the export elseif block. Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
1 parent dd71bd5 commit 791fce6

1 file changed

Lines changed: 11 additions & 6 deletions

File tree

functions.php

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -129,15 +129,20 @@ function syslog_sendemail($to, $from, $subject, $message, $smsmessage = '') {
129129
function syslog_apply_selected_items_action($selected_items, $drp_action, $action_map, $export_action = '', $export_items = '') {
130130
if ($selected_items != false) {
131131
if (isset($action_map[$drp_action])) {
132-
foreach($selected_items as $selected_item) {
133-
$action_function = $action_map[$drp_action];
134-
$action_function($selected_item);
132+
$action_function = $action_map[$drp_action];
133+
134+
if (function_exists($action_function)) {
135+
foreach($selected_items as $selected_item) {
136+
$action_function($selected_item);
137+
}
138+
} else {
139+
cacti_log("SYSLOG ERROR: Bulk action function '$action_function' not found.", false, 'SYSTEM');
135140
}
136141
} elseif ($export_action != '' && $drp_action == $export_action) {
137142
/* Re-serialize the sanitized array and URL-encode so the value is
138-
* safe to embed in a JS document.location string (avoids injection
139-
* via the raw request value that $export_items carries). */
140-
$_SESSION['exporter'] = rawurlencode(serialize($selected_items));
143+
* safe to embed in a JS document.location string (avoids injection
144+
* via the raw request value that $export_items carries). */
145+
$_SESSION['exporter'] = rawurlencode(serialize($selected_items));
141146
}
142147
}
143148
}

0 commit comments

Comments
 (0)