[Pkg-shadow-commits] r2616 - in upstream/trunk: . lib
Nicolas FRANCOIS
nekral-guest at alioth.debian.org
Fri Apr 10 22:34:49 UTC 2009
Author: nekral-guest
Date: 2009-04-10 22:34:49 +0000 (Fri, 10 Apr 2009)
New Revision: 2616
Modified:
upstream/trunk/ChangeLog
upstream/trunk/lib/sgetspent.c
Log:
* lib/sgetspent.c: Replace strtol() by getlong(). Also detect more
issues in a numerical shadow entry field.
Modified: upstream/trunk/ChangeLog
===================================================================
--- upstream/trunk/ChangeLog 2009-04-10 22:34:42 UTC (rev 2615)
+++ upstream/trunk/ChangeLog 2009-04-10 22:34:49 UTC (rev 2616)
@@ -1,5 +1,10 @@
2009-04-06 Nicolas François <nicolas.francois at centraliens.net>
+ * lib/sgetspent.c: Replace strtol() by getlong(). Also detect more
+ issues in a numerical shadow entry field.
+
+2009-04-06 Nicolas François <nicolas.francois at centraliens.net>
+
* src/chage.c: More strtol() replaced by getlong().
* src/chage.c: expdays renamed to expdate. It is a date, even if
expressed in a number of days since Jan 1, 1970.
Modified: upstream/trunk/lib/sgetspent.c
===================================================================
--- upstream/trunk/lib/sgetspent.c 2009-04-10 22:34:42 UTC (rev 2615)
+++ upstream/trunk/lib/sgetspent.c 2009-04-10 22:34:49 UTC (rev 2616)
@@ -106,36 +106,33 @@
* incorrectly formatted number.
*/
- spwd.sp_lstchg = strtol (fields[2], &cpp, 10);
- /* FIXME: (0 == spwd.sp_lstchg) does not look correct */
- if ((0 == spwd.sp_lstchg) && ('\0' != *cpp)) {
- return 0;
- } else if (fields[2][0] == '\0') {
+ if (fields[2][0] == '\0') {
spwd.sp_lstchg = -1;
+ } else if ( (getlong (fields[2], &spwd.sp_lstchg) == 0)
+ || (spwd.sp_lstchg < 0)) {
+ return 0;
}
/*
* Get the minimum period between password changes.
*/
- spwd.sp_min = strtol (fields[3], &cpp, 10);
- /* FIXME: (0 == spwd.sp_min) does not look correct */
- if ((0 == spwd.sp_min) && ('\0' != *cpp)) {
- return 0;
- } else if (fields[3][0] == '\0') {
+ if (fields[3][0] == '\0') {
spwd.sp_min = -1;
+ } else if ( (getlong (fields[3], &spwd.sp_min) == 0)
+ || (spwd.sp_min < 0)) {
+ return 0;
}
/*
* Get the maximum number of days a password is valid.
*/
- spwd.sp_max = strtol (fields[4], &cpp, 10);
- /* FIXME: (0 == spwd.sp_max) does not look correct */
- if ((0 == spwd.sp_max) && ('\0' != *cpp)) {
- return 0;
- } else if (fields[4][0] == '\0') {
+ if (fields[4][0] == '\0') {
spwd.sp_max = -1;
+ } else if ( (getlong (fields[4], &spwd.sp_max) == 0)
+ || (spwd.sp_max < 0)) {
+ return 0;
}
/*
@@ -156,12 +153,11 @@
* Get the number of days of password expiry warning.
*/
- spwd.sp_warn = strtol (fields[5], &cpp, 10);
- /* FIXME: (0 == spwd.sp_warn) does not look correct */
- if ((0 == spwd.sp_warn) && ('\0' != *cpp)) {
- return 0;
- } else if (fields[5][0] == '\0') {
+ if (fields[5][0] == '\0') {
spwd.sp_warn = -1;
+ } else if ( (getlong (fields[5], &spwd.sp_warn) == 0)
+ || (spwd.sp_warn < 0)) {
+ return 0;
}
/*
@@ -169,12 +165,11 @@
* disabled.
*/
- spwd.sp_inact = strtol (fields[6], &cpp, 10);
- /* FIXME: (0 == spwd.sp_inact) does not look correct */
- if ((0 == spwd.sp_inact) && ('\0' != *cpp)) {
- return 0;
- } else if (fields[6][0] == '\0') {
+ if (fields[6][0] == '\0') {
spwd.sp_inact = -1;
+ } else if ( (getlong (fields[6], &spwd.sp_inact) == 0)
+ || (spwd.sp_inact < 0)) {
+ return 0;
}
/*
@@ -182,12 +177,11 @@
* set to expire.
*/
- spwd.sp_expire = strtol (fields[7], &cpp, 10);
- /* FIXME: (0 == spwd.sp_expire) does not look correct */
- if ((0 == spwd.sp_expire) && ('\0' != *cpp)) {
- return 0;
- } else if (fields[7][0] == '\0') {
+ if (fields[7][0] == '\0') {
spwd.sp_expire = -1;
+ } else if ( (getlong (fields[7], &spwd.sp_expire) == 0)
+ || (spwd.sp_expire < 0)) {
+ return 0;
}
/*
@@ -195,12 +189,11 @@
* to have anything other than a valid integer in it.
*/
- spwd.sp_flag = strtol (fields[8], &cpp, 10);
- /* FIXME: (0 == spwd.sp_flag) does not look correct */
- if ((0 == spwd.sp_flag) && ('\0' != *cpp)) {
- return 0;
- } else if (fields[8][0] == '\0') {
+ if (fields[8][0] == '\0') {
spwd.sp_flag = SHADOW_SP_FLAG_UNSET;
+ } else if (getlong (fields[8], &spwd.sp_flag) == 0) {
+ /* FIXME: add a getulong function */
+ return 0;
}
return (&spwd);
More information about the Pkg-shadow-commits
mailing list