Changeset 18493


Ignore:
Timestamp:
2009-02-10T16:02:02+13:00 (15 years ago)
Author:
davidb
Message:

Increased password limit to 128, and made to loop stop after three attempts

File:
1 edited

Legend:

Unmodified
Added
Removed
  • gsdl/trunk/common-src/src/getpw/getpw.cpp

    r2999 r18493  
    7171int main (int argc, char *argv[]) {
    7272
     73  int password_ok = 0;
    7374  char c[10];
    74   while (1) {
     75  int i;
     76 
     77  for (i=0; i<3; i++)  {
    7578    char *a = getpass("Enter password:");
    7679    int len = strlen (a);
    77     if (len < 3 || len > 8) {
    78       cerr << "Password must be between 3 and 8 characters long. Try again\n";
     80    if (len < 3 || len > 128) {
     81      cerr << "Password must be between 3 and 128 characters long. Try again\n";
    7982      continue;
    8083    }
     84
    8185    strcpy (c, a);
     86
    8287    char *b = getpass("Re-enter password:"); 
    83     if ((strcmp (c, b)) == 0) break;
    84     else cerr << "Passwords didn't match. Try again.\n";
     88
     89    if ((strcmp (c, b)) == 0) {
     90      password_ok = 1;
     91      break;
     92    }
     93    else {
     94      cerr << "Passwords didn't match. Try again.\n";
     95    }
     96  }
     97
     98  if (!password_ok) {
     99    cerr << "Failed to capture password." << endl;
     100    return -1;
    85101  }
    86102
Note: See TracChangeset for help on using the changeset viewer.