From d38fe0e5cab4a7efaba8a79a22a85b0e67817441 Mon Sep 17 00:00:00 2001 From: "terry%mozilla.org" <> Date: Wed, 8 Mar 2000 02:22:41 +0000 Subject: Patch by Brian Duggan -- security improvements. --- CGI.pl | 3 +++ buglist.cgi | 3 +++ createattachment.cgi | 1 + reports.cgi | 8 ++++---- showattachment.cgi | 2 +- showdependencygraph.cgi | 1 + 6 files changed, 13 insertions(+), 5 deletions(-) diff --git a/CGI.pl b/CGI.pl index 8f80826d2..c8dc98e2c 100644 --- a/CGI.pl +++ b/CGI.pl @@ -842,6 +842,9 @@ sub CheckIfVotedConfirmed { sub DumpBugActivity { my ($id, $starttime) = (@_); my $datepart = ""; + + die "Invalid id: $id" unless $id=~/^\s*\d+\s*$/; + if (defined $starttime) { $datepart = "and bugs_activity.bug_when >= $starttime"; } diff --git a/buglist.cgi b/buglist.cgi index 43d46c7ea..75549e730 100755 --- a/buglist.cgi +++ b/buglist.cgi @@ -170,6 +170,7 @@ sub GenerateSQL { } if (defined $F{'sql'}) { + die "Invalid sql: $F{'sql'}" if $F{'sql'} =~ /;/; push(@wherepart, "( $F{'sql'} )"); } @@ -887,6 +888,8 @@ if (defined $::FORM{'order'} && $::FORM{'order'} ne "") { $::FORM{'order'} =~ s/assign\.login_name/map_assigned_to.login_name/g; # Another backwards compatability hack. + die "Invalid order: $::FORM{'order'}" unless + $::FORM{'order'} =~ /^([a-zA-Z0-9_., ]+)$/; ORDER: for ($::FORM{'order'}) { /\./ && do { # This (hopefully) already has fieldnames in it, so we're done. diff --git a/createattachment.cgi b/createattachment.cgi index 1eaf9b1ea..fa370d710 100755 --- a/createattachment.cgi +++ b/createattachment.cgi @@ -41,6 +41,7 @@ confirm_login(); print "Content-type: text/html\n\n"; my $id = $::FORM{'id'}; +die "invalid id: $id" unless $id=~/^\s*\d+\s*$/; PutHeader("Create an attachment", "Create attachment", "Bug $id"); diff --git a/reports.cgi b/reports.cgi index 6c8ededcf..805de8da9 100755 --- a/reports.cgi +++ b/reports.cgi @@ -206,7 +206,7 @@ and bugs.reporter = report.userid FIN if( $::FORM{'product'} ne "-All-" ) { - $query .= "and bugs.product='$::FORM{'product'}'"; + $query .= "and bugs.product=".SqlQuote($::FORM{'product'}); } $query .= <