From d992e929f4471df9d5f29d417685a9ed1c94e3f5 Mon Sep 17 00:00:00 2001 From: DL6ER Date: Wed, 22 Nov 2023 22:49:20 +0100 Subject: [PATCH] Fix possible race-collision leading to a theoretical out-of-bounds read Signed-off-by: DL6ER --- src/database/network-table.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/database/network-table.c b/src/database/network-table.c index 85c0b8d3..94c34775 100644 --- a/src/database/network-table.c +++ b/src/database/network-table.c @@ -760,7 +760,7 @@ static int update_netDB_interface(sqlite3 *db, const int network_id, const char // Loop over all clients known to FTL and ensure we add them all to the database static bool add_FTL_clients_to_network_table(sqlite3 *db, enum arp_status *client_status, time_t now, - unsigned int *additional_entries) + unsigned int *additional_entries, int num_clients) { // Return early if database is known to be broken if(FTLDBerror()) @@ -768,7 +768,7 @@ static bool add_FTL_clients_to_network_table(sqlite3 *db, enum arp_status *clien int rc = SQLITE_OK; char hwaddr[128]; - for(int clientID = 0; clientID < counters->clients; clientID++) + for(int clientID = 0; clientID < num_clients; clientID++) { // Check thread cancellation if(killed) @@ -1536,7 +1536,7 @@ void parse_neighbor_cache(sqlite3* db) // Loop over all clients known to FTL and ensure we add them all to the // database - if(!add_FTL_clients_to_network_table(db, client_status, now, &additional_entries)) + if(!add_FTL_clients_to_network_table(db, client_status, now, &additional_entries, clients)) return; // Check thread cancellation