Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoeland Jago Douma <roeland@famdouma.nl>2019-10-28 15:07:43 +0300
committerRoeland Jago Douma <roeland@famdouma.nl>2019-10-28 15:07:43 +0300
commitdd185e383d74c3c6e6c186b3f41257a47656260f (patch)
tree4efcada7674fd1c37b36ccd3f7e22989aeb37f5c /lib/private/User
parent921f748996754e59e5b59cc08cc424ff66854730 (diff)
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 <roeland@famdouma.nl>
Diffstat (limited to 'lib/private/User')
-rw-r--r--lib/private/User/Database.php10
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/private/User/Database.php b/lib/private/User/Database.php
index 3db96fa02e2..23dbe8c2334 100644
--- a/lib/private/User/Database.php
+++ b/lib/private/User/Database.php
@@ -259,6 +259,8 @@ class Database extends ABackend
* @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();
@@ -380,6 +382,8 @@ class Database extends ABackend
* @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;
@@ -485,5 +489,11 @@ class Database extends ABackend
return $this->cache[$uid]['uid'];
}
+ private function fixLimit($limit) {
+ if (is_int($limit) && $limit >= 0) {
+ return $limit;
+ }
+ return null;
+ }
}