From 1ba61cd13a5a726f77b35c82598b54d3af387531 Mon Sep 17 00:00:00 2001 From: "Todd C. Miller" Date: Thu, 29 Jun 2023 10:17:39 -0600 Subject: [PATCH] No need to round up to page size with sudo_mmap_alloc(). --- lib/util/snprintf.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/lib/util/snprintf.c b/lib/util/snprintf.c index d081ba09c..8b25e1ed1 100644 --- a/lib/util/snprintf.c +++ b/lib/util/snprintf.c @@ -107,7 +107,7 @@ union arg { }; static int __find_arguments(const char *fmt0, va_list ap, union arg **argtable); -static int __grow_type_table(unsigned char **typetable, long *tablesize); +static int __grow_type_table(unsigned char **typetable, int *tablesize); static int xxxprintf(char **, size_t, int, const char *, va_list); #ifdef PRINTF_WIDE_CHAR @@ -1089,9 +1089,9 @@ __find_arguments(const char *fmt0, va_list ap, union arg **argtable) int flags; /* flags as above */ unsigned char *typetable; /* table of types */ unsigned char stattypetable[STATIC_ARG_TBL_SIZE]; - long tablesize; /* current size of type table */ - long tablemax; /* largest used index in table */ - long nextarg; /* 1-based argument index */ + int tablesize; /* current size of type table */ + int tablemax; /* largest used index in table */ + int nextarg; /* 1-based argument index */ int ret = 0; /* return value */ /* @@ -1421,14 +1421,10 @@ finish: * Increase the size of the type table. */ static int -__grow_type_table(unsigned char **typetable, long *tablesize) +__grow_type_table(unsigned char **typetable, int *tablesize) { unsigned char *oldtable = *typetable; - long newsize = *tablesize * 2; - long size = sysconf(_SC_PAGESIZE); - - if (newsize < size) - newsize = size; + int newsize = *tablesize * 2; if (*tablesize == STATIC_ARG_TBL_SIZE) { *typetable = sudo_mmap_alloc(newsize);