Handle the case where O_PATH or O_SEARCH is defined but O_DIRECTORY

is not.  In theory, O_DIRECTORY is redundant when O_SEARCH is
specified but it is legal for O_EXEC and O_SEARCH to have the same
value.  Bug #844
This commit is contained in:
Todd C. Miller
2018-08-18 07:06:54 -06:00
parent 288f3f17a6
commit 69541be94a

View File

@@ -379,13 +379,21 @@ done:
* Use O_SEARCH/O_PATH and/or O_DIRECTORY where possible. * Use O_SEARCH/O_PATH and/or O_DIRECTORY where possible.
*/ */
#if defined(O_SEARCH) #if defined(O_SEARCH)
# define DIR_OPEN_FLAGS (O_SEARCH|O_DIRECTORY) # if defined(O_DIRECTORY)
# define DIR_OPEN_FLAGS (O_SEARCH|O_DIRECTORY)
# else
# define DIR_OPEN_FLAGS (O_SEARCH)
# endif
#elif defined(O_PATH) #elif defined(O_PATH)
# define DIR_OPEN_FLAGS (O_PATH|O_DIRECTORY) # if defined(O_DIRECTORY)
# define DIR_OPEN_FLAGS (O_PATH|O_DIRECTORY)
# else
# define DIR_OPEN_FLAGS (O_PATH)
# endif
#elif defined(O_DIRECTORY) #elif defined(O_DIRECTORY)
# define DIR_OPEN_FLAGS (O_RDONLY|O_DIRECTORY) # define DIR_OPEN_FLAGS (O_RDONLY|O_DIRECTORY)
#else #else
# define DIR_OPEN_FLAGS (O_RDONLY|O_NONBLOCK) # define DIR_OPEN_FLAGS (O_RDONLY|O_NONBLOCK)
#endif #endif
static int static int