Add reallocarray() for those without it.
This commit is contained in:
@@ -556,6 +556,9 @@
|
|||||||
/* Define to 1 if you have the `random' function. */
|
/* Define to 1 if you have the `random' function. */
|
||||||
#undef HAVE_RANDOM
|
#undef HAVE_RANDOM
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `reallocarray' function. */
|
||||||
|
#undef HAVE_REALLOCARRAY
|
||||||
|
|
||||||
/* Define to 1 if you have the `revoke' function. */
|
/* Define to 1 if you have the `revoke' function. */
|
||||||
#undef HAVE_REVOKE
|
#undef HAVE_REVOKE
|
||||||
|
|
||||||
|
3
configure
vendored
3
configure
vendored
@@ -2653,6 +2653,7 @@ as_fn_append ac_header_list " sys/stropts.h"
|
|||||||
as_fn_append ac_header_list " sys/sysmacros.h"
|
as_fn_append ac_header_list " sys/sysmacros.h"
|
||||||
as_fn_append ac_func_list " killpg"
|
as_fn_append ac_func_list " killpg"
|
||||||
as_fn_append ac_func_list " nl_langinfo"
|
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 " strftime"
|
||||||
as_fn_append ac_func_list " tzset"
|
as_fn_append ac_func_list " tzset"
|
||||||
as_fn_append ac_func_list " seteuid"
|
as_fn_append ac_func_list " seteuid"
|
||||||
@@ -17921,6 +17922,8 @@ done
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
for ac_func in getgrouplist
|
for ac_func in getgrouplist
|
||||||
do :
|
do :
|
||||||
ac_fn_c_check_func "$LINENO" "getgrouplist" "ac_cv_func_getgrouplist"
|
ac_fn_c_check_func "$LINENO" "getgrouplist" "ac_cv_func_getgrouplist"
|
||||||
|
@@ -2395,7 +2395,7 @@ dnl
|
|||||||
dnl Function checks
|
dnl Function checks
|
||||||
dnl
|
dnl
|
||||||
AC_FUNC_GETGROUPS
|
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], [], [
|
AC_CHECK_FUNCS([getgrouplist], [], [
|
||||||
case "$host_os" in
|
case "$host_os" in
|
||||||
aix*)
|
aix*)
|
||||||
|
@@ -368,7 +368,7 @@ __dso_public long long sudo_strtonum(const char *, long long, long long, const c
|
|||||||
* All libc replacements are prefixed with "sudo_" to avoid namespace issues.
|
* All libc replacements are prefixed with "sudo_" to avoid namespace issues.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
struct timeval;
|
struct passwd;
|
||||||
struct timespec;
|
struct timespec;
|
||||||
|
|
||||||
#ifndef HAVE_CLOSEFROM
|
#ifndef HAVE_CLOSEFROM
|
||||||
@@ -479,5 +479,10 @@ __dso_public const char *sudo_getprogname(void);
|
|||||||
# undef getprogname
|
# undef getprogname
|
||||||
# define getprogname() sudo_getprogname()
|
# define getprogname() sudo_getprogname()
|
||||||
#endif /* HAVE_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 */
|
#endif /* _SUDO_COMPAT_H */
|
||||||
|
@@ -48,6 +48,7 @@
|
|||||||
#elif defined(HAVE_INTTYPES_H)
|
#elif defined(HAVE_INTTYPES_H)
|
||||||
# include <inttypes.h>
|
# include <inttypes.h>
|
||||||
#endif
|
#endif
|
||||||
|
#include <errno.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
|
|
||||||
#define DEFAULT_TEXT_DOMAIN "sudo"
|
#define DEFAULT_TEXT_DOMAIN "sudo"
|
||||||
@@ -257,3 +258,17 @@ sudo_evasprintf_v1(char **ret, const char *fmt, va_list args)
|
|||||||
sudo_fatal_nodebug(NULL);
|
sudo_fatal_nodebug(NULL);
|
||||||
return len;
|
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 */
|
||||||
|
Reference in New Issue
Block a user