From fc6c84024f250cb9e20fff66a00fba8c8bddaacd Mon Sep 17 00:00:00 2001 From: matteo-cristino Date: Thu, 7 Nov 2024 21:41:31 +0100 Subject: [PATCH] fix: cover time import overflow corner case in wasm --- src/zen_time.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/zen_time.c b/src/zen_time.c index 33c92c341..5d69c2636 100644 --- a/src/zen_time.c +++ b/src/zen_time.c @@ -90,10 +90,14 @@ ztime_t* time_arg(lua_State *L, int n) { free(result); lerror(L, "Could not read unix timestamp %s", arg); return NULL; - } else if (l_result < INT_MIN || l_result > INT_MAX) { - free(result); - lerror(L, "Could not read unix timestamp %s out of range", arg); - return NULL; + } else { + char s_result[1024]; + snprintf(s_result, 1024, "%ld", l_result); + if (l_result < INT_MIN || l_result > INT_MAX || strcmp(s_result, arg) != 0 ) { + free(result); + lerror(L, "Could not read unix timestamp %s out of range", arg); + return NULL; + } } *result = (ztime_t)l_result; goto end;