From: Todd C. Miller Date: Tue, 23 Jun 2015 19:49:56 +0000 (-0600) Subject: Must call round_nfds() with fd+1 since it takes a count not the fd X-Git-Tag: SUDO_1_8_14^2~57 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=d36e46cb6e191f21bcc66f5604825e414e16a9f0;p=sudo Must call round_nfds() with fd+1 since it takes a count not the fd number. In other words, the lowest value is 1, not 0. --- diff --git a/lib/util/sudo_debug.c b/lib/util/sudo_debug.c index 9e1089746..b8efb7586 100644 --- a/lib/util/sudo_debug.c +++ b/lib/util/sudo_debug.c @@ -180,7 +180,7 @@ sudo_debug_new_output(struct sudo_debug_instance *instance, if (sudo_debug_fds_size < output->fd) { /* Bump fds size to the next multiple of 4 * NBBY. */ const int old_size = sudo_debug_fds_size / NBBY; - const int new_size = round_nfds(output->fd) / NBBY; + const int new_size = round_nfds(output->fd + 1) / NBBY; unsigned char *new_fds; new_fds = realloc(sudo_debug_fds, new_size);