Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Make sure limit is never negative
There were some cases where a negative limit could be passed in. Which
would happily make the query explode.

This is just a quick hack to make sure it never is negative.

Signed-off-by: Roeland Jago Douma <[email protected]>
  • Loading branch information
rullzer committed Oct 28, 2019
commit dd185e383d74c3c6e6c186b3f41257a47656260f
10 changes: 10 additions & 0 deletions lib/private/User/Database.php
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,8 @@ public function getDisplayName($uid): string {
* @return array an array of all displayNames (value) and the corresponding uids (key)
*/
public function getDisplayNames($search = '', $limit = null, $offset = null) {
$limit = $this->fixLimit($limit);

$this->fixDI();

$query = $this->dbConn->getQueryBuilder();
Expand Down Expand Up @@ -380,6 +382,8 @@ private function loadUser($uid) {
* @return string[] an array of all uids
*/
public function getUsers($search = '', $limit = null, $offset = null) {
$limit = $this->fixLimit($limit);

$users = $this->getDisplayNames($search, $limit, $offset);
$userIds = array_map(function ($uid) {
return (string)$uid;
Expand Down Expand Up @@ -485,5 +489,11 @@ public function getRealUID(string $uid): string {
return $this->cache[$uid]['uid'];
}

private function fixLimit($limit) {
if (is_int($limit) && $limit >= 0) {
return $limit;
}

return null;
}
}