diff --git a/config.h.in b/config.h.in index 8626973ac..5066ca563 100644 --- a/config.h.in +++ b/config.h.in @@ -848,6 +848,9 @@ /* Define to 1 if you have the `strsignal' function. */ #undef HAVE_STRSIGNAL +/* Define to 1 if you have the `strtoull' function. */ +#undef HAVE_STRTOULL + /* Define to 1 if `d_namlen' is a member of `struct dirent'. */ #undef HAVE_STRUCT_DIRENT_D_NAMLEN diff --git a/configure b/configure index 1a7342d70..fa4469cfb 100755 --- a/configure +++ b/configure @@ -3254,6 +3254,7 @@ as_fn_append ac_func_c_list " nl_langinfo HAVE_NL_LANGINFO" as_fn_append ac_func_c_list " faccessat HAVE_FACCESSAT" as_fn_append ac_func_c_list " wordexp HAVE_WORDEXP" as_fn_append ac_func_c_list " getauxval HAVE_GETAUXVAL" +as_fn_append ac_func_c_list " strtoull HAVE_STRTOULL" as_fn_append ac_func_c_list " seteuid HAVE_SETEUID" # Auxiliary files required by this configure script. @@ -21009,6 +21010,7 @@ done + for ac_func in execvpe do : ac_fn_c_check_func "$LINENO" "execvpe" "ac_cv_func_execvpe" diff --git a/configure.ac b/configure.ac index 85efd8d5f..4744b83fe 100644 --- a/configure.ac +++ b/configure.ac @@ -2560,7 +2560,7 @@ dnl Function checks dnl AC_FUNC_GETGROUPS AC_FUNC_FSEEKO -AC_CHECK_FUNCS_ONCE([fexecve fmemopen killpg nl_langinfo faccessat wordexp getauxval]) +AC_CHECK_FUNCS_ONCE([fexecve fmemopen killpg nl_langinfo faccessat wordexp getauxval strtoull]) AC_CHECK_FUNCS([execvpe], [SUDO_APPEND_INTERCEPT_EXP(execvpe)]) AC_CHECK_FUNCS([pread], [ # pread/pwrite on 32-bit HP-UX 11.x may not support large files diff --git a/plugins/sudoers/defaults.c b/plugins/sudoers/defaults.c index d9eda17f4..869f8230f 100644 --- a/plugins/sudoers/defaults.c +++ b/plugins/sudoers/defaults.c @@ -876,11 +876,16 @@ check_rlimit(const char *str, bool soft) unsigned long long ullval; char *ep; - /* XXX - some systems may lack strtoull() */ errno = 0; +#ifdef HAVE_STRTOULL ullval = strtoull(str, &ep, 10); if (str == ep || (errno == ERANGE && ullval == ULLONG_MAX)) debug_return_bool(false); +#else + ullval = strtoul(str, &ep, 10); + if (str == ep || (errno == ERANGE && ullval == ULONG_MAX)) + debug_return_bool(false); +#endif if (*ep == '\0' || (soft && *ep == ',')) debug_return_bool(true); debug_return_bool(false); diff --git a/src/limits.c b/src/limits.c index 9e1dbb5cf..525e09c82 100644 --- a/src/limits.c +++ b/src/limits.c @@ -457,11 +457,16 @@ store_rlimit(const char *str, rlim_t *val, bool soft) unsigned long long ullval = 0; char *ep; - /* XXX - some systems may lack strtoull() */ errno = 0; +#ifdef HAVE_STRTOULL ullval = strtoull(str, &ep, 10); if (str == ep || (errno == ERANGE && ullval == ULLONG_MAX)) debug_return_bool(false); +#else + ullval = strtoul(str, &ep, 10); + if (str == ep || (errno == ERANGE && ullval == ULONG_MAX)) + debug_return_bool(false); +#endif if (*ep == '\0' || (soft && *ep == ',')) { *val = ullval; debug_return_bool(true);