From 3fcb9c44efe4a2edd3c3f0e1071dbefd58e3ba8a Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Thu, 3 Jun 2021 11:40:27 +0200 Subject: [PATCH] spa: use strtoull for atou32 On machines with a 32 bits long, converting a negative value will still result in v == (uint32_t)v and the unit test will fail. Extend to 64 bits and strtoull to reject negative values in atou32. --- spa/include/spa/utils/string.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spa/include/spa/utils/string.h b/spa/include/spa/utils/string.h index 22afb6629..728ba9f2e 100644 --- a/spa/include/spa/utils/string.h +++ b/spa/include/spa/utils/string.h @@ -100,13 +100,13 @@ static inline bool spa_atoi32(const char *str, int32_t *val, int base) static inline bool spa_atou32(const char *str, uint32_t *val, int base) { char *endptr; - unsigned long v; + unsigned long long v; if (!str || *str =='\0') return false; errno = 0; - v = strtoul(str, &endptr, base); + v = strtoull(str, &endptr, base); if (errno != 0 || *endptr != '\0') return false;