Use sudo_strtonum() explicitly instead of via a macro.
This commit is contained in:
@@ -379,11 +379,6 @@ int getdomainname(char *, size_t);
|
|||||||
# endif
|
# endif
|
||||||
#endif /* __hpux && !__LP64__ */
|
#endif /* __hpux && !__LP64__ */
|
||||||
|
|
||||||
/* We use our own strtonum() to get translatable error strings. */
|
|
||||||
__dso_public long long sudo_strtonum(const char *, long long, long long, const char **);
|
|
||||||
#undef strtonum
|
|
||||||
#define strtonum(_a, _b, _c, _d) sudo_strtonum((_a), (_b), (_c), (_d))
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Functions "missing" from libc.
|
* Functions "missing" from libc.
|
||||||
* All libc replacements are prefixed with "sudo_" to avoid namespace issues.
|
* All libc replacements are prefixed with "sudo_" to avoid namespace issues.
|
||||||
|
@@ -246,6 +246,10 @@ __dso_public const char *sudo_strsplit_v1(const char *str, const char *endstr, c
|
|||||||
__dso_public int sudo_strtobool_v1(const char *str);
|
__dso_public int sudo_strtobool_v1(const char *str);
|
||||||
#define sudo_strtobool(_a) sudo_strtobool_v1((_a))
|
#define sudo_strtobool(_a) sudo_strtobool_v1((_a))
|
||||||
|
|
||||||
|
/* strtonum.c */
|
||||||
|
/* Not versioned for historical reasons. */
|
||||||
|
__dso_public long long sudo_strtonum(const char *, long long, long long, const char **);
|
||||||
|
|
||||||
/* strtoid.c */
|
/* strtoid.c */
|
||||||
__dso_public id_t sudo_strtoid_v1(const char *str, const char *sep, char **endp, const char **errstr);
|
__dso_public id_t sudo_strtoid_v1(const char *str, const char *sep, char **endp, const char **errstr);
|
||||||
#define sudo_strtoid(_a, _b, _c, _d) sudo_strtoid_v1((_a), (_b), (_c), (_d))
|
#define sudo_strtoid(_a, _b, _c, _d) sudo_strtoid_v1((_a), (_b), (_c), (_d))
|
||||||
|
@@ -1057,11 +1057,13 @@ strtomode.i: $(srcdir)/strtomode.c $(incdir)/compat/stdbool.h \
|
|||||||
$(CC) -E -o $@ $(CPPFLAGS) $<
|
$(CC) -E -o $@ $(CPPFLAGS) $<
|
||||||
strtomode.plog: strtomode.i
|
strtomode.plog: strtomode.i
|
||||||
rm -f $@; pvs-studio --cfg $(PVS_CFG) --sourcetree-root $(top_srcdir) --skip-cl-exe yes --source-file $(srcdir)/strtomode.c --i-file $< --output-file $@
|
rm -f $@; pvs-studio --cfg $(PVS_CFG) --sourcetree-root $(top_srcdir) --skip-cl-exe yes --source-file $(srcdir)/strtomode.c --i-file $< --output-file $@
|
||||||
strtonum.lo: $(srcdir)/strtonum.c $(incdir)/sudo_compat.h \
|
strtonum.lo: $(srcdir)/strtonum.c $(incdir)/compat/stdbool.h \
|
||||||
$(incdir)/sudo_gettext.h $(top_builddir)/config.h
|
$(incdir)/sudo_compat.h $(incdir)/sudo_gettext.h \
|
||||||
|
$(incdir)/sudo_util.h $(top_builddir)/config.h
|
||||||
$(LIBTOOL) $(LTFLAGS) --mode=compile $(CC) -c -o $@ $(CPPFLAGS) $(CFLAGS) $(ASAN_CFLAGS) $(PIE_CFLAGS) $(SSP_CFLAGS) $(srcdir)/strtonum.c
|
$(LIBTOOL) $(LTFLAGS) --mode=compile $(CC) -c -o $@ $(CPPFLAGS) $(CFLAGS) $(ASAN_CFLAGS) $(PIE_CFLAGS) $(SSP_CFLAGS) $(srcdir)/strtonum.c
|
||||||
strtonum.i: $(srcdir)/strtonum.c $(incdir)/sudo_compat.h \
|
strtonum.i: $(srcdir)/strtonum.c $(incdir)/compat/stdbool.h \
|
||||||
$(incdir)/sudo_gettext.h $(top_builddir)/config.h
|
$(incdir)/sudo_compat.h $(incdir)/sudo_gettext.h \
|
||||||
|
$(incdir)/sudo_util.h $(top_builddir)/config.h
|
||||||
$(CC) -E -o $@ $(CPPFLAGS) $<
|
$(CC) -E -o $@ $(CPPFLAGS) $<
|
||||||
strtonum.plog: strtonum.i
|
strtonum.plog: strtonum.i
|
||||||
rm -f $@; pvs-studio --cfg $(PVS_CFG) --sourcetree-root $(top_srcdir) --skip-cl-exe yes --source-file $(srcdir)/strtonum.c --i-file $< --output-file $@
|
rm -f $@; pvs-studio --cfg $(PVS_CFG) --sourcetree-root $(top_srcdir) --skip-cl-exe yes --source-file $(srcdir)/strtonum.c --i-file $< --output-file $@
|
||||||
|
@@ -39,6 +39,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "sudo_compat.h"
|
#include "sudo_compat.h"
|
||||||
|
#include "sudo_util.h"
|
||||||
#include "pathnames.h"
|
#include "pathnames.h"
|
||||||
|
|
||||||
#ifndef _POSIX_OPEN_MAX
|
#ifndef _POSIX_OPEN_MAX
|
||||||
@@ -116,7 +117,7 @@ sudo_closefrom(int lowfd)
|
|||||||
struct dirent *dent;
|
struct dirent *dent;
|
||||||
while ((dent = readdir(dirp)) != NULL) {
|
while ((dent = readdir(dirp)) != NULL) {
|
||||||
const char *errstr;
|
const char *errstr;
|
||||||
int fd = strtonum(dent->d_name, lowfd, INT_MAX, &errstr);
|
int fd = sudo_strtonum(dent->d_name, lowfd, INT_MAX, &errstr);
|
||||||
if (errstr == NULL && fd != dirfd(dirp)) {
|
if (errstr == NULL && fd != dirfd(dirp)) {
|
||||||
# ifdef __APPLE__
|
# ifdef __APPLE__
|
||||||
/* Avoid potential libdispatch crash when we close its fds. */
|
/* Avoid potential libdispatch crash when we close its fds. */
|
||||||
|
@@ -239,7 +239,7 @@ gai_service(const char *servname, int flags, int *type, unsigned short *port)
|
|||||||
const char *errstr;
|
const char *errstr;
|
||||||
unsigned short value;
|
unsigned short value;
|
||||||
|
|
||||||
value = strtonum(servname, 0, USHRT_MAX, &errstr);
|
value = sudo_strtonum(servname, 0, USHRT_MAX, &errstr);
|
||||||
if (errstr == NULL) {
|
if (errstr == NULL) {
|
||||||
*port = value;
|
*port = value;
|
||||||
} else if (errno == ERANGE) {
|
} else if (errno == ERANGE) {
|
||||||
|
@@ -41,6 +41,7 @@
|
|||||||
#include "sudo_gettext.h" /* must be included before sudo_compat.h */
|
#include "sudo_gettext.h" /* must be included before sudo_compat.h */
|
||||||
|
|
||||||
#include "sudo_compat.h"
|
#include "sudo_compat.h"
|
||||||
|
#include "sudo_util.h"
|
||||||
|
|
||||||
enum strtonum_err {
|
enum strtonum_err {
|
||||||
STN_INITIAL,
|
STN_INITIAL,
|
||||||
|
@@ -410,7 +410,7 @@ set_var_max_groups(const char *strval, const char *conf_file,
|
|||||||
int max_groups;
|
int max_groups;
|
||||||
debug_decl(set_var_max_groups, SUDO_DEBUG_UTIL)
|
debug_decl(set_var_max_groups, SUDO_DEBUG_UTIL)
|
||||||
|
|
||||||
max_groups = strtonum(strval, 1, INT_MAX, NULL);
|
max_groups = sudo_strtonum(strval, 1, INT_MAX, NULL);
|
||||||
if (max_groups <= 0) {
|
if (max_groups <= 0) {
|
||||||
sudo_warnx(U_("invalid max groups \"%s\" in %s, line %u"), strval,
|
sudo_warnx(U_("invalid max groups \"%s\" in %s, line %u"), strval,
|
||||||
conf_file, lineno);
|
conf_file, lineno);
|
||||||
|
@@ -60,11 +60,11 @@ sudo_get_ttysize_v1(int *rowp, int *colp)
|
|||||||
|
|
||||||
/* Fall back on $LINES and $COLUMNS. */
|
/* Fall back on $LINES and $COLUMNS. */
|
||||||
if ((p = getenv("LINES")) == NULL ||
|
if ((p = getenv("LINES")) == NULL ||
|
||||||
(*rowp = strtonum(p, 1, INT_MAX, NULL)) <= 0) {
|
(*rowp = sudo_strtonum(p, 1, INT_MAX, NULL)) <= 0) {
|
||||||
*rowp = 24;
|
*rowp = 24;
|
||||||
}
|
}
|
||||||
if ((p = getenv("COLUMNS")) == NULL ||
|
if ((p = getenv("COLUMNS")) == NULL ||
|
||||||
(*colp = strtonum(p, 1, INT_MAX, NULL)) <= 0) {
|
(*colp = sudo_strtonum(p, 1, INT_MAX, NULL)) <= 0) {
|
||||||
*colp = 80;
|
*colp = 80;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -78,7 +78,7 @@ get_boottime(struct timespec *ts)
|
|||||||
if (strncmp(line, "btime ", 6) == 0) {
|
if (strncmp(line, "btime ", 6) == 0) {
|
||||||
if (line[len - 1] == '\n')
|
if (line[len - 1] == '\n')
|
||||||
line[len - 1] = '\0';
|
line[len - 1] = '\0';
|
||||||
llval = strtonum(line + 6, 1, LLONG_MAX, NULL);
|
llval = sudo_strtonum(line + 6, 1, LLONG_MAX, NULL);
|
||||||
if (llval > 0) {
|
if (llval > 0) {
|
||||||
ts->tv_sec = (time_t)llval;
|
ts->tv_sec = (time_t)llval;
|
||||||
ts->tv_nsec = 0;
|
ts->tv_nsec = 0;
|
||||||
|
@@ -416,7 +416,7 @@ cvtsudoers_parse_keyword(const char *conf_file, const char *keyword,
|
|||||||
case CONF_UINT:
|
case CONF_UINT:
|
||||||
{
|
{
|
||||||
unsigned int uval =
|
unsigned int uval =
|
||||||
strtonum(value, 0, UINT_MAX, &errstr);
|
sudo_strtonum(value, 0, UINT_MAX, &errstr);
|
||||||
if (errstr != NULL) {
|
if (errstr != NULL) {
|
||||||
sudo_warnx(U_("%s: %s: %s: %s"),
|
sudo_warnx(U_("%s: %s: %s: %s"),
|
||||||
conf_file, keyword, value, U_(errstr));
|
conf_file, keyword, value, U_(errstr));
|
||||||
|
@@ -834,7 +834,7 @@ store_int(const char *str, union sudo_defs_val *sd_un)
|
|||||||
if (str == NULL) {
|
if (str == NULL) {
|
||||||
sd_un->ival = 0;
|
sd_un->ival = 0;
|
||||||
} else {
|
} else {
|
||||||
i = strtonum(str, INT_MIN, INT_MAX, &errstr);
|
i = sudo_strtonum(str, INT_MIN, INT_MAX, &errstr);
|
||||||
if (errstr != NULL) {
|
if (errstr != NULL) {
|
||||||
sudo_debug_printf(SUDO_DEBUG_ERROR|SUDO_DEBUG_LINENO,
|
sudo_debug_printf(SUDO_DEBUG_ERROR|SUDO_DEBUG_LINENO,
|
||||||
"%s: %s", str, errstr);
|
"%s: %s", str, errstr);
|
||||||
@@ -855,7 +855,7 @@ store_uint(const char *str, union sudo_defs_val *sd_un)
|
|||||||
if (str == NULL) {
|
if (str == NULL) {
|
||||||
sd_un->uival = 0;
|
sd_un->uival = 0;
|
||||||
} else {
|
} else {
|
||||||
u = strtonum(str, 0, UINT_MAX, &errstr);
|
u = sudo_strtonum(str, 0, UINT_MAX, &errstr);
|
||||||
if (errstr != NULL) {
|
if (errstr != NULL) {
|
||||||
sudo_debug_printf(SUDO_DEBUG_ERROR|SUDO_DEBUG_LINENO,
|
sudo_debug_printf(SUDO_DEBUG_ERROR|SUDO_DEBUG_LINENO,
|
||||||
"%s: %s", str, errstr);
|
"%s: %s", str, errstr);
|
||||||
|
@@ -206,7 +206,7 @@ io_set_max_sessid(const char *maxval)
|
|||||||
unsigned int value;
|
unsigned int value;
|
||||||
debug_decl(io_set_max_sessid, SUDOERS_DEBUG_UTIL)
|
debug_decl(io_set_max_sessid, SUDOERS_DEBUG_UTIL)
|
||||||
|
|
||||||
value = strtonum(maxval, 0, SESSID_MAX, &errstr);
|
value = sudo_strtonum(maxval, 0, SESSID_MAX, &errstr);
|
||||||
if (errstr != NULL) {
|
if (errstr != NULL) {
|
||||||
if (errno != ERANGE) {
|
if (errno != ERANGE) {
|
||||||
sudo_debug_printf(SUDO_DEBUG_ERROR|SUDO_DEBUG_LINENO,
|
sudo_debug_printf(SUDO_DEBUG_ERROR|SUDO_DEBUG_LINENO,
|
||||||
@@ -611,7 +611,8 @@ iolog_deserialize_info(struct iolog_details *details, char * const user_info[],
|
|||||||
switch (**cur) {
|
switch (**cur) {
|
||||||
case 'c':
|
case 'c':
|
||||||
if (strncmp(*cur, "cols=", sizeof("cols=") - 1) == 0) {
|
if (strncmp(*cur, "cols=", sizeof("cols=") - 1) == 0) {
|
||||||
int n = strtonum(*cur + sizeof("cols=") - 1, 1, INT_MAX, NULL);
|
int n = sudo_strtonum(*cur + sizeof("cols=") - 1, 1, INT_MAX,
|
||||||
|
NULL);
|
||||||
if (n > 0)
|
if (n > 0)
|
||||||
details->cols = n;
|
details->cols = n;
|
||||||
continue;
|
continue;
|
||||||
@@ -623,7 +624,8 @@ iolog_deserialize_info(struct iolog_details *details, char * const user_info[],
|
|||||||
break;
|
break;
|
||||||
case 'l':
|
case 'l':
|
||||||
if (strncmp(*cur, "lines=", sizeof("lines=") - 1) == 0) {
|
if (strncmp(*cur, "lines=", sizeof("lines=") - 1) == 0) {
|
||||||
int n = strtonum(*cur + sizeof("lines=") - 1, 1, INT_MAX, NULL);
|
int n = sudo_strtonum(*cur + sizeof("lines=") - 1, 1, INT_MAX,
|
||||||
|
NULL);
|
||||||
if (n > 0)
|
if (n > 0)
|
||||||
details->lines = n;
|
details->lines = n;
|
||||||
continue;
|
continue;
|
||||||
|
@@ -109,7 +109,7 @@ parse_logfile(const char *logfile)
|
|||||||
goto bad;
|
goto bad;
|
||||||
}
|
}
|
||||||
*ep = '\0';
|
*ep = '\0';
|
||||||
li->tstamp = strtonum(cp, 0, TIME_T_MAX, &errstr);
|
li->tstamp = sudo_strtonum(cp, 0, TIME_T_MAX, &errstr);
|
||||||
if (errstr != NULL) {
|
if (errstr != NULL) {
|
||||||
sudo_warn(U_("%s: time stamp %s: %s"), logfile, cp, errstr);
|
sudo_warn(U_("%s: time stamp %s: %s"), logfile, cp, errstr);
|
||||||
goto bad;
|
goto bad;
|
||||||
@@ -155,18 +155,19 @@ parse_logfile(const char *logfile)
|
|||||||
if ((li->tty = strndup(cp, (size_t)(ep - cp))) == NULL)
|
if ((li->tty = strndup(cp, (size_t)(ep - cp))) == NULL)
|
||||||
sudo_fatalx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
|
sudo_fatalx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
|
||||||
cp = ep + 1;
|
cp = ep + 1;
|
||||||
/* need to NULL out separator to use strtonum() */
|
/* need to NULL out separator to use sudo_strtonum() */
|
||||||
|
/* XXX - use sudo_strtonumx */
|
||||||
if ((ep = strchr(cp, ':')) != NULL) {
|
if ((ep = strchr(cp, ':')) != NULL) {
|
||||||
*ep = '\0';
|
*ep = '\0';
|
||||||
}
|
}
|
||||||
li->rows = strtonum(cp, 1, INT_MAX, &errstr);
|
li->rows = sudo_strtonum(cp, 1, INT_MAX, &errstr);
|
||||||
if (errstr != NULL) {
|
if (errstr != NULL) {
|
||||||
sudo_debug_printf(SUDO_DEBUG_ERROR|SUDO_DEBUG_LINENO,
|
sudo_debug_printf(SUDO_DEBUG_ERROR|SUDO_DEBUG_LINENO,
|
||||||
"%s: tty rows %s: %s", logfile, cp, errstr);
|
"%s: tty rows %s: %s", logfile, cp, errstr);
|
||||||
}
|
}
|
||||||
if (ep != NULL) {
|
if (ep != NULL) {
|
||||||
cp = ep + 1;
|
cp = ep + 1;
|
||||||
li->cols = strtonum(cp, 1, INT_MAX, &errstr);
|
li->cols = sudo_strtonum(cp, 1, INT_MAX, &errstr);
|
||||||
if (errstr != NULL) {
|
if (errstr != NULL) {
|
||||||
sudo_debug_printf(SUDO_DEBUG_ERROR|SUDO_DEBUG_LINENO,
|
sudo_debug_printf(SUDO_DEBUG_ERROR|SUDO_DEBUG_LINENO,
|
||||||
"%s: tty cols %s: %s", logfile, cp, errstr);
|
"%s: tty cols %s: %s", logfile, cp, errstr);
|
||||||
@@ -240,7 +241,7 @@ parse_delay(const char *cp, struct timespec *delay, const char *decimal_point)
|
|||||||
}
|
}
|
||||||
memcpy(numbuf, cp, len);
|
memcpy(numbuf, cp, len);
|
||||||
numbuf[len] = '\0';
|
numbuf[len] = '\0';
|
||||||
delay->tv_sec = strtonum(numbuf, 0, TIME_T_MAX, &errstr);
|
delay->tv_sec = sudo_strtonum(numbuf, 0, TIME_T_MAX, &errstr);
|
||||||
if (errstr != NULL) {
|
if (errstr != NULL) {
|
||||||
sudo_debug_printf(SUDO_DEBUG_ERROR|SUDO_DEBUG_LINENO,
|
sudo_debug_printf(SUDO_DEBUG_ERROR|SUDO_DEBUG_LINENO,
|
||||||
"%s: number of seconds is %s", numbuf, errstr);
|
"%s: number of seconds is %s", numbuf, errstr);
|
||||||
@@ -266,7 +267,7 @@ parse_delay(const char *cp, struct timespec *delay, const char *decimal_point)
|
|||||||
}
|
}
|
||||||
memcpy(numbuf, cp, len);
|
memcpy(numbuf, cp, len);
|
||||||
numbuf[len] = '\0';
|
numbuf[len] = '\0';
|
||||||
llval = strtonum(numbuf, 0, LLONG_MAX, &errstr);
|
llval = sudo_strtonum(numbuf, 0, LLONG_MAX, &errstr);
|
||||||
if (errstr != NULL) {
|
if (errstr != NULL) {
|
||||||
sudo_debug_printf(SUDO_DEBUG_ERROR|SUDO_DEBUG_LINENO,
|
sudo_debug_printf(SUDO_DEBUG_ERROR|SUDO_DEBUG_LINENO,
|
||||||
"%s: number of nanoseconds is %s", numbuf, errstr);
|
"%s: number of nanoseconds is %s", numbuf, errstr);
|
||||||
|
@@ -430,7 +430,8 @@ sudo_ldap_parse_keyword(const char *keyword, const char *value,
|
|||||||
*(int *)(cur->valp) = sudo_strtobool(value) == true;
|
*(int *)(cur->valp) = sudo_strtobool(value) == true;
|
||||||
break;
|
break;
|
||||||
case CONF_INT:
|
case CONF_INT:
|
||||||
*(int *)(cur->valp) = strtonum(value, INT_MIN, INT_MAX, &errstr);
|
*(int *)(cur->valp) = sudo_strtonum(value, INT_MIN, INT_MAX,
|
||||||
|
&errstr);
|
||||||
if (errstr != NULL) {
|
if (errstr != NULL) {
|
||||||
sudo_warnx(U_("%s: %s: %s: %s"),
|
sudo_warnx(U_("%s: %s: %s: %s"),
|
||||||
path_ldap_conf, keyword, value, U_(errstr));
|
path_ldap_conf, keyword, value, U_(errstr));
|
||||||
|
@@ -132,7 +132,7 @@ addr_matches_if_netmask(const char *n, const char *m)
|
|||||||
debug_return_bool(false);
|
debug_return_bool(false);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
i = strtonum(m, 1, 32, &errstr);
|
i = sudo_strtonum(m, 1, 32, &errstr);
|
||||||
if (errstr != NULL) {
|
if (errstr != NULL) {
|
||||||
sudo_debug_printf(SUDO_DEBUG_ERROR|SUDO_DEBUG_LINENO,
|
sudo_debug_printf(SUDO_DEBUG_ERROR|SUDO_DEBUG_LINENO,
|
||||||
"IPv4 netmask %s: %s", m, errstr);
|
"IPv4 netmask %s: %s", m, errstr);
|
||||||
@@ -145,7 +145,7 @@ addr_matches_if_netmask(const char *n, const char *m)
|
|||||||
#ifdef HAVE_STRUCT_IN6_ADDR
|
#ifdef HAVE_STRUCT_IN6_ADDR
|
||||||
else {
|
else {
|
||||||
if (inet_pton(AF_INET6, m, &mask.ip6) != 1) {
|
if (inet_pton(AF_INET6, m, &mask.ip6) != 1) {
|
||||||
j = strtonum(m, 1, 128, &errstr);
|
j = sudo_strtonum(m, 1, 128, &errstr);
|
||||||
if (errstr != NULL) {
|
if (errstr != NULL) {
|
||||||
sudo_debug_printf(SUDO_DEBUG_ERROR|SUDO_DEBUG_LINENO,
|
sudo_debug_printf(SUDO_DEBUG_ERROR|SUDO_DEBUG_LINENO,
|
||||||
"IPv6 netmask %s: %s", m, errstr);
|
"IPv6 netmask %s: %s", m, errstr);
|
||||||
|
@@ -173,7 +173,7 @@ sudoers_policy_deserialize_info(void *v, char **runas_user, char **runas_group)
|
|||||||
if (MATCHES(*cur, "closefrom=")) {
|
if (MATCHES(*cur, "closefrom=")) {
|
||||||
errno = 0;
|
errno = 0;
|
||||||
p = *cur + sizeof("closefrom=") - 1;
|
p = *cur + sizeof("closefrom=") - 1;
|
||||||
user_closefrom = strtonum(p, 4, INT_MAX, &errstr);
|
user_closefrom = sudo_strtonum(p, 4, INT_MAX, &errstr);
|
||||||
if (user_closefrom == 0) {
|
if (user_closefrom == 0) {
|
||||||
sudo_warnx(U_("%s: %s"), *cur, U_(errstr));
|
sudo_warnx(U_("%s: %s"), *cur, U_(errstr));
|
||||||
goto bad;
|
goto bad;
|
||||||
@@ -300,7 +300,7 @@ sudoers_policy_deserialize_info(void *v, char **runas_user, char **runas_group)
|
|||||||
if (MATCHES(*cur, "max_groups=")) {
|
if (MATCHES(*cur, "max_groups=")) {
|
||||||
errno = 0;
|
errno = 0;
|
||||||
p = *cur + sizeof("max_groups=") - 1;
|
p = *cur + sizeof("max_groups=") - 1;
|
||||||
sudo_user.max_groups = strtonum(p, 1, INT_MAX, &errstr);
|
sudo_user.max_groups = sudo_strtonum(p, 1, INT_MAX, &errstr);
|
||||||
if (sudo_user.max_groups == 0) {
|
if (sudo_user.max_groups == 0) {
|
||||||
sudo_warnx(U_("%s: %s"), *cur, U_(errstr));
|
sudo_warnx(U_("%s: %s"), *cur, U_(errstr));
|
||||||
goto bad;
|
goto bad;
|
||||||
@@ -397,7 +397,7 @@ sudoers_policy_deserialize_info(void *v, char **runas_user, char **runas_group)
|
|||||||
if (MATCHES(*cur, "lines=")) {
|
if (MATCHES(*cur, "lines=")) {
|
||||||
errno = 0;
|
errno = 0;
|
||||||
p = *cur + sizeof("lines=") - 1;
|
p = *cur + sizeof("lines=") - 1;
|
||||||
sudo_user.lines = strtonum(p, 1, INT_MAX, &errstr);
|
sudo_user.lines = sudo_strtonum(p, 1, INT_MAX, &errstr);
|
||||||
if (sudo_user.lines == 0) {
|
if (sudo_user.lines == 0) {
|
||||||
sudo_warnx(U_("%s: %s"), *cur, U_(errstr));
|
sudo_warnx(U_("%s: %s"), *cur, U_(errstr));
|
||||||
goto bad;
|
goto bad;
|
||||||
@@ -407,7 +407,7 @@ sudoers_policy_deserialize_info(void *v, char **runas_user, char **runas_group)
|
|||||||
if (MATCHES(*cur, "cols=")) {
|
if (MATCHES(*cur, "cols=")) {
|
||||||
errno = 0;
|
errno = 0;
|
||||||
p = *cur + sizeof("cols=") - 1;
|
p = *cur + sizeof("cols=") - 1;
|
||||||
sudo_user.cols = strtonum(p, 1, INT_MAX, &errstr);
|
sudo_user.cols = sudo_strtonum(p, 1, INT_MAX, &errstr);
|
||||||
if (sudo_user.cols == 0) {
|
if (sudo_user.cols == 0) {
|
||||||
sudo_warnx(U_("%s: %s"), *cur, U_(errstr));
|
sudo_warnx(U_("%s: %s"), *cur, U_(errstr));
|
||||||
goto bad;
|
goto bad;
|
||||||
|
@@ -89,10 +89,10 @@ main(int argc, char *argv[])
|
|||||||
dash = strchr(cp, '-');
|
dash = strchr(cp, '-');
|
||||||
if (dash != NULL) {
|
if (dash != NULL) {
|
||||||
*dash = '\0';
|
*dash = '\0';
|
||||||
len = strtonum(cp, 1, INT_MAX, NULL);
|
len = sudo_strtonum(cp, 1, INT_MAX, NULL);
|
||||||
maxlen = strtonum(dash + 1, 1, INT_MAX, NULL);
|
maxlen = sudo_strtonum(dash + 1, 1, INT_MAX, NULL);
|
||||||
} else {
|
} else {
|
||||||
len = maxlen = strtonum(cp, 1, INT_MAX, NULL);
|
len = maxlen = sudo_strtonum(cp, 1, INT_MAX, NULL);
|
||||||
}
|
}
|
||||||
if (len == 0 || maxlen == 0)
|
if (len == 0 || maxlen == 0)
|
||||||
sudo_fatalx("%s: invalid length on line %d\n", argv[1], lineno);
|
sudo_fatalx("%s: invalid length on line %d\n", argv[1], lineno);
|
||||||
|
@@ -60,7 +60,7 @@ check_addr(char *input)
|
|||||||
cp = input + len;
|
cp = input + len;
|
||||||
while (isspace((unsigned char)*cp))
|
while (isspace((unsigned char)*cp))
|
||||||
cp++;
|
cp++;
|
||||||
expected = strtonum(cp, 0, 1, &errstr);
|
expected = sudo_strtonum(cp, 0, 1, &errstr);
|
||||||
if (errstr != NULL)
|
if (errstr != NULL)
|
||||||
sudo_fatalx("expecting 0 or 1, got %s", cp);
|
sudo_fatalx("expecting 0 or 1, got %s", cp);
|
||||||
input[len] = '\0';
|
input[len] = '\0';
|
||||||
|
@@ -52,7 +52,7 @@ get_now(struct timespec *now)
|
|||||||
buf[strcspn(buf, "\n")] = '\0';
|
buf[strcspn(buf, "\n")] = '\0';
|
||||||
|
|
||||||
/* Boot time is in seconds since the epoch. */
|
/* Boot time is in seconds since the epoch. */
|
||||||
seconds = strtonum(buf + 6, 0, TIME_T_MAX, &errstr);
|
seconds = sudo_strtonum(buf + 6, 0, TIME_T_MAX, &errstr);
|
||||||
if (errstr != NULL)
|
if (errstr != NULL)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
@@ -325,7 +325,7 @@ parse_args(int argc, char **argv, int *nargc, char ***nargv,
|
|||||||
break;
|
break;
|
||||||
case 'C':
|
case 'C':
|
||||||
assert(optarg != NULL);
|
assert(optarg != NULL);
|
||||||
if (strtonum(optarg, 3, INT_MAX, NULL) == 0) {
|
if (sudo_strtonum(optarg, 3, INT_MAX, NULL) == 0) {
|
||||||
sudo_warnx(U_("the argument to -C must be a number greater than or equal to 3"));
|
sudo_warnx(U_("the argument to -C must be a number greater than or equal to 3"));
|
||||||
usage(1);
|
usage(1);
|
||||||
}
|
}
|
||||||
|
@@ -103,7 +103,7 @@ main(int argc, char *argv[], char *envp[])
|
|||||||
const char *errstr;
|
const char *errstr;
|
||||||
|
|
||||||
cp = argv[1] + 9;
|
cp = argv[1] + 9;
|
||||||
fd = strtonum(cp, 0, INT_MAX, &errstr);
|
fd = sudo_strtonum(cp, 0, INT_MAX, &errstr);
|
||||||
if (errstr != NULL)
|
if (errstr != NULL)
|
||||||
sudo_fatalx(U_("invalid file descriptor number: %s"), cp);
|
sudo_fatalx(U_("invalid file descriptor number: %s"), cp);
|
||||||
argv++;
|
argv++;
|
||||||
|
@@ -674,7 +674,7 @@ command_info_to_details(char * const info[], struct command_details *details)
|
|||||||
SET_STRING("cwd=", cwd)
|
SET_STRING("cwd=", cwd)
|
||||||
if (strncmp("closefrom=", info[i], sizeof("closefrom=") - 1) == 0) {
|
if (strncmp("closefrom=", info[i], sizeof("closefrom=") - 1) == 0) {
|
||||||
cp = info[i] + sizeof("closefrom=") - 1;
|
cp = info[i] + sizeof("closefrom=") - 1;
|
||||||
details->closefrom = strtonum(cp, 0, INT_MAX, &errstr);
|
details->closefrom = sudo_strtonum(cp, 0, INT_MAX, &errstr);
|
||||||
if (errstr != NULL)
|
if (errstr != NULL)
|
||||||
sudo_fatalx(U_("%s: %s"), info[i], U_(errstr));
|
sudo_fatalx(U_("%s: %s"), info[i], U_(errstr));
|
||||||
break;
|
break;
|
||||||
@@ -684,7 +684,7 @@ command_info_to_details(char * const info[], struct command_details *details)
|
|||||||
SET_FLAG("exec_background=", CD_EXEC_BG)
|
SET_FLAG("exec_background=", CD_EXEC_BG)
|
||||||
if (strncmp("execfd=", info[i], sizeof("execfd=") - 1) == 0) {
|
if (strncmp("execfd=", info[i], sizeof("execfd=") - 1) == 0) {
|
||||||
cp = info[i] + sizeof("execfd=") - 1;
|
cp = info[i] + sizeof("execfd=") - 1;
|
||||||
details->execfd = strtonum(cp, 0, INT_MAX, &errstr);
|
details->execfd = sudo_strtonum(cp, 0, INT_MAX, &errstr);
|
||||||
if (errstr != NULL)
|
if (errstr != NULL)
|
||||||
sudo_fatalx(U_("%s: %s"), info[i], U_(errstr));
|
sudo_fatalx(U_("%s: %s"), info[i], U_(errstr));
|
||||||
#ifdef HAVE_FEXECVE
|
#ifdef HAVE_FEXECVE
|
||||||
@@ -704,7 +704,8 @@ command_info_to_details(char * const info[], struct command_details *details)
|
|||||||
case 'n':
|
case 'n':
|
||||||
if (strncmp("nice=", info[i], sizeof("nice=") - 1) == 0) {
|
if (strncmp("nice=", info[i], sizeof("nice=") - 1) == 0) {
|
||||||
cp = info[i] + sizeof("nice=") - 1;
|
cp = info[i] + sizeof("nice=") - 1;
|
||||||
details->priority = strtonum(cp, INT_MIN, INT_MAX, &errstr);
|
details->priority = sudo_strtonum(cp, INT_MIN, INT_MAX,
|
||||||
|
&errstr);
|
||||||
if (errstr != NULL)
|
if (errstr != NULL)
|
||||||
sudo_fatalx(U_("%s: %s"), info[i], U_(errstr));
|
sudo_fatalx(U_("%s: %s"), info[i], U_(errstr));
|
||||||
SET(details->flags, CD_SET_PRIORITY);
|
SET(details->flags, CD_SET_PRIORITY);
|
||||||
@@ -799,7 +800,7 @@ command_info_to_details(char * const info[], struct command_details *details)
|
|||||||
case 't':
|
case 't':
|
||||||
if (strncmp("timeout=", info[i], sizeof("timeout=") - 1) == 0) {
|
if (strncmp("timeout=", info[i], sizeof("timeout=") - 1) == 0) {
|
||||||
cp = info[i] + sizeof("timeout=") - 1;
|
cp = info[i] + sizeof("timeout=") - 1;
|
||||||
details->timeout = strtonum(cp, 0, INT_MAX, &errstr);
|
details->timeout = sudo_strtonum(cp, 0, INT_MAX, &errstr);
|
||||||
if (errstr != NULL)
|
if (errstr != NULL)
|
||||||
sudo_fatalx(U_("%s: %s"), info[i], U_(errstr));
|
sudo_fatalx(U_("%s: %s"), info[i], U_(errstr));
|
||||||
SET(details->flags, CD_SET_TIMEOUT);
|
SET(details->flags, CD_SET_TIMEOUT);
|
||||||
|
@@ -235,7 +235,8 @@ get_process_ttyname(char *name, size_t namelen)
|
|||||||
if (*ep == ' ') {
|
if (*ep == ' ') {
|
||||||
*ep = '\0';
|
*ep = '\0';
|
||||||
if (++field == 7) {
|
if (++field == 7) {
|
||||||
int tty_nr = strtonum(cp, INT_MIN, INT_MAX, &errstr);
|
int tty_nr = sudo_strtonum(cp, INT_MIN, INT_MAX,
|
||||||
|
&errstr);
|
||||||
if (errstr) {
|
if (errstr) {
|
||||||
sudo_debug_printf(SUDO_DEBUG_ERROR|SUDO_DEBUG_LINENO,
|
sudo_debug_printf(SUDO_DEBUG_ERROR|SUDO_DEBUG_LINENO,
|
||||||
"%s: tty device %s: %s", path, cp, errstr);
|
"%s: tty device %s: %s", path, cp, errstr);
|
||||||
|
Reference in New Issue
Block a user