Add macros to determine the length of an integer type in string form.

Adapted from answer #6 in:
https://stackoverflow.com/questions/10536207/ansi-c-maximum-number-of-characters-printing-a-decimal-int
This commit is contained in:
Todd C. Miller
2023-09-19 15:15:02 -06:00
parent 221a10340c
commit d53bbb54b2
12 changed files with 16 additions and 12 deletions

View File

@@ -399,7 +399,7 @@ log_failure(const struct sudoers_context *ctx, unsigned int status,
static char *
fmt_authfail_message(unsigned int tries)
{
char numbuf[(((sizeof(int) * 8) + 2) / 3) + 2];
char numbuf[STRLEN_MAX_UNSIGNED(unsigned int) + 1];
char *dst, *dst_end, *ret = NULL;
const char *src;
size_t len;