* src/passwd.c: Replace getnumber() by getlong(). This permits to
get rid of another strtol().
This commit is contained in:
parent
1675ca3378
commit
d548bf4742
@ -1,3 +1,8 @@
|
|||||||
|
2009-04-06 Nicolas François <nicolas.francois@centraliens.net>
|
||||||
|
|
||||||
|
* src/passwd.c: Replace getnumber() by getlong(). This permits to
|
||||||
|
get rid of another strtol().
|
||||||
|
|
||||||
2009-04-06 Nicolas François <nicolas.francois@centraliens.net>
|
2009-04-06 Nicolas François <nicolas.francois@centraliens.net>
|
||||||
|
|
||||||
* libmisc/getlong.c: Include both <stdlib.h> and <errno.h> needed
|
* libmisc/getlong.c: Include both <stdlib.h> and <errno.h> needed
|
||||||
|
50
src/passwd.c
50
src/passwd.c
@ -147,7 +147,6 @@ static char *update_crypt_pw (char *);
|
|||||||
static void update_noshadow (void);
|
static void update_noshadow (void);
|
||||||
|
|
||||||
static void update_shadow (void);
|
static void update_shadow (void);
|
||||||
static long getnumber (const char *);
|
|
||||||
#ifdef WITH_SELINUX
|
#ifdef WITH_SELINUX
|
||||||
static int check_selinux_access (const char *changed_user,
|
static int check_selinux_access (const char *changed_user,
|
||||||
uid_t changed_uid,
|
uid_t changed_uid,
|
||||||
@ -677,20 +676,6 @@ static void update_shadow (void)
|
|||||||
spw_locked = false;
|
spw_locked = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static long getnumber (const char *numstr)
|
|
||||||
{
|
|
||||||
long val;
|
|
||||||
char *errptr;
|
|
||||||
|
|
||||||
val = strtol (numstr, &errptr, 10);
|
|
||||||
if (('\0' != *errptr) || (ERANGE == errno)) {
|
|
||||||
fprintf (stderr, _("%s: invalid numeric argument '%s'\n"), Prog,
|
|
||||||
numstr);
|
|
||||||
exit (E_BAD_ARG);
|
|
||||||
}
|
|
||||||
return val;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef WITH_SELINUX
|
#ifdef WITH_SELINUX
|
||||||
static int check_selinux_access (const char *changed_user,
|
static int check_selinux_access (const char *changed_user,
|
||||||
uid_t changed_uid,
|
uid_t changed_uid,
|
||||||
@ -839,8 +824,13 @@ int main (int argc, char **argv)
|
|||||||
anyflag = true;
|
anyflag = true;
|
||||||
break;
|
break;
|
||||||
case 'i':
|
case 'i':
|
||||||
inact = getnumber (optarg);
|
if ( (getlong (optarg, &inact) == 0)
|
||||||
if (inact >= -1)
|
|| (inact < -1)) {
|
||||||
|
fprintf (stderr,
|
||||||
|
_("%s: invalid numeric argument '%s'\n"),
|
||||||
|
Prog, optarg);
|
||||||
|
usage (E_BAD_ARG);
|
||||||
|
}
|
||||||
iflg = true;
|
iflg = true;
|
||||||
anyflag = true;
|
anyflag = true;
|
||||||
break;
|
break;
|
||||||
@ -853,7 +843,13 @@ int main (int argc, char **argv)
|
|||||||
anyflag = true;
|
anyflag = true;
|
||||||
break;
|
break;
|
||||||
case 'n':
|
case 'n':
|
||||||
age_min = getnumber (optarg);
|
if ( (getlong (optarg, &age_min) == 0)
|
||||||
|
|| (age_min < -1)) {
|
||||||
|
fprintf (stderr,
|
||||||
|
_("%s: invalid numeric argument '%s'\n"),
|
||||||
|
Prog, optarg);
|
||||||
|
usage (E_BAD_ARG);
|
||||||
|
}
|
||||||
nflg = true;
|
nflg = true;
|
||||||
anyflag = true;
|
anyflag = true;
|
||||||
break;
|
break;
|
||||||
@ -878,14 +874,24 @@ int main (int argc, char **argv)
|
|||||||
anyflag = true;
|
anyflag = true;
|
||||||
break;
|
break;
|
||||||
case 'w':
|
case 'w':
|
||||||
warn = getnumber (optarg);
|
if ( (getlong (optarg, &warn) == 0)
|
||||||
if (warn >= -1) {
|
|| (warn < -1)) {
|
||||||
wflg = true;
|
fprintf (stderr,
|
||||||
|
_("%s: invalid numeric argument '%s'\n"),
|
||||||
|
Prog, optarg);
|
||||||
|
usage (E_BAD_ARG);
|
||||||
}
|
}
|
||||||
|
wflg = true;
|
||||||
anyflag = true;
|
anyflag = true;
|
||||||
break;
|
break;
|
||||||
case 'x':
|
case 'x':
|
||||||
age_max = getnumber (optarg);
|
if ( (getlong (optarg, &age_max) == 0)
|
||||||
|
|| (age_max < -1)) {
|
||||||
|
fprintf (stderr,
|
||||||
|
_("%s: invalid numeric argument '%s'\n"),
|
||||||
|
Prog, optarg);
|
||||||
|
usage (E_BAD_ARG);
|
||||||
|
}
|
||||||
xflg = true;
|
xflg = true;
|
||||||
anyflag = true;
|
anyflag = true;
|
||||||
break;
|
break;
|
||||||
|
Loading…
Reference in New Issue
Block a user