diff --git a/libraries/libapparmor/configure.ac b/libraries/libapparmor/configure.ac index 479ba6ddc..73d99398b 100644 --- a/libraries/libapparmor/configure.ac +++ b/libraries/libapparmor/configure.ac @@ -81,7 +81,7 @@ AM_CONDITIONAL(HAVE_RUBY, test x$with_ruby = xyes) AC_HEADER_STDC AC_CHECK_HEADERS(unistd.h stdint.h syslog.h) -AC_CHECK_FUNCS([asprintf __secure_getenv secure_getenv]) +AC_CHECK_FUNCS([asprintf __secure_getenv secure_getenv reallocarray]) AM_PROG_CC_C_O AC_C_CONST diff --git a/libraries/libapparmor/src/private.c b/libraries/libapparmor/src/private.c index bece09d19..218f6628a 100644 --- a/libraries/libapparmor/src/private.c +++ b/libraries/libapparmor/src/private.c @@ -43,6 +43,17 @@ #endif #endif +/** + * Allow libapparmor to build on older glibcs and other libcs that do + * not support reallocarray. + */ +#ifndef HAVE_REALLOCARRY +void *reallocarray(void *ptr, size_t nmemb, size_t size) +{ + return realloc(ptr, nmemb * size); +} +#endif + struct ignored_suffix_t { const char * text; int len;