diff options
author | Todd C. Miller <Todd.Miller@sudo.ws> | 2023-01-04 10:36:09 -0700 |
---|---|---|
committer | Todd C. Miller <Todd.Miller@sudo.ws> | 2023-01-04 10:36:09 -0700 |
commit | 61167e52f9da1f5130ad580ba5a57bd12d78577a (patch) | |
tree | f71381a19c98b284f44ad3061629c2208bdab02c /lib | |
parent | 20a37111dbe6a5a3c58eb77fb678c1b7ef2b4c91 (diff) | |
download | sudo-61167e52f9da1f5130ad580ba5a57bd12d78577a.tar.gz |
sudo_lbuf_expand: don't allocate less than 256 bytes at a time.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/util/lbuf.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/lib/util/lbuf.c b/lib/util/lbuf.c index c2a83760b..34c2a343b 100644 --- a/lib/util/lbuf.c +++ b/lib/util/lbuf.c @@ -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"); |