Limit the number of clients to return to the number of clients to avoid possible overflows for very large N and add N=0 as special option to return all clients (even if the user does not know how many there are)

Signed-off-by: DL6ER <dl6er@dl6er.de>
This commit is contained in:
DL6ER 2023-12-18 22:47:18 +01:00
parent aa123cacde
commit fa6a8b38e9
No known key found for this signature in database
GPG Key ID: 00135ACBD90B28DD
2 changed files with 7 additions and 1 deletions

View File

@ -199,7 +199,7 @@ components:
clients:
N:
in: query
description: Maximum number of clients to return
description: Maximum number of clients to return, setting this to 0 will return all clients
name: N
schema:
type: integer

View File

@ -73,6 +73,12 @@ int api_history_clients(struct ftl_conn *api)
{
// Does the user request a non-default number of clients
get_uint_var(api->request->query_string, "N", &Nc);
// Limit the number of clients to return to the number of
// clients to avoid possible overflows for very large N
// Also allow N=0 to return all clients
if((int)Nc > counters->clients || Nc == 0)
Nc = counters->clients;
}
// Lock shared memory