2
0
mirror of https://github.com/sudo-project/sudo.git synced 2025-08-31 06:15:37 +00:00

When restoring fds traverse list from high -> low, not low -> high

to avoid implicitly closing an fd we want to relocate.
This commit is contained in:
Todd C. Miller
2014-01-14 14:22:04 -07:00
parent d7277fc96e
commit 26cff8bcb5

View File

@@ -166,7 +166,7 @@ closefrom_except(int startfd, struct preserved_fd_list *pfds)
closefrom(startfd);
/* Restore preserved fds and set flags. */
TAILQ_FOREACH(pfd, pfds, entries) {
TAILQ_FOREACH_REVERSE(pfd, pfds, preserved_fd_list, entries) {
if (pfd->lowfd != pfd->highfd) {
if (dup2(pfd->lowfd, pfd->highfd) == -1) {
sudo_debug_printf(SUDO_DEBUG_ERROR|SUDO_DEBUG_LINENO,