Move bufsize_roundup() -> sudo_pow2_roundup() in libsudo_util.

This commit is contained in:
Todd C. Miller
2019-11-02 12:03:44 -06:00
parent 676d3fc67b
commit f1d0c99e03
8 changed files with 65 additions and 26 deletions

View File

@@ -186,7 +186,7 @@ read_io_buf(struct client_closure *closure)
/* Expand buf as needed. */
if (timing->u.nbytes > closure->bufsize) {
free(closure->buf);
closure->bufsize = bufsize_roundup(timing->u.nbytes);
closure->bufsize = sudo_pow2_roundup(timing->u.nbytes);
if ((closure->buf = malloc(closure->bufsize)) == NULL) {
sudo_warn(NULL);
timing->u.nbytes = 0;
@@ -228,7 +228,7 @@ fmt_client_message(struct connection_buffer *buf, ClientMessage *msg)
/* Resize buffer as needed. */
if (len > buf->size) {
free(buf->data);
buf->size = bufsize_roundup(len);
buf->size = sudo_pow2_roundup(len);
if ((buf->data = malloc(buf->size)) == NULL) {
sudo_debug_printf(SUDO_DEBUG_ERROR|SUDO_DEBUG_LINENO,
"unable to malloc %u", buf->size);