From bf836312041fbcb171b6ba79f5f193d22f150c08 Mon Sep 17 00:00:00 2001 From: Leonardo Alminana Date: Thu, 5 Sep 2024 16:01:11 +0200 Subject: [PATCH] in_elasticsearch: improved buffer size check Signed-off-by: Leonardo Alminana --- plugins/in_elasticsearch/in_elasticsearch_bulk_conn.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/plugins/in_elasticsearch/in_elasticsearch_bulk_conn.c b/plugins/in_elasticsearch/in_elasticsearch_bulk_conn.c index fe6e46fb657..cbab165103b 100644 --- a/plugins/in_elasticsearch/in_elasticsearch_bulk_conn.c +++ b/plugins/in_elasticsearch/in_elasticsearch_bulk_conn.c @@ -116,9 +116,10 @@ static int in_elasticsearch_bulk_conn_event(void *data) } if (NULL != request_end) { - request_len = (size_t)(request_end - conn->buf_data); + request_len = (size_t) ((uintptr_t) request_end - + (uintptr_t) conn->buf_data); - if (0 < (conn->buf_len - request_len)) { + if (request_len < conn->buf_len) { memmove(conn->buf_data, &conn->buf_data[request_len], conn->buf_len - request_len);