Skip to content

Commit bfa1ecc

Browse files
committed
Security: Fix SQL injection and likely future similar issues
1 parent 40dd044 commit bfa1ecc

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

main/inc/lib/CoursesAndSessionsCatalog.class.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,8 +215,8 @@ public static function getLimitFilterFromArray($limit)
215215
{
216216
$limitFilter = '';
217217
if (!empty($limit) && is_array($limit)) {
218-
$limitStart = isset($limit['start']) ? $limit['start'] : 0;
219-
$limitLength = isset($limit['length']) ? $limit['length'] : 12;
218+
$limitStart = isset($limit['start']) ? (int) $limit['start'] : 0;
219+
$limitLength = isset($limit['length']) ? (int) $limit['length'] : 12;
220220
$limitFilter = 'LIMIT '.$limitStart.', '.$limitLength;
221221
}
222222

@@ -470,11 +470,13 @@ public static function search_courses($search_term, $limit, $justVisible = false
470470
* @param array $limit
471471
*
472472
* @return array The session list
473+
* @throws Exception
473474
*/
474475
public static function browseSessions($date = null, $limit = [])
475476
{
476477
$em = Database::getManager();
477478
$urlId = api_get_current_access_url_id();
479+
$date = Database::escape_string($date);
478480
$sql = "SELECT s.id FROM session s ";
479481
$sql .= "
480482
INNER JOIN access_url_rel_session ars
@@ -501,6 +503,8 @@ public static function browseSessions($date = null, $limit = [])
501503
}
502504

503505
if (!empty($limit)) {
506+
$limit['start'] = (int) $limit['start'];
507+
$limit['length'] = (int) $limit['length'];
504508
$sql .= "LIMIT {$limit['start']}, {$limit['length']} ";
505509
}
506510

0 commit comments

Comments
 (0)