diff options
Diffstat (limited to 'src/shared')
-rw-r--r-- | src/shared/missing.h | 11 | ||||
-rw-r--r-- | src/shared/selinux-util.c | 1 |
2 files changed, 12 insertions, 0 deletions
diff --git a/src/shared/missing.h b/src/shared/missing.h index 2dc9d842d3..9031119a45 100644 --- a/src/shared/missing.h +++ b/src/shared/missing.h @@ -158,3 +158,14 @@ static inline int name_to_handle_at(int fd, const char *name, struct file_handle #ifndef AT_EMPTY_PATH #define AT_EMPTY_PATH 0x1000 #endif + +#if !HAVE_DECL_STRNDUPA +#define strndupa(s, n) \ + ({ \ + const char *__old = (s); \ + size_t __len = strnlen(__old, (n)); \ + char *__new = (char *)alloca(__len + 1); \ + __new[__len] = '\0'; \ + (char *)memcpy(__new, __old, __len); \ + }) +#endif diff --git a/src/shared/selinux-util.c b/src/shared/selinux-util.c index 4e0866be5f..a18a5a7230 100644 --- a/src/shared/selinux-util.c +++ b/src/shared/selinux-util.c @@ -31,6 +31,7 @@ #include "strv.h" #include "path-util.h" #include "selinux-util.h" +#include "missing.h" #ifdef HAVE_SELINUX DEFINE_TRIVIAL_CLEANUP_FUNC(security_context_t, freecon); |