summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--plugins/utils.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/plugins/utils.c b/plugins/utils.c
index e871c5f7..aff17906 100644
--- a/plugins/utils.c
+++ b/plugins/utils.c
@@ -258,16 +258,25 @@ bool is_int64(char *number, int64_t *target) {
258 */ 258 */
259bool is_uint64(char *number, uint64_t *target) { 259bool is_uint64(char *number, uint64_t *target) {
260 errno = 0; 260 errno = 0;
261 uint64_t tmp = strtoll(number, NULL, 10); 261 char *endptr = { 0 };
262 unsigned long long tmp = strtoull(number, &endptr, 10);
263
262 if (errno != 0) { 264 if (errno != 0) {
263 return false; 265 return false;
264 } 266 }
265 if (tmp < 0 || tmp > UINT64_MAX) { 267
268 if (*endptr != '\0') {
266 return false; 269 return false;
267 } 270 }
271
272 if (tmp > UINT64_MAX) {
273 return false;
274 }
275
268 if (target != NULL) { 276 if (target != NULL) {
269 *target = tmp; 277 *target = (uint64_t)tmp;
270 } 278 }
279
271 return true; 280 return true;
272} 281}
273 282