1
Description: The fix for CVE-2013-1435 (command line injection) introduced
2
a regression in the case that a COMMENT is inserted without trailing space.
3
Author: Gandalf <gandalf@cacti.net>
4
Origin: http://sourceforge.net/mailarchive/message.php?msg_id=31262712
8
@@ -1296,20 +1296,20 @@
11
if ($graph_item_types{$graph_item["graph_type_id"]} == "COMMENT") {
12
+ # perform variable substitution first (in case this will yield an empty results or brings command injection problems)
13
+ $comment_arg = rrd_substitute_host_query_data($graph_variables["text_format"][$graph_item_id], $graph, $graph_item);
14
+ # next, compute the argument of the COMMENT statement and perform injection counter measures
15
+ if (trim($comment_arg) == '') { # an empty COMMENT must be treated with care
16
+ $comment_arg = cacti_escapeshellarg(' ' . $hardreturn[$graph_item_id]);
18
+ $comment_arg = cacti_escapeshellarg($comment_arg . $hardreturn[$graph_item_id]);
21
+ # create rrdtool specific command line
22
if (read_config_option("rrdtool_version") != "rrd-1.0.x") {
23
- $comment_string = $graph_item_types{$graph_item["graph_type_id"]} . ":" . str_replace(":", "\:", cacti_escapeshellarg($graph_variables["text_format"][$graph_item_id] . $hardreturn[$graph_item_id])) . " ";
24
- if (trim($comment_string) == 'COMMENT:"\n"') {
25
- $txt_graph_items .= 'COMMENT:" \n"'; # rrdtool will skip a COMMENT that holds a NL only; so add a blank to make NL work
26
- } else if (trim($comment_string) != "COMMENT:\"\"") {
27
- $txt_graph_items .= rrd_substitute_host_query_data($comment_string, $graph, $graph_item);
29
+ $txt_graph_items .= $graph_item_types{$graph_item["graph_type_id"]} . ":" . str_replace(":", "\:", $comment_arg) . " ";
31
- $comment_string = $graph_item_types{$graph_item["graph_type_id"]} . ":" . cacti_escapeshellarg($graph_variables["text_format"][$graph_item_id] . $hardreturn[$graph_item_id]) . " ";
32
- if (trim($comment_string) == 'COMMENT:"\n"') {
33
- $txt_graph_items .= 'COMMENT:" \n"'; # rrdtool will skip a COMMENT that holds a NL only; so add a blank to make NL work
34
- } else if (trim($comment_string) != "COMMENT:\"\"") {
35
- $txt_graph_items .= rrd_substitute_host_query_data($comment_string, $graph, $graph_item);
37
+ $txt_graph_items .= $graph_item_types{$graph_item["graph_type_id"]} . ":" . $comment_arg . " ";
39
}elseif (($graph_item_types{$graph_item["graph_type_id"]} == "GPRINT") && (!isset($graph_data_array["graph_nolegend"]))) {
40
$graph_variables["text_format"][$graph_item_id] = str_replace(":", "\:", $graph_variables["text_format"][$graph_item_id]); /* escape colons */