Commit f393a83f authored by rswindell's avatar rswindell
Browse files

Mmore use of K_TRIM getstr() mode to prevent prepended and trailing...

Mmore use of K_TRIM getstr() mode to prevent prepended and trailing white-space on user data fields that are input by the user.
Also fixed a pretty funny bug that would occur if a user hit Ctrl-C at the password modification (W) passowrd confirmation prmopt: all subsequen text was converted to X's. The console ECHO_X mode really should go away.
parent 192dea0e
......@@ -8,7 +8,7 @@
* @format.tab-size 4 (Plain Text/Source Code File Header) *
* @format.use-tabs true (see http://www.synchro.net/ptsc_hdr.html) *
* *
* Copyright Rob Swindell - http://www.synchro.net/copyright.html *
* Copyright Rob Swindell - http://www.synchro.net/copyright.html *
* *
* This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License *
......@@ -243,7 +243,7 @@ bool sbbs_t::logon()
if(cfg.sys_misc&SM_PWEDIT && yesno(text[NewPasswordQ]))
while(online) {
bprintf(text[NewPasswordPromptFmt], MIN_PASS_LEN, LEN_PASS);
getstr(str,LEN_PASS,K_UPPER|K_LINE);
getstr(str,LEN_PASS,K_UPPER|K_LINE|K_TRIM);
truncsp(str);
if(chkpass(str,&useron,true))
break;
......@@ -289,7 +289,7 @@ bool sbbs_t::logon()
hangup();
return(false);
}
kmode=(cfg.uq&UQ_NOEXASC);
kmode=(cfg.uq&UQ_NOEXASC)|K_TRIM;
if(!(cfg.uq&UQ_NOUPRLWR))
kmode|=K_UPRLWR;
......@@ -321,7 +321,7 @@ bool sbbs_t::logon()
while(online) {
bputs(text[EnterYourHandle]);
if(!getstr(useron.handle,LEN_HANDLE
,K_LINE|K_EDIT|K_AUTODEL|(cfg.uq&UQ_NOEXASC))
,K_LINE|K_EDIT|K_AUTODEL|kmode)
|| strchr(useron.handle,0xff)
|| (cfg.uq&UQ_DUPHAND
&& userdatdupe(useron.number,U_HANDLE,LEN_HANDLE
......@@ -347,7 +347,7 @@ bool sbbs_t::logon()
if(cfg.uq&UQ_ADDRESS && !useron.zipcode[0])
while(online) {
bputs(text[EnterYourZipCode]);
if(getstr(useron.zipcode,LEN_ZIPCODE,K_UPPER|(cfg.uq&UQ_NOEXASC)))
if(getstr(useron.zipcode,LEN_ZIPCODE,K_UPPER|kmode))
break;
}
if(cfg.uq&UQ_PHONE && !useron.phone[0]) {
......@@ -363,7 +363,7 @@ bool sbbs_t::logon()
continue;
} else {
if(getstr(useron.phone,LEN_PHONE
,K_UPPER|(cfg.uq&UQ_NOEXASC))<5)
,K_UPPER|(cfg.uq&UQ_NOEXASC)|K_TRIM)<5)
continue;
}
if(!trashcan(useron.phone,"phone"))
......@@ -373,7 +373,7 @@ bool sbbs_t::logon()
if(!(cfg.uq&UQ_NONETMAIL) && !useron.netmail[0]) {
while(online) {
bputs(text[EnterNetMailAddress]);
if(getstr(useron.netmail,LEN_NETMAIL,K_EDIT|K_AUTODEL|K_LINE)
if(getstr(useron.netmail,LEN_NETMAIL,K_EDIT|K_AUTODEL|K_LINE|K_TRIM)
&& !trashcan(useron.netmail,"email"))
break;
}
......
......@@ -75,7 +75,7 @@ BOOL sbbs_t::newuser()
c=0;
while(++c<4) {
bputs(text[NewUserPasswordPrompt]);
getstr(str,40,K_UPPER);
getstr(str,40,K_UPPER|K_TRIM);
if(!strcmp(str,cfg.new_pass))
break;
SAFEPRINTF(tmp,"NUP Attempted: '%s'",str);
......@@ -236,7 +236,7 @@ BOOL sbbs_t::newuser()
}
else if(cfg.uq&UQ_COMPANY && text[EnterYourCompany][0]) {
bputs(text[EnterYourCompany]);
getstr(useron.name,LEN_NAME,(cfg.uq&UQ_NOEXASC)|K_EDIT|K_AUTODEL);
getstr(useron.name,LEN_NAME,kmode);
}
if(!useron.alias[0]) {
errormsg(WHERE, ERR_CHK, "alias", 0);
......@@ -250,7 +250,7 @@ BOOL sbbs_t::newuser()
while((cfg.uq&UQ_HANDLE) && online && text[EnterYourHandle][0]) {
bputs(text[EnterYourHandle]);
if(!getstr(useron.handle,LEN_HANDLE
,K_LINE|K_EDIT|K_AUTODEL|(cfg.uq&UQ_NOEXASC))
,K_LINE|K_EDIT|K_AUTODEL|K_TRIM|(cfg.uq&UQ_NOEXASC))
|| strchr(useron.handle,0xff)
|| ((cfg.uq&UQ_DUPHAND)
&& userdatdupe(0,U_HANDLE,LEN_HANDLE,useron.handle))
......@@ -281,7 +281,7 @@ BOOL sbbs_t::newuser()
while(online && text[EnterYourZipCode][0]) {
bputs(text[EnterYourZipCode]);
if(getstr(useron.zipcode,LEN_ZIPCODE
,K_UPPER|(cfg.uq&UQ_NOEXASC)|K_EDIT|K_AUTODEL))
,K_UPPER|(cfg.uq&UQ_NOEXASC)|K_EDIT|K_AUTODEL|K_TRIM))
break;
}
if(!online) return(FALSE);
......@@ -294,7 +294,7 @@ BOOL sbbs_t::newuser()
bputs(text[EnterYourPhoneNumber]);
if(!usa) {
if(getstr(useron.phone,LEN_PHONE
,K_UPPER|K_LINE|(cfg.uq&UQ_NOEXASC)|K_EDIT|K_AUTODEL)<5)
,K_UPPER|K_LINE|(cfg.uq&UQ_NOEXASC)|K_EDIT|K_AUTODEL|K_TRIM)<5)
continue;
}
else {
......@@ -320,7 +320,7 @@ BOOL sbbs_t::newuser()
if(!online) return(FALSE);
while(!(cfg.uq&UQ_NONETMAIL) && online && text[EnterNetMailAddress][0]) {
bputs(text[EnterNetMailAddress]);
if(getstr(useron.netmail,LEN_NETMAIL,K_EDIT|K_AUTODEL|K_LINE)
if(getstr(useron.netmail,LEN_NETMAIL,K_EDIT|K_AUTODEL|K_LINE|K_TRIM)
&& !trashcan(useron.netmail,"email"))
break;
}
......@@ -383,7 +383,7 @@ BOOL sbbs_t::newuser()
if(cfg.sys_misc&SM_PWEDIT && text[NewPasswordQ][0] && yesno(text[NewPasswordQ]))
while(online) {
bprintf(text[NewPasswordPromptFmt], MIN_PASS_LEN, LEN_PASS);
getstr(str,LEN_PASS,K_UPPER|K_LINE);
getstr(str,LEN_PASS,K_UPPER|K_LINE|K_TRIM);
truncsp(str);
if(chkpass(str,&useron,true)) {
SAFECOPY(useron.pass,str);
......@@ -422,7 +422,7 @@ BOOL sbbs_t::newuser()
if(cfg.new_magic[0] && text[MagicWordPrompt][0]) {
bputs(text[MagicWordPrompt]);
str[0]=0;
getstr(str,50,K_UPPER);
getstr(str,50,K_UPPER|K_TRIM);
if(strcmp(str,cfg.new_magic)) {
bputs(text[FailedMagicWord]);
SAFEPRINTF(tmp,"failed magic word: '%s'",str);
......
......@@ -56,6 +56,7 @@ void sbbs_t::useredit(int usernumber)
uint i,j,k;
float f;
long l;
long kmode = K_LINE|K_EDIT|K_AUTODEL|K_TRIM;
user_t user;
struct tm tm;
......@@ -173,14 +174,14 @@ void sbbs_t::useredit(int usernumber)
switch(l) {
case 'A':
bputs(text[EnterYourAlias]);
getstr(user.alias,LEN_ALIAS,K_LINE|K_EDIT|K_AUTODEL);
getstr(user.alias,LEN_ALIAS,kmode);
if(sys_status&SS_ABORT)
break;
putuserrec(&cfg,user.number,U_ALIAS,LEN_ALIAS,user.alias);
if(!(user.misc&DELETED))
putusername(&cfg,user.number,user.alias);
bputs(text[EnterYourHandle]);
getstr(user.handle,LEN_HANDLE,K_LINE|K_EDIT|K_AUTODEL);
getstr(user.handle,LEN_HANDLE,kmode);
if(sys_status&SS_ABORT)
break;
putuserrec(&cfg,user.number,U_HANDLE,LEN_HANDLE,user.handle);
......@@ -188,14 +189,14 @@ void sbbs_t::useredit(int usernumber)
case 'B':
bprintf(text[EnterYourBirthday]
,cfg.sys_misc&SM_EURODATE ? "DD/MM/YY" : "MM/DD/YY");
gettmplt(user.birth,"nn/nn/nn",K_LINE|K_EDIT|K_AUTODEL);
gettmplt(user.birth,"nn/nn/nn",kmode);
if(sys_status&SS_ABORT)
break;
putuserrec(&cfg,user.number,U_BIRTH,LEN_BIRTH,user.birth);
break;
case 'C':
bputs(text[EnterYourComputer]);
getstr(user.comp,LEN_COMP,K_LINE|K_EDIT|K_AUTODEL);
getstr(user.comp,LEN_COMP,kmode);
if(sys_status&SS_ABORT)
break;
putuserrec(&cfg,user.number,U_COMP,LEN_COMP,user.comp);
......@@ -399,12 +400,12 @@ void sbbs_t::useredit(int usernumber)
break;
case 'L':
bputs(text[EnterYourAddress]);
getstr(user.address,LEN_ADDRESS,K_LINE|K_EDIT|K_AUTODEL);
getstr(user.address,LEN_ADDRESS,kmode);
if(sys_status&SS_ABORT)
break;
putuserrec(&cfg,user.number,U_ADDRESS,LEN_ADDRESS,user.address);
bputs(text[EnterYourCityState]);
getstr(user.location,LEN_LOCATION,K_LINE|K_EDIT|K_AUTODEL);
getstr(user.location,LEN_LOCATION,kmode);
if(sys_status&SS_ABORT)
break;
putuserrec(&cfg,user.number,U_LOCATION,LEN_LOCATION,user.location);
......@@ -430,14 +431,14 @@ void sbbs_t::useredit(int usernumber)
break;
case 'O':
bputs(text[UeditComment]);
getstr(user.comment,60,K_LINE|K_EDIT|K_AUTODEL);
getstr(user.comment,60,kmode);
if(sys_status&SS_ABORT)
break;
putuserrec(&cfg,user.number,U_COMMENT,60,user.comment);
break;
case 'P':
bputs(text[EnterYourPhoneNumber]);
getstr(user.phone,LEN_PHONE,K_UPPER|K_LINE|K_EDIT|K_AUTODEL);
getstr(user.phone,LEN_PHONE,kmode);
if(sys_status&SS_ABORT)
break;
putuserrec(&cfg,user.number,U_PHONE,LEN_PHONE,user.phone);
......@@ -450,7 +451,7 @@ void sbbs_t::useredit(int usernumber)
return;
case 'R':
bputs(text[EnterYourRealName]);
getstr(user.name,LEN_NAME,K_LINE|K_EDIT|K_AUTODEL);
getstr(user.name,LEN_NAME,kmode);
if(sys_status&SS_ABORT)
break;
putuserrec(&cfg,user.number,U_NAME,LEN_NAME,user.name);
......@@ -523,7 +524,7 @@ void sbbs_t::useredit(int usernumber)
break;
case 'W':
bputs(text[UeditPassword]);
getstr(user.pass,LEN_PASS,K_UPPER|K_LINE|K_EDIT|K_AUTODEL);
getstr(user.pass,LEN_PASS,K_UPPER|kmode);
if(sys_status&SS_ABORT)
break;
putuserrec(&cfg,user.number,U_PASS,LEN_PASS,user.pass);
......@@ -1063,7 +1064,7 @@ void sbbs_t::maindflts(user_t* user)
break;
case 'M': /* NetMail address */
bputs(text[EnterNetMailAddress]);
getstr(user->netmail,LEN_NETMAIL,K_EDIT|K_AUTODEL|K_LINE);
getstr(user->netmail,LEN_NETMAIL,K_LINE|K_EDIT|K_AUTODEL|K_TRIM);
if(sys_status&SS_ABORT)
break;
putuserrec(&cfg,user->number,U_NETMAIL,LEN_NETMAIL,user->netmail);
......@@ -1091,16 +1092,16 @@ void sbbs_t::maindflts(user_t* user)
bputs(text[CurrentPassword]);
console|=CON_R_ECHOX;
ch=(char)getstr(str,LEN_PASS,K_UPPER);
console&=~(CON_R_ECHOX|CON_L_ECHOX);
if(sys_status&SS_ABORT)
break;
console&=~(CON_R_ECHOX|CON_L_ECHOX);
if(stricmp(str,user->pass)) {
bputs(text[WrongPassword]);
pause();
break;
}
bprintf(text[NewPasswordPromptFmt], MIN_PASS_LEN, LEN_PASS);
if(!getstr(str,LEN_PASS,K_UPPER|K_LINE))
if(!getstr(str,LEN_PASS,K_UPPER|K_LINE|K_TRIM))
break;
truncsp(str);
if(!chkpass(str,user,false)) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment