sudo_lbuf_expand: don't allocate less than 256 bytes at a time.

This commit is contained in:
Todd C. Miller
2023-01-04 10:36:09 -07:00
parent dc9ef69021
commit 532023f7b6

View File

@@ -77,9 +77,11 @@ sudo_lbuf_expand(struct sudo_lbuf *lbuf, unsigned int extra)
}
if (lbuf->len + extra + 1 > lbuf->size) {
const unsigned int new_size = sudo_pow2_roundup(lbuf->len + extra + 1);
unsigned int new_size = sudo_pow2_roundup(lbuf->len + extra + 1);
char *new_buf;
if (new_size < 256)
new_size = 256;
if ((new_buf = realloc(lbuf->buf, new_size)) == NULL) {
sudo_debug_printf(SUDO_DEBUG_ERROR|SUDO_DEBUG_LINENO,
"unable to allocate memory");