/* Define to 1 if you have the `random' function. */
#undef HAVE_RANDOM
+/* Define to 1 if you have the `reallocarray' function. */
+#undef HAVE_REALLOCARRAY
+
/* Define to 1 if you have the `revoke' function. */
#undef HAVE_REVOKE
as_fn_append ac_header_list " sys/sysmacros.h"
as_fn_append ac_func_list " killpg"
as_fn_append ac_func_list " nl_langinfo"
+as_fn_append ac_func_list " reallocarray"
as_fn_append ac_func_list " strftime"
as_fn_append ac_func_list " tzset"
as_fn_append ac_func_list " seteuid"
+
+
for ac_func in getgrouplist
do :
ac_fn_c_check_func "$LINENO" "getgrouplist" "ac_cv_func_getgrouplist"
dnl Function checks
dnl
AC_FUNC_GETGROUPS
-AC_CHECK_FUNCS_ONCE([killpg nl_langinfo strftime tzset])
+AC_CHECK_FUNCS_ONCE([killpg nl_langinfo reallocarray strftime tzset])
AC_CHECK_FUNCS([getgrouplist], [], [
case "$host_os" in
aix*)
* All libc replacements are prefixed with "sudo_" to avoid namespace issues.
*/
-struct timeval;
+struct passwd;
struct timespec;
#ifndef HAVE_CLOSEFROM
# undef getprogname
# define getprogname() sudo_getprogname()
#endif /* HAVE_GETPROGNAME */
+#ifndef HAVE_REALLOCARRAY
+__dso_public void *sudo_reallocarray(void *ptr, size_t nmemb, size_t size);
+# undef reallocarray
+# define reallocarray(_a, _b, _c) sudo_reallocarray((_a), (_b), (_c))
+#endif /* HAVE_REALLOCARRAY */
#endif /* _SUDO_COMPAT_H */
#elif defined(HAVE_INTTYPES_H)
# include <inttypes.h>
#endif
+#include <errno.h>
#include <limits.h>
#define DEFAULT_TEXT_DOMAIN "sudo"
sudo_fatal_nodebug(NULL);
return len;
}
+
+#ifndef HAVE_REALLOCARRAY
+void *
+sudo_reallocarray(void *ptr, size_t nmemb, size_t size)
+{
+ if (nmemb > SIZE_MAX / size) {
+ errno = EOVERFLOW;
+ return NULL;
+ }
+
+ size *= nmemb;
+ return ptr ? realloc(ptr, size) : malloc(size);
+}
+#endif /* HAVE_REALLOCARRAY */