Skip to content

Commit cf09d69

Browse files
committed
http_server: api: v1: traces: fix finding inputs by alias.
Signed-off-by: Phillip Whelan <[email protected]>
1 parent dffcd42 commit cf09d69

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

src/http_server/api/v1/trace.c

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,14 +59,11 @@ static struct flb_input_instance *find_input(struct flb_hs *hs, const char *name
5959

6060
mk_list_foreach(head, &hs->config->inputs) {
6161
in = mk_list_entry(head, struct flb_input_instance, _head);
62-
if (strlen(in->name) != nlen) {
63-
continue;
64-
}
65-
if (strncmp(name, in->name, nlen) == 0) {
62+
if ((strlen(in->name) == nlen) && (strncmp(name, in->name, nlen) == 0)) {
6663
return in;
6764
}
6865
if (in->alias) {
69-
if (strcmp(name, in->alias) == 0) {
66+
if ((strlen(in->alias) == nlen) && (strncmp(name, in->alias, nlen) == 0)) {
7067
return in;
7168
}
7269
}
@@ -113,7 +110,7 @@ static int disable_trace_input(struct flb_hs *hs, const char *name, size_t nlen)
113110

114111
static flb_sds_t get_input_name(mk_request_t *request)
115112
{
116-
const char *base = "/api/v1/trace/";
113+
const char base[] = "/api/v1/trace/";
117114

118115

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

126123
return flb_sds_create_len(&request->real_path.data[sizeof(base)-1],
127-
request->real_path.len - sizeof(base)-1);
124+
request->real_path.len - (sizeof(base)-1));
128125
}
129126

130127
static int http_disable_trace(mk_request_t *request, void *data,

0 commit comments

Comments
 (0)