diff --git a/src/api/docs/content/specs/history.yaml b/src/api/docs/content/specs/history.yaml index eac87aeb..4d476665 100644 --- a/src/api/docs/content/specs/history.yaml +++ b/src/api/docs/content/specs/history.yaml @@ -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 diff --git a/src/api/history.c b/src/api/history.c index e0a2de21..51ff712a 100644 --- a/src/api/history.c +++ b/src/api/history.c @@ -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