~ubuntu-branches/debian/squeeze/cacti/squeeze

« back to all changes in this revision

Viewing changes to debian/patches/fix_COMMENT_in_graph_regression_from_CVE-2013-1435.patch

  • Committer: Package Import Robot
  • Author(s): Paul Gevers
  • Date: 2013-08-28 20:52:20 UTC
  • Revision ID: package-import@ubuntu.com-20130828205220-zccn57s0jpnlspl3
Tags: 0.8.7g-1+squeeze3
* Security upload
* Fix Cross site scripting in host.php and install/index.php (upstream
  bug 2383) CVE-2013-5588
* Fix SQL injection in host.php (upstream bug 2383)
  CVE-2013-5589

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
 
5
 
 
6
--- a/lib/rrd.php
 
7
+++ b/lib/rrd.php
 
8
@@ -1296,20 +1296,20 @@
 
9
                $need_rrd_nl = TRUE;
 
10
 
 
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]);
 
17
+                       } else {
 
18
+                               $comment_arg = cacti_escapeshellarg($comment_arg . $hardreturn[$graph_item_id]);
 
19
+                       }
 
20
+
 
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);
 
28
-                               }
 
29
+                               $txt_graph_items .= $graph_item_types{$graph_item["graph_type_id"]} . ":" . str_replace(":", "\:", $comment_arg) . " ";
 
30
                        }else {
 
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);
 
36
-                               }
 
37
+                               $txt_graph_items .= $graph_item_types{$graph_item["graph_type_id"]} . ":" . $comment_arg . " ";
 
38
                        }
 
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 */