From: Frédéric Buclin Date: Wed, 4 Aug 2010 22:17:40 +0000 (+0200) Subject: Bug 583690: (CVE-2010-2759) [SECURITY][PostgreSQL] Bugzilla crashes when viewing... X-Git-Tag: bugzilla-3.2.8~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fa02894238ec57af7c7bf27a3ec492185d275a30;p=thirdparty%2Fbugzilla.git Bug 583690: (CVE-2010-2759) [SECURITY][PostgreSQL] Bugzilla crashes when viewing a bug if a comment contains 'bug ' or 'attachment ' where is greater than the max allowed integer r=mkanat a=LpSolit --- diff --git a/Bugzilla/Constants.pm b/Bugzilla/Constants.pm index 65301cd4ec..1c35b46632 100644 --- a/Bugzilla/Constants.pm +++ b/Bugzilla/Constants.pm @@ -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; diff --git a/Bugzilla/Object.pm b/Bugzilla/Object.pm index 7f39b81f6c..614b4f256d 100644 --- a/Bugzilla/Object.pm +++ b/Bugzilla/Object.pm @@ -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 diff --git a/Bugzilla/Template.pm b/Bugzilla/Template.pm index 261a8441a3..c61b88cb69 100644 --- a/Bugzilla/Template.pm +++ b/Bugzilla/Template.pm @@ -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 "<invalid bug number: $quote_bug_num>"; + ($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