Skip to content

Commit

Permalink
Limit maximal number of rows in QBE
Browse files Browse the repository at this point in the history
User would be lost in them anyway by that count and it prevents DOS.

Signed-off-by: Michal Čihař <michal@cihar.com>
  • Loading branch information
nijel committed Aug 18, 2016
1 parent 3ef6201 commit 45e33d6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
5 changes: 4 additions & 1 deletion libraries/DbQbe.php
Original file line number Diff line number Diff line change
Expand Up @@ -1940,7 +1940,10 @@ private function _initializeCriteriasCount()
// sets row count
$rows = PMA_ifSetOr($_REQUEST['rows'], 0, 'numeric');
$criteriaRowAdd = PMA_ifSetOr($_REQUEST['criteriaRowAdd'], 0, 'numeric');
$this->_criteria_row_count = max($rows + $criteriaRowAdd, 0);
$this->_criteria_row_count = min(
100,
max($rows + $criteriaRowAdd, 0)
);

return $criteriaColumnCount;
}
Expand Down
10 changes: 10 additions & 0 deletions libraries/SavedSearches.php
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,16 @@ public function setCriterias($criterias, $json = false)
}
}

/* Limit amount of rows */
if (!isset($data['rows'])) {
$data['rows'] = 0;
} else {
$data['rows'] = min(
max(0, intval($data['rows'])),
100
);
}

for ($i = 0; $i <= $data['rows']; $i++) {
$data['Or' . $i] = $criterias['Or' . $i];
}
Expand Down

0 comments on commit 45e33d6

Please sign in to comment.