From: Todd C. Miller Date: Fri, 25 Jul 2014 23:00:10 +0000 (-0600) Subject: If there the preserved fds list is empty, add a new element with X-Git-Tag: SUDO_1_8_11^2~95 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7e5a2397415fd72c3e1813a90aedb348385248fe;p=sudo If there the preserved fds list is empty, add a new element with TAILQ_INSERT_HEAD instead of TAILQ_INSERT_TAIL to avoid an infinite loop on AIX, Solaris and possibly others when debug mode is active. --- diff --git a/src/preserve_fds.c b/src/preserve_fds.c index e96da2913..31921141f 100644 --- a/src/preserve_fds.c +++ b/src/preserve_fds.c @@ -84,7 +84,10 @@ add_preserved_fd(struct preserved_fd_list *pfds, int fd) } } if (pfd == NULL) { - TAILQ_INSERT_TAIL(pfds, pfd_new, entries); + if (TAILQ_EMPTY(pfds)) + TAILQ_INSERT_HEAD(pfds, pfd_new, entries); + else + TAILQ_INSERT_TAIL(pfds, pfd_new, entries); sudo_debug_printf(SUDO_DEBUG_DEBUG|SUDO_DEBUG_LINENO, "preserving fd %d", fd); }