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:
@@ -302,7 +302,7 @@ sudo_lbuf_append_v1(struct sudo_lbuf *lbuf, const char * restrict fmt, ...)
|
||||
num_end++;
|
||||
if (num_end[0] == '$' && num_end[1] == 's' && num_end > num_start) {
|
||||
/* Convert the numeric part to an integer */
|
||||
char numbuf[(((sizeof(int) * 8) + 2) / 3) + 2];
|
||||
char numbuf[STRLEN_MAX_SIGNED(int) + 1];
|
||||
len = (unsigned int)(num_end - num_start);
|
||||
if (len >= sizeof(numbuf)) {
|
||||
errno = EINVAL;
|
||||
|
Reference in New Issue
Block a user