From 2259e8fbbc088fe1c2b2e9a7b92b6f05f8b98022 Mon Sep 17 00:00:00 2001 From: Filipe Brandenburger Date: Tue, 17 Apr 2018 22:46:03 -0700 Subject: [PATCH] path-util: Finish DEFAULT_PATH_NULSTR with an extra NUL (#8745) The NULSTR_FOREACH iterator needs to see an empty string at the end, so we need to insert an extra NUL explicitly. Also update PATH0_BIN_SBIN(x) to include an extra NUL terminator, rename it to PATH_BIN_SBIN_NULSTR(x), which is more consistent with the similar CONF_PATHS_NULSTR(x) macro. Fixes: 5008da1ec1cf2cf8c15b702c4052e3a49583095d --- src/basic/path-util.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/basic/path-util.h b/src/basic/path-util.h index 9946853..7ec0a3e 100644 --- a/src/basic/path-util.h +++ b/src/basic/path-util.h @@ -17,23 +17,23 @@ #if HAVE_SPLIT_BIN # define PATH_SBIN_BIN(x) x "sbin:" x "bin" -# define PATH0_SBIN_BIN(x) x "sbin\0" x "bin" +# define PATH_SBIN_BIN_NULSTR(x) x "sbin\0" x "bin\0" #else -# define PATH0_SBIN_BIN(x) x "bin" # define PATH_SBIN_BIN(x) x "bin" +# define PATH_SBIN_BIN_NULSTR(x) x "bin\0" #endif #define DEFAULT_PATH_NORMAL PATH_SBIN_BIN("/usr/local/") ":" PATH_SBIN_BIN("/usr/") -#define DEFAULT_PATH0_NORMAL PATH0_SBIN_BIN("/usr/local/") "\0" PATH0_SBIN_BIN("/usr/") +#define DEFAULT_PATH_NORMAL_NULSTR PATH_SBIN_BIN_NULSTR("/usr/local/") PATH_SBIN_BIN_NULSTR("/usr/") #define DEFAULT_PATH_SPLIT_USR DEFAULT_PATH_NORMAL ":" PATH_SBIN_BIN("/") -#define DEFAULT_PATH0_SPLIT_USR DEFAULT_PATH0_NORMAL "\0" PATH0_SBIN_BIN("/") +#define DEFAULT_PATH_SPLIT_USR_NULSTR DEFAULT_PATH_NORMAL_NULSTR PATH_SBIN_BIN_NULSTR("/") #if HAVE_SPLIT_USR # define DEFAULT_PATH DEFAULT_PATH_SPLIT_USR -# define DEFAULT_PATH_NULSTR DEFAULT_PATH0_SPLIT_USR +# define DEFAULT_PATH_NULSTR DEFAULT_PATH_SPLIT_USR_NULSTR #else # define DEFAULT_PATH DEFAULT_PATH_NORMAL -# define DEFAULT_PATH_NULSTR DEFAULT_PATH0_NORMAL +# define DEFAULT_PATH_NULSTR DEFAULT_PATH_NORMAL_NULSTR #endif bool is_path(const char *p) _pure_; -- 2.7.4