From de00c08f8a815b3c905b9dc243c68a6cfbc37a6c Mon Sep 17 00:00:00 2001 From: Takahiro Yamashita Date: Sun, 17 Sep 2023 09:36:03 +0900 Subject: [PATCH] uri: not allow negative pos Signed-off-by: Takahiro Yamashita --- src/flb_uri.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/flb_uri.c b/src/flb_uri.c index af6d042a92b..48a8b0d8867 100644 --- a/src/flb_uri.c +++ b/src/flb_uri.c @@ -71,6 +71,11 @@ flb_sds_t flb_uri_encode(const char *uri, size_t len) /* Retrieve a given field based on it expected position in the URI */ struct flb_uri_field *flb_uri_get(struct flb_uri *uri, int pos) { + if (pos < 0) { + flb_trace("[uri] negative pos"); + return NULL; + } + if (pos >= FLB_URI_MAX || pos > uri->count) { flb_trace("[uri] requested position > FLB_URI_MAX"); return NULL;