From 878c29cdc5a912e197575213c15e3dc1ffadb7ac Mon Sep 17 00:00:00 2001 From: DavidKorczynski Date: Wed, 10 Mar 2021 20:23:39 +0000 Subject: [PATCH] utils: fix integer overflow (#3206) Signed-off-by: davkor --- src/flb_utils.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/flb_utils.c b/src/flb_utils.c index ba950eed362..ac5b0ae8d69 100644 --- a/src/flb_utils.c +++ b/src/flb_utils.c @@ -453,6 +453,10 @@ int64_t flb_utils_hex2int(char *hex, int len) char c; while ((c = *hex++) && i < len) { + /* Ensure no overflow */ + if (res >= 0xccccccccccccd00) { + return -1; + } res *= 0x10; if (c >= 'a' && c <= 'f') {