]> granicus.if.org Git - shadow/commitdiff
* src/lastlog.c: Replace atoi() by getulong().
authornekral-guest <nekral-guest@5a98b0ae-9ef6-0310-add3-de5d479b70d7>
Tue, 28 Apr 2009 19:25:15 +0000 (19:25 +0000)
committernekral-guest <nekral-guest@5a98b0ae-9ef6-0310-add3-de5d479b70d7>
Tue, 28 Apr 2009 19:25:15 +0000 (19:25 +0000)
ChangeLog
src/lastlog.c

index 77939f128a9583d01d88f7f5754b3a17461ebd91..a71183b75e94f63e122479000de995094b7d0a91 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2009-04-28  Nicolas François  <nicolas.francois@centraliens.net>
+
+       * src/lastlog.c: Replace atoi() by getulong().
+
 2009-04-28  Nicolas François  <nicolas.francois@centraliens.net>
 
        * libmisc/failure.h: Replace HAVE_UTMPX_H by USE_UTMPX.
index 9fde16124298766a0132ac4d7240d7b338a82407..39dd8939311fc9fb185bdeb794ca77cfa88662e8 100644 (file)
@@ -60,9 +60,7 @@ static unsigned long umin;    /* if uflg and has_umin, only display users with uid
 static bool has_umin = false;
 static unsigned long umax;     /* if uflg and has_umax, only display users with uid <= umax */
 static bool has_umax = false;
-static int days;               /* number of days to consider for print command */
 static time_t seconds;         /* that number of days in seconds */
-static int inverse_days;       /* number of days to consider for print command */
 static time_t inverse_seconds; /* that number of days in seconds */
 static struct stat statbuf;    /* fstat buffer for file size */
 
@@ -213,15 +211,31 @@ int main (int argc, char **argv)
                                usage ();
                                break;
                        case 't':
-                               days = atoi (optarg); /* FIXME */
+                       {
+                               unsigned long days;
+                               if (getulong (optarg, &days) == 0) {
+                                       fprintf (stderr,
+                                                _("%s: invalid numeric argument '%s'\n"),
+                                                "lastlog", optarg);
+                                       exit (EXIT_FAILURE);
+                               }
                                seconds = (time_t) days * DAY;
                                tflg = true;
                                break;
+                       }
                        case 'b':
-                               inverse_days = atoi (optarg); /* FIXME */
+                       {
+                               unsigned long inverse_days;
+                               if (getulong (optarg, &inverse_days) == 0) {
+                                       fprintf (stderr,
+                                                _("%s: invalid numeric argument '%s'\n"),
+                                                "lastlog", optarg);
+                                       exit (EXIT_FAILURE);
+                               }
                                inverse_seconds = (time_t) inverse_days * DAY;
                                bflg = true;
                                break;
+                       }
                        case 'u':
                        {
                                const struct passwd *pwent;