Skip to content

Commit

Permalink
http_server: api: v1: traces: fix finding inputs by alias.
Browse files Browse the repository at this point in the history
Signed-off-by: Phillip Whelan <phil@calyptia.com>
  • Loading branch information
pwhelan authored and edsiper committed Jun 6, 2024
1 parent 92ba3b6 commit 8035a0a
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions src/http_server/api/v1/trace.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,11 @@ static struct flb_input_instance *find_input(struct flb_hs *hs, const char *name

mk_list_foreach(head, &hs->config->inputs) {
in = mk_list_entry(head, struct flb_input_instance, _head);
if (strlen(in->name) != nlen) {
continue;
}
if (strncmp(name, in->name, nlen) == 0) {
if ((strlen(in->name) == nlen) && (strncmp(name, in->name, nlen) == 0)) {
return in;
}
if (in->alias) {
if (strcmp(name, in->alias) == 0) {
if ((strlen(in->alias) == nlen) && (strncmp(name, in->alias, nlen) == 0)) {
return in;
}
}
Expand Down Expand Up @@ -113,7 +110,7 @@ static int disable_trace_input(struct flb_hs *hs, const char *name, size_t nlen)

static flb_sds_t get_input_name(mk_request_t *request)
{
const char *base = "/api/v1/trace/";
const char base[] = "/api/v1/trace/";


if (request->real_path.data == NULL) {
Expand All @@ -124,7 +121,7 @@ static flb_sds_t get_input_name(mk_request_t *request)
}

return flb_sds_create_len(&request->real_path.data[sizeof(base)-1],
request->real_path.len - sizeof(base)-1);
request->real_path.len - (sizeof(base)-1));
}

static int http_disable_trace(mk_request_t *request, void *data,
Expand Down

0 comments on commit 8035a0a

Please sign in to comment.