From e679925bd0c8608ebe24f34917347ad939c6506d Mon Sep 17 00:00:00 2001 From: Alejandro Sirgo Rica Date: Fri, 25 Oct 2024 11:53:22 +0200 Subject: src: add safe_strtoull for safe string to number conversion Add safe_strtoull to validate the execution of strtoull. Definining the base of the number is required becase partition codes are base 16 but they lack the 0x prefix. Replace uses of atoi and strtoull/strtoul and log the conversion errors. --- src/utils.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/utils.h') diff --git a/src/utils.h b/src/utils.h index 45ecf23..288be67 100644 --- a/src/utils.h +++ b/src/utils.h @@ -1,7 +1,10 @@ #ifndef _OG_UTILS_H #define _OG_UTILS_H +#include + void str_toupper(char *str); void str_tolower(char *str); +int safe_strtoull(const char *str, uint64_t *out_value, int base, uint64_t max); #endif -- cgit v1.2.3-18-g5258