From 341f08d7042359776b16f983e8e9c5a4b0909048 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juhani=20Krekel=C3=A4?= Date: Sun, 20 Nov 2022 20:04:39 +0200 Subject: [PATCH] Derive maximum base from number of digits instead of hardcoding --- baseconv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/baseconv.c b/baseconv.c index 33ecad4..5ec5e3d 100644 --- a/baseconv.c +++ b/baseconv.c @@ -9,7 +9,7 @@ static const char digits[] = "0123456789abcdefghijklmnopqrstuvwxyz"; bool baseconv(char outbuf[], size_t bufsize, unsigned base, uintmax_t num) { // Supported bases are 2 to 36 inclusive (though it could be higher // if our digits string was longer - if (base < 2 || base > 36) + if (base < 2 || base > sizeof(digits)) return false; // Longest possible converted string is base-2, where we produce one