lib/, src/: str2*(): Rename functions and reorder parameters
This makes them compatible with liba2i's functions. Signed-off-by: Alejandro Colomar <alx@kernel.org>
This commit is contained in:
committed by
Serge Hallyn
parent
b085c3f612
commit
f39ac101ff
@@ -8,5 +8,5 @@
|
||||
#include "atoi/str2i.h"
|
||||
|
||||
|
||||
extern inline int getlong(const char *restrict s, long *restrict n);
|
||||
extern inline int getulong(const char *restrict s, unsigned long *restrict n);
|
||||
extern inline int str2sl(long *restrict n, const char *restrict s);
|
||||
extern inline int str2ul(unsigned long *restrict n, const char *restrict s);
|
||||
|
||||
@@ -16,21 +16,21 @@
|
||||
#include "attr.h"
|
||||
|
||||
|
||||
ATTR_STRING(1) ATTR_ACCESS(write_only, 2)
|
||||
inline int getlong(const char *restrict s, long *restrict n);
|
||||
ATTR_STRING(1) ATTR_ACCESS(write_only, 2)
|
||||
inline int getulong(const char *restrict s, unsigned long *restrict n);
|
||||
ATTR_STRING(2) ATTR_ACCESS(write_only, 1)
|
||||
inline int str2sl(long *restrict n, const char *restrict s);
|
||||
ATTR_STRING(2) ATTR_ACCESS(write_only, 1)
|
||||
inline int str2ul(unsigned long *restrict n, const char *restrict s);
|
||||
|
||||
|
||||
inline int
|
||||
getlong(const char *restrict s, long *restrict n)
|
||||
str2sl(long *restrict n, const char *restrict s)
|
||||
{
|
||||
return a2sl(n, s, NULL, 0, LONG_MIN, LONG_MAX);
|
||||
}
|
||||
|
||||
|
||||
inline int
|
||||
getulong(const char *restrict s, unsigned long *restrict n)
|
||||
str2ul(unsigned long *restrict n, const char *restrict s)
|
||||
{
|
||||
return a2ul(n, s, NULL, 0, 0, ULONG_MAX);
|
||||
}
|
||||
|
||||
@@ -246,7 +246,7 @@ int getdef_num (const char *item, int dflt)
|
||||
return dflt;
|
||||
}
|
||||
|
||||
if ( (getlong(d->value, &val) == -1)
|
||||
if ( (str2sl(&val, d->value) == -1)
|
||||
|| (val > INT_MAX)
|
||||
|| (val < -1)) {
|
||||
fprintf (shadow_logfd,
|
||||
@@ -281,7 +281,7 @@ unsigned int getdef_unum (const char *item, unsigned int dflt)
|
||||
return dflt;
|
||||
}
|
||||
|
||||
if ( (getlong(d->value, &val) == -1)
|
||||
if ( (str2sl(&val, d->value) == -1)
|
||||
|| (val < 0)
|
||||
|| (val > INT_MAX)) {
|
||||
fprintf (shadow_logfd,
|
||||
@@ -316,7 +316,7 @@ long getdef_long (const char *item, long dflt)
|
||||
return dflt;
|
||||
}
|
||||
|
||||
if (getlong(d->value, &val) == -1 || val < -1) {
|
||||
if (str2sl(&val, d->value) == -1 || val < -1) {
|
||||
fprintf (shadow_logfd,
|
||||
_("configuration error - cannot parse %s value: '%s'"),
|
||||
item, d->value);
|
||||
@@ -348,7 +348,7 @@ unsigned long getdef_ulong (const char *item, unsigned long dflt)
|
||||
return dflt;
|
||||
}
|
||||
|
||||
if (getulong(d->value, &val) == -1) {
|
||||
if (str2ul(&val, d->value) == -1) {
|
||||
fprintf (shadow_logfd,
|
||||
_("configuration error - cannot parse %s value: '%s'"),
|
||||
item, d->value);
|
||||
|
||||
@@ -51,15 +51,15 @@ struct map_range *get_map_ranges(int ranges, int argc, char **argv)
|
||||
/* Gather up the ranges from the command line */
|
||||
mapping = mappings;
|
||||
for (idx = 0, argidx = 0; idx < ranges; idx++, argidx += 3, mapping++) {
|
||||
if (getulong(argv[argidx + 0], &mapping->upper) == -1) {
|
||||
if (str2ul(&mapping->upper, argv[argidx + 0]) == -1) {
|
||||
free(mappings);
|
||||
return NULL;
|
||||
}
|
||||
if (getulong(argv[argidx + 1], &mapping->lower) == -1) {
|
||||
if (str2ul(&mapping->lower, argv[argidx + 1]) == -1) {
|
||||
free(mappings);
|
||||
return NULL;
|
||||
}
|
||||
if (getulong(argv[argidx + 2], &mapping->count) == -1) {
|
||||
if (str2ul(&mapping->count, argv[argidx + 2]) == -1) {
|
||||
free(mappings);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
14
lib/limits.c
14
lib/limits.c
@@ -61,7 +61,7 @@ static int setrlimit_value (unsigned int resource,
|
||||
limit = RLIM_INFINITY;
|
||||
}
|
||||
else {
|
||||
/* We cannot use getlong here because it fails when there
|
||||
/* We cannot use str2sl() here because it fails when there
|
||||
* is more to the value than just this number!
|
||||
* Also, we are limited to base 10 here (hex numbers will not
|
||||
* work with the limit string parser as is anyway)
|
||||
@@ -93,7 +93,7 @@ static int set_prio (const char *value)
|
||||
{
|
||||
long prio;
|
||||
|
||||
if ( (getlong(value, &prio) == -1)
|
||||
if ( (str2sl(&prio, value) == -1)
|
||||
|| (prio != (int) prio)) {
|
||||
return 0;
|
||||
}
|
||||
@@ -108,7 +108,7 @@ static int set_umask (const char *value)
|
||||
{
|
||||
unsigned long mask;
|
||||
|
||||
if ( (getulong(value, &mask) == -1)
|
||||
if ( (str2ul(&mask, value) == -1)
|
||||
|| (mask != (mode_t) mask)) {
|
||||
return 0;
|
||||
}
|
||||
@@ -123,7 +123,7 @@ static int check_logins (const char *name, const char *maxlogins)
|
||||
{
|
||||
unsigned long limit, count;
|
||||
|
||||
if (getulong(maxlogins, &limit) == -1) {
|
||||
if (str2ul(&limit, maxlogins) == -1) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -486,7 +486,7 @@ void setup_limits (const struct passwd *info)
|
||||
if (strncmp (cp, "pri=", 4) == 0) {
|
||||
long inc;
|
||||
|
||||
if ( (getlong(cp + 4, &inc) == 0)
|
||||
if ( (str2sl(&inc, cp + 4) == 0)
|
||||
&& (inc >= -20) && (inc <= 20)) {
|
||||
errno = 0;
|
||||
if ( (nice (inc) != -1)
|
||||
@@ -504,7 +504,7 @@ void setup_limits (const struct passwd *info)
|
||||
}
|
||||
if (strncmp (cp, "ulimit=", 7) == 0) {
|
||||
long blocks;
|
||||
if ( (getlong(cp + 7, &blocks) == -1)
|
||||
if ( (str2sl(&blocks, cp + 7) == -1)
|
||||
|| (blocks != (int) blocks)
|
||||
|| (set_filesize_limit (blocks) != 0)) {
|
||||
SYSLOG ((LOG_WARN,
|
||||
@@ -516,7 +516,7 @@ void setup_limits (const struct passwd *info)
|
||||
if (strncmp (cp, "umask=", 6) == 0) {
|
||||
unsigned long mask;
|
||||
|
||||
if ( (getulong(cp + 6, &mask) == -1)
|
||||
if ( (str2ul(&mask, cp + 6) == -1)
|
||||
|| (mask != (mode_t) mask)) {
|
||||
SYSLOG ((LOG_WARN,
|
||||
"Can't set umask value for user %s",
|
||||
|
||||
@@ -86,9 +86,8 @@ do_rlogin(const char *remote_host, char *name, size_t namesize, char *term,
|
||||
*cp = '\0';
|
||||
cp++;
|
||||
|
||||
if (getulong(cp, &remote_speed) == -1) {
|
||||
if (str2ul(&remote_speed, cp) == -1)
|
||||
remote_speed = 9600;
|
||||
}
|
||||
}
|
||||
for (i = 0;
|
||||
( (speed_table[i].spd_baud != remote_speed)
|
||||
|
||||
@@ -98,7 +98,7 @@ sgetspent(const char *string)
|
||||
|
||||
if (fields[2][0] == '\0') {
|
||||
spwd.sp_lstchg = -1;
|
||||
} else if ( (getlong(fields[2], &spwd.sp_lstchg) == -1)
|
||||
} else if ( (str2sl(&spwd.sp_lstchg, fields[2]) == -1)
|
||||
|| (spwd.sp_lstchg < 0)) {
|
||||
return NULL;
|
||||
}
|
||||
@@ -109,7 +109,7 @@ sgetspent(const char *string)
|
||||
|
||||
if (fields[3][0] == '\0') {
|
||||
spwd.sp_min = -1;
|
||||
} else if ( (getlong(fields[3], &spwd.sp_min) == -1)
|
||||
} else if ( (str2sl(&spwd.sp_min, fields[3]) == -1)
|
||||
|| (spwd.sp_min < 0)) {
|
||||
return NULL;
|
||||
}
|
||||
@@ -120,7 +120,7 @@ sgetspent(const char *string)
|
||||
|
||||
if (fields[4][0] == '\0') {
|
||||
spwd.sp_max = -1;
|
||||
} else if ( (getlong(fields[4], &spwd.sp_max) == -1)
|
||||
} else if ( (str2sl(&spwd.sp_max, fields[4]) == -1)
|
||||
|| (spwd.sp_max < 0)) {
|
||||
return NULL;
|
||||
}
|
||||
@@ -145,7 +145,7 @@ sgetspent(const char *string)
|
||||
|
||||
if (fields[5][0] == '\0') {
|
||||
spwd.sp_warn = -1;
|
||||
} else if ( (getlong(fields[5], &spwd.sp_warn) == -1)
|
||||
} else if ( (str2sl(&spwd.sp_warn, fields[5]) == -1)
|
||||
|| (spwd.sp_warn < 0)) {
|
||||
return NULL;
|
||||
}
|
||||
@@ -157,7 +157,7 @@ sgetspent(const char *string)
|
||||
|
||||
if (fields[6][0] == '\0') {
|
||||
spwd.sp_inact = -1;
|
||||
} else if ( (getlong(fields[6], &spwd.sp_inact) == -1)
|
||||
} else if ( (str2sl(&spwd.sp_inact, fields[6]) == -1)
|
||||
|| (spwd.sp_inact < 0)) {
|
||||
return NULL;
|
||||
}
|
||||
@@ -169,7 +169,7 @@ sgetspent(const char *string)
|
||||
|
||||
if (fields[7][0] == '\0') {
|
||||
spwd.sp_expire = -1;
|
||||
} else if ( (getlong(fields[7], &spwd.sp_expire) == -1)
|
||||
} else if ( (str2sl(&spwd.sp_expire, fields[7]) == -1)
|
||||
|| (spwd.sp_expire < 0)) {
|
||||
return NULL;
|
||||
}
|
||||
@@ -181,7 +181,7 @@ sgetspent(const char *string)
|
||||
|
||||
if (fields[8][0] == '\0') {
|
||||
spwd.sp_flag = SHADOW_SP_FLAG_UNSET;
|
||||
} else if (getulong(fields[8], &spwd.sp_flag) == -1) {
|
||||
} else if (str2ul(&spwd.sp_flag, fields[8]) == -1) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
14
lib/shadow.c
14
lib/shadow.c
@@ -118,7 +118,7 @@ static struct spwd *my_sgetspent (const char *string)
|
||||
if (fields[2][0] == '\0') {
|
||||
spwd.sp_lstchg = -1;
|
||||
} else {
|
||||
if (getlong(fields[2], &spwd.sp_lstchg) == -1)
|
||||
if (str2sl(&spwd.sp_lstchg, fields[2]) == -1)
|
||||
return 0;
|
||||
if (spwd.sp_lstchg < 0)
|
||||
return 0;
|
||||
@@ -131,7 +131,7 @@ static struct spwd *my_sgetspent (const char *string)
|
||||
if (fields[3][0] == '\0') {
|
||||
spwd.sp_min = -1;
|
||||
} else {
|
||||
if (getlong(fields[3], &spwd.sp_min) == -1)
|
||||
if (str2sl(&spwd.sp_min, fields[3]) == -1)
|
||||
return 0;
|
||||
if (spwd.sp_min < 0)
|
||||
return 0;
|
||||
@@ -144,7 +144,7 @@ static struct spwd *my_sgetspent (const char *string)
|
||||
if (fields[4][0] == '\0') {
|
||||
spwd.sp_max = -1;
|
||||
} else {
|
||||
if (getlong(fields[4], &spwd.sp_max) == -1)
|
||||
if (str2sl(&spwd.sp_max, fields[4]) == -1)
|
||||
return 0;
|
||||
if (spwd.sp_max < 0)
|
||||
return 0;
|
||||
@@ -171,7 +171,7 @@ static struct spwd *my_sgetspent (const char *string)
|
||||
if (fields[5][0] == '\0') {
|
||||
spwd.sp_warn = -1;
|
||||
} else {
|
||||
if (getlong(fields[5], &spwd.sp_warn) == -1)
|
||||
if (str2sl(&spwd.sp_warn, fields[5]) == -1)
|
||||
return 0;
|
||||
if (spwd.sp_warn < 0)
|
||||
return 0;
|
||||
@@ -185,7 +185,7 @@ static struct spwd *my_sgetspent (const char *string)
|
||||
if (fields[6][0] == '\0') {
|
||||
spwd.sp_inact = -1;
|
||||
} else {
|
||||
if (getlong(fields[6], &spwd.sp_inact) == -1)
|
||||
if (str2sl(&spwd.sp_inact, fields[6]) == -1)
|
||||
return 0;
|
||||
if (spwd.sp_inact < 0)
|
||||
return 0;
|
||||
@@ -199,7 +199,7 @@ static struct spwd *my_sgetspent (const char *string)
|
||||
if (fields[7][0] == '\0') {
|
||||
spwd.sp_expire = -1;
|
||||
} else {
|
||||
if (getlong(fields[7], &spwd.sp_expire) == -1)
|
||||
if (str2sl(&spwd.sp_expire, fields[7]) == -1)
|
||||
return 0;
|
||||
if (spwd.sp_expire < 0)
|
||||
return 0;
|
||||
@@ -213,7 +213,7 @@ static struct spwd *my_sgetspent (const char *string)
|
||||
if (fields[8][0] == '\0') {
|
||||
spwd.sp_flag = SHADOW_SP_FLAG_UNSET;
|
||||
} else {
|
||||
if (getulong(fields[8], &spwd.sp_flag) == -1)
|
||||
if (str2ul(&spwd.sp_flag, fields[8]) == -1)
|
||||
return 0;
|
||||
if (spwd.sp_flag < 0)
|
||||
return 0;
|
||||
|
||||
@@ -64,9 +64,8 @@ long strtoday (const char *str)
|
||||
}
|
||||
if (isnum) {
|
||||
long retdate;
|
||||
if (getlong(str, &retdate) == -1) {
|
||||
if (str2sl(&retdate, str) == -1)
|
||||
return -2;
|
||||
}
|
||||
return retdate;
|
||||
}
|
||||
|
||||
|
||||
@@ -108,9 +108,9 @@ subordinate_parse(const char *line)
|
||||
if (i != SUBID_NFIELDS || *fields[0] == '\0' || *fields[1] == '\0' || *fields[2] == '\0')
|
||||
return NULL;
|
||||
range.owner = fields[0];
|
||||
if (getulong(fields[1], &range.start) == -1)
|
||||
if (str2ul(&range.start, fields[1]) == -1)
|
||||
return NULL;
|
||||
if (getulong(fields[2], &range.count) == -1)
|
||||
if (str2ul(&range.count, fields[2]) == -1)
|
||||
return NULL;
|
||||
|
||||
return ⦥
|
||||
|
||||
16
src/chage.c
16
src/chage.c
@@ -171,14 +171,14 @@ static int new_fields (void)
|
||||
|
||||
SNPRINTF(buf, "%ld", mindays);
|
||||
change_field (buf, sizeof buf, _("Minimum Password Age"));
|
||||
if ( (getlong(buf, &mindays) == -1)
|
||||
if ( (str2sl(&mindays, buf) == -1)
|
||||
|| (mindays < -1)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
SNPRINTF(buf, "%ld", maxdays);
|
||||
change_field (buf, sizeof buf, _("Maximum Password Age"));
|
||||
if ( (getlong(buf, &maxdays) == -1)
|
||||
if ( (str2sl(&maxdays, buf) == -1)
|
||||
|| (maxdays < -1)) {
|
||||
return 0;
|
||||
}
|
||||
@@ -201,14 +201,14 @@ static int new_fields (void)
|
||||
|
||||
SNPRINTF(buf, "%ld", warndays);
|
||||
change_field (buf, sizeof buf, _("Password Expiration Warning"));
|
||||
if ( (getlong(buf, &warndays) == -1)
|
||||
if ( (str2sl(&warndays, buf) == -1)
|
||||
|| (warndays < -1)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
SNPRINTF(buf, "%ld", inactdays);
|
||||
change_field (buf, sizeof buf, _("Password Inactive"));
|
||||
if ( (getlong(buf, &inactdays) == -1)
|
||||
if ( (str2sl(&inactdays, buf) == -1)
|
||||
|| (inactdays < -1)) {
|
||||
return 0;
|
||||
}
|
||||
@@ -397,7 +397,7 @@ static void process_flags (int argc, char **argv)
|
||||
break;
|
||||
case 'I':
|
||||
Iflg = true;
|
||||
if ( (getlong(optarg, &inactdays) == -1)
|
||||
if ( (str2sl(&inactdays, optarg) == -1)
|
||||
|| (inactdays < -1)) {
|
||||
fprintf (stderr,
|
||||
_("%s: invalid numeric argument '%s'\n"),
|
||||
@@ -410,7 +410,7 @@ static void process_flags (int argc, char **argv)
|
||||
break;
|
||||
case 'm':
|
||||
mflg = true;
|
||||
if ( (getlong(optarg, &mindays) == -1)
|
||||
if ( (str2sl(&mindays, optarg) == -1)
|
||||
|| (mindays < -1)) {
|
||||
fprintf (stderr,
|
||||
_("%s: invalid numeric argument '%s'\n"),
|
||||
@@ -420,7 +420,7 @@ static void process_flags (int argc, char **argv)
|
||||
break;
|
||||
case 'M':
|
||||
Mflg = true;
|
||||
if ( (getlong(optarg, &maxdays) == -1)
|
||||
if ( (str2sl(&maxdays, optarg) == -1)
|
||||
|| (maxdays < -1)) {
|
||||
fprintf (stderr,
|
||||
_("%s: invalid numeric argument '%s'\n"),
|
||||
@@ -434,7 +434,7 @@ static void process_flags (int argc, char **argv)
|
||||
break;
|
||||
case 'W':
|
||||
Wflg = true;
|
||||
if ( (getlong(optarg, &warndays) == -1)
|
||||
if ( (str2sl(&warndays, optarg) == -1)
|
||||
|| (warndays < -1)) {
|
||||
fprintf (stderr,
|
||||
_("%s: invalid numeric argument '%s'\n"),
|
||||
|
||||
@@ -198,19 +198,19 @@ static void process_flags (int argc, char **argv)
|
||||
}
|
||||
#if defined(USE_SHA_CRYPT)
|
||||
if ( ( ((0 == strcmp (crypt_method, "SHA256")) || (0 == strcmp (crypt_method, "SHA512")))
|
||||
&& (-1 == getlong(optarg, &sha_rounds)))) {
|
||||
&& (-1 == str2sl(&sha_rounds, optarg)))) {
|
||||
bad_s = 1;
|
||||
}
|
||||
#endif /* USE_SHA_CRYPT */
|
||||
#if defined(USE_BCRYPT)
|
||||
if (( (0 == strcmp (crypt_method, "BCRYPT"))
|
||||
&& (-1 == getlong(optarg, &bcrypt_rounds)))) {
|
||||
&& (-1 == str2sl(&bcrypt_rounds, optarg)))) {
|
||||
bad_s = 1;
|
||||
}
|
||||
#endif /* USE_BCRYPT */
|
||||
#if defined(USE_YESCRYPT)
|
||||
if (( (0 == strcmp (crypt_method, "YESCRYPT"))
|
||||
&& (-1 == getlong(optarg, &yescrypt_cost)))) {
|
||||
&& (-1 == str2sl(&yescrypt_cost, optarg)))) {
|
||||
bad_s = 1;
|
||||
}
|
||||
#endif /* USE_YESCRYPT */
|
||||
|
||||
@@ -193,19 +193,19 @@ static void process_flags (int argc, char **argv)
|
||||
bad_s = 0;
|
||||
#if defined(USE_SHA_CRYPT)
|
||||
if ((IS_CRYPT_METHOD("SHA256") || IS_CRYPT_METHOD("SHA512"))
|
||||
&& (-1 == getlong(optarg, &sha_rounds))) {
|
||||
&& (-1 == str2sl(&sha_rounds, optarg))) {
|
||||
bad_s = 1;
|
||||
}
|
||||
#endif /* USE_SHA_CRYPT */
|
||||
#if defined(USE_BCRYPT)
|
||||
if (IS_CRYPT_METHOD("BCRYPT")
|
||||
&& (-1 == getlong(optarg, &bcrypt_rounds))) {
|
||||
&& (-1 == str2sl(&bcrypt_rounds, optarg))) {
|
||||
bad_s = 1;
|
||||
}
|
||||
#endif /* USE_BCRYPT */
|
||||
#if defined(USE_YESCRYPT)
|
||||
if (IS_CRYPT_METHOD("YESCRYPT")
|
||||
&& (-1 == getlong(optarg, &yescrypt_cost))) {
|
||||
&& (-1 == str2sl(&yescrypt_cost, optarg))) {
|
||||
bad_s = 1;
|
||||
}
|
||||
#endif /* USE_YESCRYPT */
|
||||
|
||||
@@ -547,7 +547,7 @@ int main (int argc, char **argv)
|
||||
usage (E_SUCCESS);
|
||||
/*@notreached@*/break;
|
||||
case 'l':
|
||||
if (getlong(optarg, &fail_locktime) == -1) {
|
||||
if (str2sl(&fail_locktime, optarg) == -1) {
|
||||
fprintf (stderr,
|
||||
_("%s: invalid numeric argument '%s'\n"),
|
||||
Prog, optarg);
|
||||
@@ -559,7 +559,7 @@ int main (int argc, char **argv)
|
||||
{
|
||||
long lmax;
|
||||
|
||||
if ( (getlong(optarg, &lmax) == -1)
|
||||
if ( (str2sl(&lmax, optarg) == -1)
|
||||
|| ((long)(short) lmax != lmax)) {
|
||||
fprintf (stderr,
|
||||
_("%s: invalid numeric argument '%s'\n"),
|
||||
@@ -576,7 +576,7 @@ int main (int argc, char **argv)
|
||||
case 'R': /* no-op, handled in process_root_flag () */
|
||||
break;
|
||||
case 't':
|
||||
if (getlong(optarg, &days) == -1) {
|
||||
if (str2sl(&days, optarg) == -1) {
|
||||
fprintf (stderr,
|
||||
_("%s: invalid numeric argument '%s'\n"),
|
||||
Prog, optarg);
|
||||
|
||||
@@ -328,7 +328,7 @@ int main (int argc, char **argv)
|
||||
case 'b':
|
||||
{
|
||||
unsigned long inverse_days;
|
||||
if (getulong(optarg, &inverse_days) == -1) {
|
||||
if (str2ul(&inverse_days, optarg) == -1) {
|
||||
fprintf (stderr,
|
||||
_("%s: invalid numeric argument '%s'\n"),
|
||||
Prog, optarg);
|
||||
@@ -356,7 +356,7 @@ int main (int argc, char **argv)
|
||||
case 't':
|
||||
{
|
||||
unsigned long days;
|
||||
if (getulong(optarg, &days) == -1) {
|
||||
if (str2ul(&days, optarg) == -1) {
|
||||
fprintf (stderr,
|
||||
_("%s: invalid numeric argument '%s'\n"),
|
||||
Prog, optarg);
|
||||
|
||||
@@ -674,19 +674,19 @@ static void process_flags (int argc, char **argv)
|
||||
}
|
||||
#if defined(USE_SHA_CRYPT)
|
||||
if ( ( ((0 == strcmp (crypt_method, "SHA256")) || (0 == strcmp (crypt_method, "SHA512")))
|
||||
&& (-1 == getlong(optarg, &sha_rounds)))) {
|
||||
&& (-1 == str2sl(&sha_rounds, optarg)))) {
|
||||
bad_s = 1;
|
||||
}
|
||||
#endif /* USE_SHA_CRYPT */
|
||||
#if defined(USE_BCRYPT)
|
||||
if (( (0 == strcmp (crypt_method, "BCRYPT"))
|
||||
&& (-1 == getlong(optarg, &bcrypt_rounds)))) {
|
||||
&& (-1 == str2sl(&bcrypt_rounds, optarg)))) {
|
||||
bad_s = 1;
|
||||
}
|
||||
#endif /* USE_BCRYPT */
|
||||
#if defined(USE_YESCRYPT)
|
||||
if (( (0 == strcmp (crypt_method, "YESCRYPT"))
|
||||
&& (-1 == getlong(optarg, &yescrypt_cost)))) {
|
||||
&& (-1 == str2sl(&yescrypt_cost, optarg)))) {
|
||||
bad_s = 1;
|
||||
}
|
||||
#endif /* USE_YESCRYPT */
|
||||
|
||||
@@ -801,7 +801,7 @@ int main (int argc, char **argv)
|
||||
usage (E_SUCCESS);
|
||||
/*@notreached@*/break;
|
||||
case 'i':
|
||||
if ( (getlong(optarg, &inact) == -1)
|
||||
if ( (str2sl(&inact, optarg) == -1)
|
||||
|| (inact < -1)) {
|
||||
fprintf (stderr,
|
||||
_("%s: invalid numeric argument '%s'\n"),
|
||||
@@ -820,7 +820,7 @@ int main (int argc, char **argv)
|
||||
anyflag = true;
|
||||
break;
|
||||
case 'n':
|
||||
if ( (getlong(optarg, &age_min) == -1)
|
||||
if ( (str2sl(&age_min, optarg) == -1)
|
||||
|| (age_min < -1)) {
|
||||
fprintf (stderr,
|
||||
_("%s: invalid numeric argument '%s'\n"),
|
||||
@@ -855,7 +855,7 @@ int main (int argc, char **argv)
|
||||
anyflag = true;
|
||||
break;
|
||||
case 'w':
|
||||
if ( (getlong(optarg, &warn) == -1)
|
||||
if ( (str2sl(&warn, optarg) == -1)
|
||||
|| (warn < -1)) {
|
||||
(void) fprintf (stderr,
|
||||
_("%s: invalid numeric argument '%s'\n"),
|
||||
@@ -866,7 +866,7 @@ int main (int argc, char **argv)
|
||||
anyflag = true;
|
||||
break;
|
||||
case 'x':
|
||||
if ( (getlong(optarg, &age_max) == -1)
|
||||
if ( (str2sl(&age_max, optarg) == -1)
|
||||
|| (age_max < -1)) {
|
||||
(void) fprintf (stderr,
|
||||
_("%s: invalid numeric argument '%s'\n"),
|
||||
|
||||
@@ -416,7 +416,7 @@ static void get_defaults (void)
|
||||
* Default Password Inactive value
|
||||
*/
|
||||
else if (MATCH (buf, DINACT)) {
|
||||
if ( (getlong(ccp, &def_inactive) == -1)
|
||||
if ( (str2sl(&def_inactive, ccp) == -1)
|
||||
|| (def_inactive < -1)) {
|
||||
fprintf (stderr,
|
||||
_("%s: invalid numeric argument '%s'\n"),
|
||||
@@ -1302,7 +1302,7 @@ static void process_flags (int argc, char **argv)
|
||||
eflg = true;
|
||||
break;
|
||||
case 'f':
|
||||
if ( (getlong(optarg, &def_inactive) == -1)
|
||||
if ( (str2sl(&def_inactive, optarg) == -1)
|
||||
|| (def_inactive < -1)) {
|
||||
fprintf (stderr,
|
||||
_("%s: invalid numeric argument '%s'\n"),
|
||||
|
||||
@@ -1062,7 +1062,7 @@ static void process_flags (int argc, char **argv)
|
||||
eflg = true;
|
||||
break;
|
||||
case 'f':
|
||||
if ( (getlong(optarg, &user_newinactive) == -1)
|
||||
if ( (str2sl(&user_newinactive, optarg) == -1)
|
||||
|| (user_newinactive < -1)) {
|
||||
fprintf (stderr,
|
||||
_("%s: invalid numeric argument '%s'\n"),
|
||||
|
||||
Reference in New Issue
Block a user