Commit d38fe0e5 authored by terry%mozilla.org's avatar terry%mozilla.org

Patch by Brian Duggan <bduggan@oven.com> -- security improvements.

parent 77f66018
...@@ -842,6 +842,9 @@ sub CheckIfVotedConfirmed { ...@@ -842,6 +842,9 @@ sub CheckIfVotedConfirmed {
sub DumpBugActivity { sub DumpBugActivity {
my ($id, $starttime) = (@_); my ($id, $starttime) = (@_);
my $datepart = ""; my $datepart = "";
die "Invalid id: $id" unless $id=~/^\s*\d+\s*$/;
if (defined $starttime) { if (defined $starttime) {
$datepart = "and bugs_activity.bug_when >= $starttime"; $datepart = "and bugs_activity.bug_when >= $starttime";
} }
......
...@@ -170,6 +170,7 @@ sub GenerateSQL { ...@@ -170,6 +170,7 @@ sub GenerateSQL {
} }
if (defined $F{'sql'}) { if (defined $F{'sql'}) {
die "Invalid sql: $F{'sql'}" if $F{'sql'} =~ /;/;
push(@wherepart, "( $F{'sql'} )"); push(@wherepart, "( $F{'sql'} )");
} }
...@@ -887,6 +888,8 @@ if (defined $::FORM{'order'} && $::FORM{'order'} ne "") { ...@@ -887,6 +888,8 @@ if (defined $::FORM{'order'} && $::FORM{'order'} ne "") {
$::FORM{'order'} =~ s/assign\.login_name/map_assigned_to.login_name/g; $::FORM{'order'} =~ s/assign\.login_name/map_assigned_to.login_name/g;
# Another backwards compatability hack. # Another backwards compatability hack.
die "Invalid order: $::FORM{'order'}" unless
$::FORM{'order'} =~ /^([a-zA-Z0-9_., ]+)$/;
ORDER: for ($::FORM{'order'}) { ORDER: for ($::FORM{'order'}) {
/\./ && do { /\./ && do {
# This (hopefully) already has fieldnames in it, so we're done. # This (hopefully) already has fieldnames in it, so we're done.
......
...@@ -41,6 +41,7 @@ confirm_login(); ...@@ -41,6 +41,7 @@ confirm_login();
print "Content-type: text/html\n\n"; print "Content-type: text/html\n\n";
my $id = $::FORM{'id'}; my $id = $::FORM{'id'};
die "invalid id: $id" unless $id=~/^\s*\d+\s*$/;
PutHeader("Create an attachment", "Create attachment", "Bug $id"); PutHeader("Create an attachment", "Create attachment", "Bug $id");
......
...@@ -206,7 +206,7 @@ and bugs.reporter = report.userid ...@@ -206,7 +206,7 @@ and bugs.reporter = report.userid
FIN FIN
if( $::FORM{'product'} ne "-All-" ) { if( $::FORM{'product'} ne "-All-" ) {
$query .= "and bugs.product='$::FORM{'product'}'"; $query .= "and bugs.product=".SqlQuote($::FORM{'product'});
} }
$query .= <<FIN; $query .= <<FIN;
...@@ -572,7 +572,7 @@ sub most_doomed_for_milestone ...@@ -572,7 +572,7 @@ sub most_doomed_for_milestone
my $query; my $query;
$query = "select distinct assigned_to from bugs where target_milestone=\"$ms\""; $query = "select distinct assigned_to from bugs where target_milestone=\"$ms\"";
if( $::FORM{'product'} ne "-All-" ) { if( $::FORM{'product'} ne "-All-" ) {
$query .= "and bugs.product='$::FORM{'product'}'"; $query .= "and bugs.product=".SqlQuote($::FORM{'product'});
} }
$query .= <<FIN; $query .= <<FIN;
and and
...@@ -600,7 +600,7 @@ FIN ...@@ -600,7 +600,7 @@ FIN
{ {
my $query = "select count(bug_id) from bugs,profiles where target_milestone=\"$ms\" and userid=assigned_to and userid=\"$person\""; my $query = "select count(bug_id) from bugs,profiles where target_milestone=\"$ms\" and userid=assigned_to and userid=\"$person\"";
if( $::FORM{'product'} ne "-All-" ) { if( $::FORM{'product'} ne "-All-" ) {
$query .= "and bugs.product='$::FORM{'product'}'"; $query .= "and bugs.product=".SqlQuote($::FORM{'product'})";
} }
$query .= <<FIN; $query .= <<FIN;
and and
...@@ -696,7 +696,7 @@ sub most_recently_doomed ...@@ -696,7 +696,7 @@ sub most_recently_doomed
my $query; my $query;
$query = "select distinct assigned_to from bugs where bugs.bug_status='NEW' and target_milestone='' and bug_severity!='enhancement' and status_whiteboard='' and (product='Browser' or product='MailNews')"; $query = "select distinct assigned_to from bugs where bugs.bug_status='NEW' and target_milestone='' and bug_severity!='enhancement' and status_whiteboard='' and (product='Browser' or product='MailNews')";
if( $::FORM{'product'} ne "-All-" ) { if( $::FORM{'product'} ne "-All-" ) {
$query .= "and bugs.product='$::FORM{'product'}'"; $query .= "and bugs.product=".SqlQuote($::FORM{'product'});
} }
# End build up $query string # End build up $query string
......
...@@ -29,7 +29,7 @@ ConnectToDatabase(); ...@@ -29,7 +29,7 @@ ConnectToDatabase();
my @row; my @row;
if (defined $::FORM{'attach_id'}) { if (defined $::FORM{'attach_id'}) {
SendSQL("select mimetype, thedata from attachments where attach_id = $::FORM{'attach_id'}"); SendSQL("select mimetype, thedata from attachments where attach_id =".SqlQuote($::FORM{'attach_id'});
@row = FetchSQLData(); @row = FetchSQLData();
} }
if (!@row) { if (!@row) {
......
...@@ -26,6 +26,7 @@ use strict; ...@@ -26,6 +26,7 @@ use strict;
require "CGI.pl"; require "CGI.pl";
my $id = $::FORM{'id'}; my $id = $::FORM{'id'};
die "Invalid id: $id" unless $id =~ /^\s*\d+\s*$/;
my $urlbase = Param("urlbase"); my $urlbase = Param("urlbase");
my %seen; my %seen;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment