Skip to content

Commit

Permalink
Security: Fix SQL injection and likely future similar issues
Browse files Browse the repository at this point in the history
  • Loading branch information
ywarnier committed Dec 17, 2018
1 parent 40dd044 commit bfa1ecc
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions main/inc/lib/CoursesAndSessionsCatalog.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -215,8 +215,8 @@ public static function getLimitFilterFromArray($limit)
{
$limitFilter = '';
if (!empty($limit) && is_array($limit)) {
$limitStart = isset($limit['start']) ? $limit['start'] : 0;
$limitLength = isset($limit['length']) ? $limit['length'] : 12;
$limitStart = isset($limit['start']) ? (int) $limit['start'] : 0;
$limitLength = isset($limit['length']) ? (int) $limit['length'] : 12;
$limitFilter = 'LIMIT '.$limitStart.', '.$limitLength;
}

Expand Down Expand Up @@ -470,11 +470,13 @@ public static function search_courses($search_term, $limit, $justVisible = false
* @param array $limit
*
* @return array The session list
* @throws Exception
*/
public static function browseSessions($date = null, $limit = [])
{
$em = Database::getManager();
$urlId = api_get_current_access_url_id();
$date = Database::escape_string($date);
$sql = "SELECT s.id FROM session s ";
$sql .= "
INNER JOIN access_url_rel_session ars
Expand All @@ -501,6 +503,8 @@ public static function browseSessions($date = null, $limit = [])
}

if (!empty($limit)) {
$limit['start'] = (int) $limit['start'];
$limit['length'] = (int) $limit['length'];
$sql .= "LIMIT {$limit['start']}, {$limit['length']} ";
}

Expand Down

0 comments on commit bfa1ecc

Please sign in to comment.