]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 583690: (CVE-2010-2759) [SECURITY][PostgreSQL] Bugzilla crashes when viewing...
authorFrédéric Buclin <LpSolit@gmail.com>
Wed, 4 Aug 2010 22:17:40 +0000 (00:17 +0200)
committerFrédéric Buclin <LpSolit@gmail.com>
Wed, 4 Aug 2010 22:17:40 +0000 (00:17 +0200)
r=mkanat a=LpSolit

Bugzilla/Constants.pm
Bugzilla/Object.pm
Bugzilla/Template.pm

index 65301cd4ec5f48aad81bcfeccf2f97ae5a2005d6..1c35b46632772e95a3f586fdd9d5426f87e64569 100644 (file)
@@ -147,6 +147,7 @@ use File::Basename;
 
     MIN_SMALLINT
     MAX_SMALLINT
+    MAX_INT_32
 
     MAX_LEN_QUERY_NAME
     MAX_MILESTONE_SIZE
@@ -418,6 +419,7 @@ use constant ON_WINDOWS => ($^O =~ /MSWin32/i);
 
 use constant MIN_SMALLINT => -32768;
 use constant MAX_SMALLINT => 32767;
+use constant MAX_INT_32 => 2147483647;
 
 # The longest that a saved search name can be.
 use constant MAX_LEN_QUERY_NAME => 64;
index 7f39b81f6c4cc5bbbd200ea3aff66e9048ea7a79..614b4f256d747b3a5467eeed8dfefba13f37c5a3 100644 (file)
@@ -73,6 +73,9 @@ sub _init {
           || ThrowCodeError('param_must_be_numeric',
                             {function => $class . '::_init'});
 
+        # Too large integers make PostgreSQL crash.
+        return if $id > MAX_INT_32;
+
         $object = $dbh->selectrow_hashref(qq{
             SELECT $columns FROM $table
              WHERE $id_field = ?}, undef, $id);
@@ -136,6 +139,8 @@ sub new_from_list {
         detaint_natural($id) ||
             ThrowCodeError('param_must_be_numeric',
                           {function => $class . '::new_from_list'});
+        # Too large integers make PostgreSQL crash.
+        next if $id > MAX_INT_32;
         push(@detainted_ids, $id);
     }
     # We don't do $invocant->match because some classes have
index 261a8441a3400c444284601dc2de9748a4e75542..c61b88cb695dae2769ac5747f941d2ea33b6ddcc 100644 (file)
@@ -271,8 +271,8 @@ sub get_attachment_link {
     my ($attachid, $link_text) = @_;
     my $dbh = Bugzilla->dbh;
 
-    detaint_natural($attachid)
-      || die "get_attachment_link() called with non-integer attachment number";
+    (detaint_natural($attachid) && $attachid <= MAX_INT_32)
+      || return $link_text;
 
     my ($bugid, $isobsolete, $desc) =
         $dbh->selectrow_array('SELECT bug_id, isobsolete, description
@@ -320,6 +320,7 @@ sub get_bug_link {
     }
     my $quote_bug_num = html_quote($bug_num);
     detaint_natural($bug_num) || return "&lt;invalid bug number: $quote_bug_num&gt;";
+    ($bug_num <= MAX_INT_32) || return $link_text;
 
     my ($bug_state, $bug_res, $bug_desc) =
         $dbh->selectrow_array('SELECT bugs.bug_status, resolution, short_desc