diff --git a/src/useradd.c b/src/useradd.c index 6eaeb533..39a744ee 100644 --- a/src/useradd.c +++ b/src/useradd.c @@ -1996,8 +1996,9 @@ static void faillog_reset (uid_t uid) struct faillog fl; int fd; off_t offset_uid = (off_t) (sizeof fl) * uid; + struct stat st; - if (access (FAILLOG_FILE, F_OK) != 0) { + if (stat (FAILLOG_FILE, &st) != 0 || st.st_size <= offset_uid) { return; } @@ -2033,8 +2034,9 @@ static void lastlog_reset (uid_t uid) int fd; off_t offset_uid = (off_t) (sizeof ll) * uid; uid_t max_uid; + struct stat st; - if (access (LASTLOG_FILE, F_OK) != 0) { + if (stat (LASTLOG_FILE, &st) != 0 || st.st_size <= offset_uid) { return; }