From: Todd C. Miller Date: Sat, 18 Aug 2018 13:06:54 +0000 (-0600) Subject: Handle the case where O_PATH or O_SEARCH is defined but O_DIRECTORY X-Git-Tag: SUDO_1_8_24^2~1 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=69541be94a5bffdd9f77263405e814dd636ba516;p=sudo 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 --- diff --git a/src/sudo_edit.c b/src/sudo_edit.c index 7b01fc44b..acf028050 100644 --- a/src/sudo_edit.c +++ b/src/sudo_edit.c @@ -379,13 +379,21 @@ done: * Use O_SEARCH/O_PATH and/or O_DIRECTORY where possible. */ #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) -# 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) -# define DIR_OPEN_FLAGS (O_RDONLY|O_DIRECTORY) +# define DIR_OPEN_FLAGS (O_RDONLY|O_DIRECTORY) #else -# define DIR_OPEN_FLAGS (O_RDONLY|O_NONBLOCK) +# define DIR_OPEN_FLAGS (O_RDONLY|O_NONBLOCK) #endif static int