[Pkg-shadow-commits] r2614 - in upstream/trunk: . src

Nicolas FRANCOIS nekral-guest at alioth.debian.org
Fri Apr 10 22:34:36 UTC 2009


Author: nekral-guest
Date: 2009-04-10 22:34:36 +0000 (Fri, 10 Apr 2009)
New Revision: 2614

Modified:
   upstream/trunk/ChangeLog
   upstream/trunk/src/chage.c
Log:
	* src/chage.c: More strtol() replaced by getlong().

Modified: upstream/trunk/ChangeLog
===================================================================
--- upstream/trunk/ChangeLog	2009-04-10 22:34:29 UTC (rev 2613)
+++ upstream/trunk/ChangeLog	2009-04-10 22:34:36 UTC (rev 2614)
@@ -1,5 +1,9 @@
 2009-04-06  Nicolas François  <nicolas.francois at centraliens.net>
 
+	* src/chage.c: More strtol() replaced by getlong().
+
+2009-04-06  Nicolas François  <nicolas.francois at centraliens.net>
+
 	* lib/prototypes.h: pwd_to_spwd() should be declared if USE_PAM is
 	NOT defined.
 

Modified: upstream/trunk/src/chage.c
===================================================================
--- upstream/trunk/src/chage.c	2009-04-10 22:34:29 UTC (rev 2613)
+++ upstream/trunk/src/chage.c	2009-04-10 22:34:36 UTC (rev 2614)
@@ -195,23 +195,20 @@
 static int new_fields (void)
 {
 	char buf[200];
-	char *cp;
 
 	(void) puts (_("Enter the new value, or press ENTER for the default"));
 	(void) puts ("");
 
 	snprintf (buf, sizeof buf, "%ld", mindays);
 	change_field (buf, sizeof buf, _("Minimum Password Age"));
-	mindays = strtol (buf, &cp, 10);
-	if (   ((0 == mindays) && ('\0' != *cp))
+	if (   (getlong (buf, &mindays) == 0)
 	    || (mindays < -1)) {
 		return 0;
 	}
 
 	snprintf (buf, sizeof buf, "%ld", maxdays);
 	change_field (buf, sizeof buf, _("Maximum Password Age"));
-	maxdays = strtol (buf, &cp, 10);
-	if (   ((0 == maxdays) && ('\0' != *cp))
+	if (   (getlong (buf, &maxdays) == 0)
 	    || (maxdays < -1)) {
 		return 0;
 	}
@@ -231,16 +228,14 @@
 
 	snprintf (buf, sizeof buf, "%ld", warndays);
 	change_field (buf, sizeof buf, _("Password Expiration Warning"));
-	warndays = strtol (buf, &cp, 10);
-	if (   ((warndays == 0) && ('\0' != *cp))
+	if (   (getlong (buf, &warndays) == 0)
 	    || (warndays < -1)) {
 		return 0;
 	}
 
 	snprintf (buf, sizeof buf, "%ld", inactdays);
 	change_field (buf, sizeof buf, _("Password Inactive"));
-	inactdays = strtol (buf, &cp, 10);
-	if (   ((inactdays == 0) && ('\0' != *cp))
+	if (   (getlong (buf, &inactdays) == 0)
 	    || (inactdays < -1)) {
 		return 0;
 	}
@@ -411,16 +406,24 @@
 			dflg = true;
 			if (!isnum (optarg)) {
 				lastday = strtoday (optarg);
-			} else {
-				lastday = strtol (optarg, 0, 10);
+			} else if (   (getlong (optarg, &lastday) == 0)
+			           || (lastday < -1)) {
+				fprintf (stderr,
+				         _("%s: invalid date '%s'\n"),
+				         Prog, optarg);
+				usage ();
 			}
 			break;
 		case 'E':
 			Eflg = true;
 			if (!isnum (optarg)) {
 				expdays = strtoday (optarg);
-			} else {
-				expdays = strtol (optarg, 0, 10);
+			} else if (   (getlong (optarg, &expdays) == 0)
+			           || (expdays < -1)) {
+				fprintf (stderr,
+				         _("%s: invalid date '%s'\n"),
+				         Prog, optarg);
+				usage ();
 			}
 			break;
 		case 'h':
@@ -428,22 +431,46 @@
 			break;
 		case 'I':
 			Iflg = true;
-			inactdays = strtol (optarg, 0, 10);
+			if (   (getlong (optarg, &inactdays) == 0)
+			    || (inactdays < -1)) {
+				fprintf (stderr,
+				         _("%s: invalid numeric argument '%s'\n"),
+				         Prog, optarg);
+				usage ();
+			}
 			break;
 		case 'l':
 			lflg = true;
 			break;
 		case 'm':
 			mflg = true;
-			mindays = strtol (optarg, 0, 10);
+			if (   (getlong (optarg, &mindays) == 0)
+			    || (mindays < -1)) {
+				fprintf (stderr,
+				         _("%s: invalid numeric argument '%s'\n"),
+				         Prog, optarg);
+				usage ();
+			}
 			break;
 		case 'M':
 			Mflg = true;
-			maxdays = strtol (optarg, 0, 10);
+			if (   (getlong (optarg, &maxdays) == 0)
+			    || (maxdays < -1)) {
+				fprintf (stderr,
+				         _("%s: invalid numeric argument '%s'\n"),
+				         Prog, optarg);
+				usage ();
+			}
 			break;
 		case 'W':
 			Wflg = true;
-			warndays = strtol (optarg, 0, 10);
+			if (   (getlong (optarg, &warndays) == 0)
+			    || (warndays < -1)) {
+				fprintf (stderr,
+				         _("%s: invalid numeric argument '%s'\n"),
+				         Prog, optarg);
+				usage ();
+			}
 			break;
 		default:
 			usage ();




More information about the Pkg-shadow-commits mailing list