From 78f7f09028fdd6a5e8e4e4b584749621eaef412f Mon Sep 17 00:00:00 2001 From: Yann E. MORIN" Date: Sat, 7 Dec 2019 17:24:50 -0800 Subject: [PATCH] fix undefined macros in musl musl does not define glibc-specific macros, so use a simple version of the macro when it is not defined. This is very inefficient, however, but copying the code from glibc is not really possible because it is LGPL while libselinux in Public Domain, and we want to avoid license propagation, so this macro is completely written from scratch, and non-optimal. Signed-off-by: "Yann E. MORIN" [Updated for 3.0] Signed-off-by: Adam Duskett diff --git a/src/booleans.c b/src/booleans.c index ffa8d26..8569002 100644 --- a/src/booleans.c +++ b/src/booleans.c @@ -65,6 +65,14 @@ int security_get_boolean_names(char ***names, int *len) goto bad; } +/* Simple (but inefficient) version of _D_ALLOC_NAMLEN when + * building with a C library that misses it (e.g. musl). + * Note: glibc does a strlen on (d)->d_name, so assume it is safe. + */ +#ifndef _D_ALLOC_NAMLEN +#define _D_ALLOC_NAMLEN(d) (strlen((d)->d_name)+1) +#endif + for (i = 0; i < *len; i++) { n[i] = strdup(namelist[i]->d_name); if (!n[i]) { -- 2.23.0