Skip to content
Snippets Groups Projects
Commit dd38606e authored by Rob Swindell's avatar Rob Swindell :speech_balloon:
Browse files

find_login_id() will now return 0 if login ID is an invalid user number

If login by number is supported and a client attempts login with an invalid usernumber, don't log an error, e.g.
mail 3264 SMTPS [46.148.x.x] !ERROR -2 getting data on user (6123)

But rather treat it as an invalid login attempt.

Also change lastuser() and total_users() to return int instead of uint. 2 billion users should be plenty.
parent 537051f6
No related branches found
No related tags found
1 merge request!463MRC mods by Codefenix (2024-10-20)
Pipeline #3821 passed
......@@ -150,8 +150,12 @@ uint find_login_id(scfg_t* cfg, const char* user_id)
{
int usernum;
if((cfg->sys_login & LOGIN_USERNUM) && IS_DIGIT(user_id[0]))
return atoi(user_id);
if((cfg->sys_login & LOGIN_USERNUM) && IS_DIGIT(user_id[0])) {
usernum = atoi(user_id);
if(usernum > lastuser(cfg))
usernum = 0;
return usernum;
}
usernum = matchuser(cfg, user_id, /* sysop_alias: */FALSE);
if(usernum < 1 && check_realname(cfg, user_id) && (cfg->sys_login & LOGIN_REALNAME))
......@@ -162,9 +166,9 @@ uint find_login_id(scfg_t* cfg, const char* user_id)
}
/****************************************************************************/
uint total_users(scfg_t* cfg)
int total_users(scfg_t* cfg)
{
uint total_users=0;
int total_users=0;
int file;
bool success = true;
......@@ -192,7 +196,7 @@ uint total_users(scfg_t* cfg)
/****************************************************************************/
/* Returns the number of the last user in user.tab (deleted ones too) */
/****************************************************************************/
uint lastuser(scfg_t* cfg)
int lastuser(scfg_t* cfg)
{
char path[MAX_PATH + 1];
off_t length;
......@@ -201,7 +205,7 @@ uint lastuser(scfg_t* cfg)
return(0);
if((length = flength(userdat_filename(cfg, path, sizeof(path)))) > 0)
return (uint)(length / USER_RECORD_LINE_LEN);
return (int)(length / USER_RECORD_LINE_LEN);
return 0;
}
......
......@@ -55,8 +55,8 @@ DLLEXPORT uint matchuser(scfg_t*, const char *str, BOOL sysop_alias); // Checks
DLLEXPORT BOOL matchusername(scfg_t*, const char* name, const char* compare);
DLLEXPORT char* alias(scfg_t*, const char* name, char* buf);
DLLEXPORT int putusername(scfg_t*, int number, const char* name);
DLLEXPORT uint total_users(scfg_t*);
DLLEXPORT uint lastuser(scfg_t*);
DLLEXPORT int total_users(scfg_t*);
DLLEXPORT int lastuser(scfg_t*);
DLLEXPORT BOOL del_lastuser(scfg_t*);
DLLEXPORT int getage(scfg_t*, const char* birthdate);
DLLEXPORT int getbirthmonth(scfg_t*, const char* birthdate);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment