mirror of
https://github.com/pi-hole/web.git
synced 2024-12-06 19:36:21 +01:00
Finalize sub-queries to ensure we're not running out of memory with hundreds of clients (can result in O(N^2) memory requirements).
Signed-off-by: DL6ER <dl6er@dl6er.de>
This commit is contained in:
@@ -69,17 +69,20 @@ if(isset($_GET["network"]) && $auth)
|
||||
$network_addresses = $db->query("SELECT ip FROM network_addresses WHERE network_id = $id ORDER BY lastSeen DESC");
|
||||
while($network_addresses !== false && $ip = $network_addresses->fetchArray(SQLITE3_ASSOC))
|
||||
array_push($res["ip"],$ip["ip"]);
|
||||
$network_addresses->finalize();
|
||||
|
||||
// Get list of host names for this device
|
||||
$res["name"] = array();
|
||||
$network_names = $db->query("SELECT name FROM network_names WHERE network_id = $id ORDER BY lastSeen DESC");
|
||||
while($network_names !== false && $ip = $network_names->fetchArray(SQLITE3_ASSOC))
|
||||
array_push($res["name"],utf8_encode($ip["name"]));
|
||||
$network_names->finalize();
|
||||
|
||||
// UTF-8 encode vendor
|
||||
$res["macVendor"] = utf8_encode($res["macVendor"]);
|
||||
array_push($network, $res);
|
||||
}
|
||||
$results->finalize();
|
||||
|
||||
$data = array_merge($data, array('network' => $network));
|
||||
}
|
||||
|
||||
@@ -194,6 +194,7 @@ if ($_POST['action'] == 'get_groups') {
|
||||
while ($gres = $group_query->fetchArray(SQLITE3_ASSOC)) {
|
||||
array_push($groups, $gres['group_id']);
|
||||
}
|
||||
$group_query->finalize();
|
||||
$res['groups'] = $groups;
|
||||
array_push($data, $res);
|
||||
}
|
||||
@@ -222,6 +223,7 @@ if ($_POST['action'] == 'get_groups') {
|
||||
while ($res_names = $query_names->fetchArray(SQLITE3_ASSOC)) {
|
||||
array_push($names, utf8_encode($res_names["name"]));
|
||||
}
|
||||
$query_names->finalize();
|
||||
$extrainfo = "";
|
||||
// Add device vendor to info string (if available)
|
||||
if (strlen($res["macVendor"]) > 0) {
|
||||
|
||||
Reference in New Issue
Block a user