Skip to content

Commit

Permalink
Fix SQL injection issues in packages search (librenms#15950)
Browse files Browse the repository at this point in the history
  • Loading branch information
murrant authored Apr 17, 2024
1 parent d7737b9 commit d29201f
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions includes/html/pages/search/packages.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
print_optionbar_end();

if (isset($_POST['results_amount']) && $_POST['results_amount'] > 0) {
$results = $_POST['results'];
$results = (int) $_POST['results_amount'];
} else {
$results = 50;
}
Expand All @@ -70,7 +70,6 @@
<?php

$count_query = 'SELECT COUNT(*) FROM ( ';
$full_query = '';
$query = 'SELECT packages.name FROM packages,devices ';
$param = [];

Expand All @@ -80,7 +79,8 @@
$param = array_merge($param, $device_ids);
}

$query .= " WHERE packages.device_id = devices.device_id AND packages.name LIKE '%" . $_POST['package'] . "%' $sql_where GROUP BY packages.name";
$query .= " WHERE packages.device_id = devices.device_id AND packages.name LIKE ? $sql_where GROUP BY packages.name";
$param[] = '%' . $_POST['package'] . '%';

$where = '';
$ver = '';
Expand All @@ -107,7 +107,7 @@
}

$start = ($page_number - 1) * $results;
$full_query = $full_query . $query . " LIMIT $start,$results";
$full_query = $query . " LIMIT $start,$results";

?>
<tr>
Expand Down

0 comments on commit d29201f

Please sign in to comment.