Only use closefrom_fallback() if no better method exists.
The previous logic was too fragile.
This commit is contained in:
@@ -43,15 +43,11 @@
|
|||||||
# define _POSIX_OPEN_MAX 20
|
# define _POSIX_OPEN_MAX 20
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(HAVE_FCNTL_CLOSEM) && !defined(HAVE_DIRFD)
|
|
||||||
# define sudo_closefrom closefrom_fallback
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Close all file descriptors greater than or equal to lowfd.
|
* Close all file descriptors greater than or equal to lowfd.
|
||||||
* This is the expensive (fallback) method.
|
* This is the expensive (fallback) method.
|
||||||
*/
|
*/
|
||||||
void
|
static void
|
||||||
closefrom_fallback(int lowfd)
|
closefrom_fallback(int lowfd)
|
||||||
{
|
{
|
||||||
long fd, maxfd;
|
long fd, maxfd;
|
||||||
@@ -131,5 +127,12 @@ sudo_closefrom(int lowfd)
|
|||||||
} else
|
} else
|
||||||
closefrom_fallback(lowfd);
|
closefrom_fallback(lowfd);
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
void
|
||||||
|
sudo_closefrom(int lowfd)
|
||||||
|
{
|
||||||
|
closefrom_fallback(lowfd);
|
||||||
|
}
|
||||||
#endif /* HAVE_FCNTL_CLOSEM */
|
#endif /* HAVE_FCNTL_CLOSEM */
|
||||||
|
|
||||||
#endif /* HAVE_CLOSEFROM */
|
#endif /* HAVE_CLOSEFROM */
|
||||||
|
Reference in New Issue
Block a user