int
changepw (int dowrite)
{
- char buf[21];
+ char buf[DGL_PASSWDLEN+1];
int error = 2;
/* A precondition is that struct `me' exists because we can be not-yet-logged-in. */
while (error)
{
- char repeatbuf[21];
+ char repeatbuf[DGL_PASSWDLEN+1];
clear ();
drawbanner (&banner, 1, 1);
mvaddstr (6, 1,
"in plaintext, so make it something new and expect it to be relatively");
mvaddstr (7, 1, "insecure.");
- mvaddstr (8, 1,
- "20 character max. No ':' characters. Blank line to abort.");
+ mvprintw (8, 1,
+ "%i character max. No ':' characters. Blank line to abort.", DGL_PASSWDLEN);
mvaddstr (10, 1, "=> ");
if (error == 1)
refresh ();
- if (mygetnstr (buf, 20, 0) != OK)
+ if (mygetnstr (buf, DGL_PASSWDLEN, 0) != OK)
return 0;
if (*buf == '\0')
mvaddstr (12, 1, "And again:");
mvaddstr (13, 1, "=> ");
- if (mygetnstr (repeatbuf, 20, 0) != OK)
+ if (mygetnstr (repeatbuf, DGL_PASSWDLEN, 0) != OK)
return 0;
if (!strcmp (buf, repeatbuf))
void
loginprompt (int from_ttyplay)
{
- char user_buf[DGL_PLAYERNAMELEN+1], pw_buf[22];
+ char user_buf[DGL_PLAYERNAMELEN+1], pw_buf[DGL_PASSWDLEN+2];
int error = 2;
loggedin = 0;
refresh ();
- if (mygetnstr (pw_buf, 20, 0) != OK)
+ if (mygetnstr (pw_buf, DGL_PASSWDLEN, 0) != OK)
return;
if (passwordgood (pw_buf))
{
assert (me != NULL);
- if (!strncmp (crypt (cpw, cpw), me->password, 13))
+ if (!strncmp (crypt (cpw, cpw), me->password, DGL_PASSWDLEN))
return 1;
- if (!strncmp (cpw, me->password, 20))
+ if (!strncmp (cpw, me->password, DGL_PASSWDLEN))
return 1;
return 0;
users = realloc (users, sizeof (struct dg_user *) * (f_num + 1));
users[f_num] = malloc (sizeof (struct dg_user));
- users[f_num]->username = (char *) calloc (22, sizeof (char));
+ users[f_num]->username = (char *) calloc (DGL_PLAYERNAMELEN+2, sizeof (char));
users[f_num]->email = (char *) calloc (82, sizeof (char));
- users[f_num]->password = (char *) calloc (22, sizeof (char));
+ users[f_num]->password = (char *) calloc (DGL_PASSWDLEN+2, sizeof (char));
users[f_num]->env = (char *) calloc (1026, sizeof (char));
/* name field, must be valid */
return 1;
users[f_num]->username[(b - n)] = *b;
b++;
- if ((b - n) >= 21) {
+ if ((b - n) >= DGL_PLAYERNAMELEN) {
debug_write("name field too long");
graceful_exit (100);
}
{
users[f_num]->password[(b - n)] = *b;
b++;
- if ((b - n) >= 20) {
+ if ((b - n) >= DGL_PASSWDLEN) {
debug_write("passwd field too long");
graceful_exit (102);
}
int ret, retry = 10;
char *qbuf;
- char tmpbuf[32];
if (requirenew) {
qbuf = sqlite3_mprintf("insert into dglusers (username, email, env, password, flags) values ('%q', '%q', '%q', '%q', %li)", me->username, me->email, me->env, me->password, me->flags);
authenticate ()
{
int i, len, me_index;
- char user_buf[DGL_PLAYERNAMELEN+1], pw_buf[22];
+ char user_buf[DGL_PLAYERNAMELEN+1], pw_buf[DGL_PASSWDLEN+1];
struct dg_game **games = NULL;
/* We use simple password authentication, rather than challenge/response. */
pw_buf[--len] = '\0';
else
{
- fprintf (stderr, "Password too long (max 20 chars).\n");
+ fprintf (stderr, "Password too long (max %i chars).\n", DGL_PASSWDLEN);
return 1;
}