From 1b06060cbcc4bf637fcdbfec181d738f01dfed46 Mon Sep 17 00:00:00 2001 From: RincewindsHat <12514511+RincewindsHat@users.noreply.github.com> Date: Thu, 23 Nov 2023 00:07:02 +0100 Subject: Fix logic in is_uint64_t to fix type-limit warning diff --git a/plugins/utils.c b/plugins/utils.c index e871c5f..aff1790 100644 --- a/plugins/utils.c +++ b/plugins/utils.c @@ -258,16 +258,25 @@ bool is_int64(char *number, int64_t *target) { */ bool is_uint64(char *number, uint64_t *target) { errno = 0; - uint64_t tmp = strtoll(number, NULL, 10); + char *endptr = { 0 }; + unsigned long long tmp = strtoull(number, &endptr, 10); + if (errno != 0) { return false; } - if (tmp < 0 || tmp > UINT64_MAX) { + + if (*endptr != '\0') { return false; } + + if (tmp > UINT64_MAX) { + return false; + } + if (target != NULL) { - *target = tmp; + *target = (uint64_t)tmp; } + return true; } -- cgit v0.10-9-g596f