Use strtoul() on systems without strtoull().

We can assume that systems without strtoull() have 32-bit resource limits.
This commit is contained in:
Todd C. Miller
2021-11-08 18:21:15 -07:00
parent 74ef983f60
commit 19065cb221
5 changed files with 18 additions and 3 deletions

View File

@@ -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

2
configure vendored
View File

@@ -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"

View File

@@ -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

View File

@@ -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);

View File

@@ -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);