]> granicus.if.org Git - sudo/commitdiff
If there the preserved fds list is empty, add a new element with
authorTodd C. Miller <Todd.Miller@courtesan.com>
Fri, 25 Jul 2014 23:00:10 +0000 (17:00 -0600)
committerTodd C. Miller <Todd.Miller@courtesan.com>
Fri, 25 Jul 2014 23:00:10 +0000 (17:00 -0600)
TAILQ_INSERT_HEAD instead of TAILQ_INSERT_TAIL to avoid an infinite
loop on AIX, Solaris and possibly others when debug mode is active.

src/preserve_fds.c

index e96da2913e1c0a7a40d19a3a37fd3b9b90b22463..31921141f2818d97dc8870bdc857765b50b40840 100644 (file)
@@ -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);
     }