From 930cbe9d946f40e3698765b05b03f97df52fa471 Mon Sep 17 00:00:00 2001 From: Lance Date: Sat, 20 May 2006 08:14:35 +0000 Subject: * Abit of alterations to login-server. git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@6664 54d463be-8e91-2dee-dedb-b68131a5f0ec --- Changelog-Trunk.txt | 2 ++ src/login/login.c | 23 ++++++++++------------- src/login/login.h | 4 ++-- src/login_sql/login.c | 12 ++++++------ src/login_sql/login.h | 4 ++-- 5 files changed, 22 insertions(+), 23 deletions(-) diff --git a/Changelog-Trunk.txt b/Changelog-Trunk.txt index 2c9716af2..8d3a9e057 100644 --- a/Changelog-Trunk.txt +++ b/Changelog-Trunk.txt @@ -3,6 +3,8 @@ Date Added AS OF SVN REV. 5091, WE ARE NOW USING TRUNK. ALL UNTESTED BUGFIXES/FEATURES GO INTO TRUNK. IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK. +2006/05/19 + * Abit of alterations to login-server. [Lance] 2006/05/19 * Minor unsigned/signed alteration in pc_additem to shut the compiler up. [Lance] * Small change in pc_additem that could be fixing the current bug with new diff --git a/src/login/login.c b/src/login/login.c index 5204b6dbd..c294665e4 100644 --- a/src/login/login.c +++ b/src/login/login.c @@ -35,7 +35,6 @@ void Gettimeofday(struct timeval *timenow) #include #include -#include "login.h" #include "../common/core.h" #include "../common/socket.h" #include "../common/timer.h" @@ -47,6 +46,7 @@ void Gettimeofday(struct timeval *timenow) #include "../common/malloc.h" #include "../common/strlib.h" #include "../common/showmsg.h" +#include "login.h" #ifdef PASSWORDENC #include "md5calc.h" @@ -1093,10 +1093,10 @@ int mmo_auth_new(struct mmo_account* account, char sex, char* email) { auth_dat[i].account_id = account_id_count++; - strncpy(auth_dat[i].userid, account->userid, 24); + strncpy(auth_dat[i].userid, account->userid, NAME_LENGTH); auth_dat[i].userid[23] = '\0'; - strncpy(auth_dat[i].pass, account->passwd, 32); + strncpy(auth_dat[i].pass, account->passwd, NAME_LENGTH); auth_dat[i].pass[23] = '\0'; memcpy(auth_dat[i].lastlogin, "-", 2); @@ -1233,7 +1233,7 @@ int mmo_auth(struct mmo_account* account, int fd) { if(use_md5_passwds) MD5_String(account->passwd, user_password); else - memcpy(user_password, account->passwd, 25); + memcpy(user_password, account->passwd, NAME_LENGTH); encpasswdok = 0; #ifdef PASSWORDENC ld = (struct login_session_data*)session[fd]->session_data; @@ -2147,19 +2147,16 @@ int parse_admin(int fd) { return 0; { struct mmo_account ma; - ma.userid = (char*)RFIFOP(fd, 2); + memcpy(ma.userid,RFIFOP(fd, 2),NAME_LENGTH); ma.userid[23] = '\0'; - memcpy(ma.passwd, RFIFOP(fd, 26), 24); + memcpy(ma.passwd, RFIFOP(fd, 26), NAME_LENGTH); ma.passwd[23] = '\0'; memcpy(ma.lastlogin, "-", 2); ma.sex = RFIFOB(fd,50); WFIFOW(fd,0) = 0x7931; WFIFOL(fd,2) = 0xffffffff; memcpy(WFIFOP(fd,6), RFIFOP(fd,2), 24); - if (strlen(ma.userid) > 23 || strlen(ma.passwd) > 23) { - login_log("'ladmin': Attempt to create an invalid account (account or pass is too long, ip: %s)" RETCODE, - ip); - } else if (strlen(ma.userid) < 4 || strlen(ma.passwd) < 4) { + if (strlen(ma.userid) < 4 || strlen(ma.passwd) < 4) { login_log("'ladmin': Attempt to create an invalid account (account or pass is too short, ip: %s)" RETCODE, ip); } else if (ma.sex != 'F' && ma.sex != 'M') { @@ -3091,7 +3088,7 @@ int parse_login(int fd) { return 0; account.version = RFIFOL(fd, 2); //for exe version check [Sirius] - account.userid = (char*)RFIFOP(fd,6); + memcpy(account.userid,RFIFOP(fd,6),NAME_LENGTH); account.userid[23] = '\0'; remove_control_chars((unsigned char *)account.userid); if (RFIFOW(fd,0) == 0x64) { @@ -3246,10 +3243,10 @@ int parse_login(int fd) { { int GM_value, len; char* server_name; - account.userid = (char*)RFIFOP(fd,2); + memcpy(account.userid,RFIFOP(fd,2),NAME_LENGTH); account.userid[23] = '\0'; remove_control_chars((unsigned char *)account.userid); - memcpy(account.passwd, RFIFOP(fd,26), 24); + memcpy(account.passwd, RFIFOP(fd,26), NAME_LENGTH); account.passwd[23] = '\0'; remove_control_chars((unsigned char *)account.passwd); account.passwdenc = 0; diff --git a/src/login/login.h b/src/login/login.h index 98f397605..643c5df4f 100644 --- a/src/login/login.h +++ b/src/login/login.h @@ -18,8 +18,8 @@ extern int login_port; struct mmo_account { int version; //Added for version check [Sirius] - char* userid; - char passwd[33]; + char userid[NAME_LENGTH]; + char passwd[NAME_LENGTH]; int passwdenc; long account_id; diff --git a/src/login_sql/login.c b/src/login_sql/login.c index 7a40808ab..2d94aba2f 100644 --- a/src/login_sql/login.c +++ b/src/login_sql/login.c @@ -643,8 +643,8 @@ int mmo_auth( struct mmo_account* account , int fd){ jstrescapecpy(t_uid,account->userid); if (account->passwdenc==PASSWORDENC) { - memset(t_pass, 0, sizeof(t_pass)); - memcpy(t_pass, account->passwd, strlen(account->passwd)); + memcpy(t_pass, account->passwd, NAME_LENGTH); + t_pass[24] = '\0'; } else jstrescapecpy(t_pass, account->passwd); @@ -1533,9 +1533,9 @@ int parse_login(int fd) { ShowInfo("client connection request %s from %d.%d.%d.%d\n", RFIFOP(fd, 6), p[0], p[1], p[2], p[3]); account.version = RFIFOL(fd, 2); - account.userid = (char*)RFIFOP(fd, 6); + memcpy(account.userid,RFIFOP(fd, 6),NAME_LENGTH); account.userid[23] = '\0'; - account.passwd = (char*)RFIFOP(fd, 30); + memcpy(account.passwd,RFIFOP(fd, 30),NAME_LENGTH); account.passwd[23] = '\0'; #ifdef PASSWORDENC account.passwdenc= (RFIFOW(fd,0)==0x64)?0:PASSWORDENC; @@ -1817,9 +1817,9 @@ int parse_login(int fd) { ShowInfo("server connection request %s @ %d.%d.%d.%d:%d (%d.%d.%d.%d)\n", RFIFOP(fd, 60), RFIFOB(fd, 54), RFIFOB(fd, 55), RFIFOB(fd, 56), RFIFOB(fd, 57), RFIFOW(fd, 58), p[0], p[1], p[2], p[3]); - account.userid = (char*)RFIFOP(fd, 2); + memcpy(account.userid,RFIFOP(fd, 2),NAME_LENGTH); account.userid[23] = '\0'; - account.passwd = (char*)RFIFOP(fd, 26); + memcpy(account.passwd,RFIFOP(fd, 26),NAME_LENGTH); account.passwd[23] = '\0'; account.passwdenc = 0; server_name = RFIFOP(fd,60); diff --git a/src/login_sql/login.h b/src/login_sql/login.h index b1f6ee263..b215c7266 100644 --- a/src/login_sql/login.h +++ b/src/login_sql/login.h @@ -30,8 +30,8 @@ struct mmo_account { int version; //Added by sirius for versioncheck - char* userid; - char* passwd; + char userid[NAME_LENGTH]; + char passwd[NAME_LENGTH]; int passwdenc; -- cgit v1.2.3-70-g09d2