Skip to content

Commit cf2bb98

Browse files
authored
Merge pull request #16 from meneleos/main
some fixes
2 parents fff90d6 + 173c682 commit cf2bb98

5 files changed

Lines changed: 36 additions & 7 deletions

File tree

‎src/db/ClientManager.cpp‎

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -510,6 +510,7 @@ void CClientManager::RESULT_SAFEBOX_LOAD(CPeer * pkPeer, SQLMsg * msg)
510510
if (strcmp("000000", szSafeboxPassword))
511511
{
512512
pkPeer->EncodeHeader(HEADER_DG_SAFEBOX_WRONG_PASSWORD, dwHandle, 0);
513+
delete pSafebox;
513514
delete pi;
514515
return;
515516
}
@@ -523,6 +524,7 @@ void CClientManager::RESULT_SAFEBOX_LOAD(CPeer * pkPeer, SQLMsg * msg)
523524
((row[2] && *row[2]) && strcmp(row[2], szSafeboxPassword)))
524525
{
525526
pkPeer->EncodeHeader(HEADER_DG_SAFEBOX_WRONG_PASSWORD, dwHandle, 0);
527+
delete pSafebox;
526528
delete pi;
527529
return;
528530
}
@@ -859,7 +861,7 @@ void CClientManager::RESULT_SAFEBOX_CHANGE_PASSWORD(CPeer * pkPeer, SQLMsg * msg
859861
{
860862
MYSQL_ROW row = mysql_fetch_row(msg->Get()->pSQLResult);
861863

862-
if (row[0] && *row[0] && !strcasecmp(row[0], p->login) || (!row[0] || !*row[0]) && !strcmp("000000", p->login))
864+
if ((row[0] && *row[0] && !strcasecmp(row[0], p->login)) || ((!row[0] || !*row[0]) && !strcmp("000000", p->login)))
863865
{
864866
char szQuery[QUERY_MAX_LEN];
865867
char escape_pwd[64];
@@ -907,6 +909,9 @@ void CClientManager::RESULT_PRICELIST_LOAD(CPeer* peer, SQLMsg* pMsg)
907909

908910
while ((row = mysql_fetch_row(pMsg->Get()->pSQLResult)))
909911
{
912+
if (table.byCount >= SHOP_PRICELIST_MAX_NUM)
913+
break;
914+
910915
str_to_number(table.aPriceInfo[table.byCount].dwVnum, row[0]);
911916
str_to_number(table.aPriceInfo[table.byCount].dwPrice, row[1]);
912917
table.byCount++;
@@ -950,6 +955,9 @@ void CClientManager::RESULT_PRICELIST_LOAD_FOR_UPDATE(SQLMsg* pMsg)
950955

951956
while ((row = mysql_fetch_row(pMsg->Get()->pSQLResult)))
952957
{
958+
if (table.byCount >= SHOP_PRICELIST_MAX_NUM)
959+
break;
960+
953961
str_to_number(table.aPriceInfo[table.byCount].dwVnum, row[0]);
954962
str_to_number(table.aPriceInfo[table.byCount].dwPrice, row[1]);
955963
table.byCount++;
@@ -1991,7 +1999,7 @@ void CClientManager::WeddingEnd(TPacketWeddingEnd * p)
19911999
// Fixed code:
19922000
void CClientManager::MyshopPricelistUpdate(const TItemPriceListTable* pPacket)
19932001
{
1994-
if (pPacket->byCount > SHOP_PRICELIST_MAX_NUM)
2002+
if (pPacket->byCount >= SHOP_PRICELIST_MAX_NUM)
19952003
{
19962004
sys_err("count overflow!");
19972005
return;

‎src/db/ClientManagerLogin.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ void CClientManager::QUERY_LOGIN_BY_KEY(CPeer * pkPeer, DWORD dwHandle, TPacketG
9797
{
9898
sys_log(0, "LOGIN_BY_KEY already login %s %lu", r.login, p->dwLoginKey);
9999
TPacketDGLoginAlready ptog;
100-
strlcpy(ptog.szLogin, szLogin, sizeof(ptog.szLogin));
100+
strlcpy(ptog.szLogin, r.login, sizeof(ptog.szLogin));
101101
pkPeer->EncodeHeader(HEADER_DG_LOGIN_ALREADY, dwHandle, sizeof(TPacketDGLoginAlready));
102102
pkPeer->Encode(&ptog, sizeof(TPacketDGLoginAlready));
103103
return;

‎src/db/ClientManagerPlayer.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -762,7 +762,7 @@ void CClientManager::RESULT_QUEST_LOAD(CPeer * peer, MYSQL_RES * pRes, DWORD dwH
762762
str_to_number(r.lValue, row[3]);
763763
}
764764

765-
sys_log(0, "QUEST_LOAD: count %d PID %u", s_table.size(), s_table[0].dwPID);
765+
sys_log(0, "QUEST_LOAD: count %d PID %u", s_table.size(), pid);
766766

767767
DWORD dwCount = s_table.size();
768768

‎src/game/input_db.cpp‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,7 @@ void CInputDB::PlayerLoad(LPDESC d, const char * data)
396396
if (NULL != CHARACTER_MANAGER::Instance().FindPC(pTab->name))
397397
{
398398
sys_err("InputDB: PlayerLoad : %s already exist in game", pTab->name);
399+
d->SetPhase(PHASE_CLOSE);
399400
return;
400401
}
401402

@@ -1411,7 +1412,7 @@ void CInputDB::GuildSkillRecharge()
14111412

14121413
void CInputDB::GuildExpUpdate(const char* c_pData)
14131414
{
1414-
TPacketGuildSkillUpdate * p = (TPacketGuildSkillUpdate *) c_pData;
1415+
TPacketGuildExpUpdate * p = (TPacketGuildExpUpdate *) c_pData;
14151416
sys_log(1, "GuildExpUpdate %d", p->amount);
14161417

14171418
CGuild * g = CGuildManager::instance().TouchGuild(p->guild_id);

‎src/game/input_login.cpp‎

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,12 @@ void CInputLogin::ChangeName(LPDESC d, const char * data)
197197
return;
198198
}
199199

200+
if (p->index < 0 || p->index >= PLAYER_PER_ACCOUNT)
201+
{
202+
sys_err("index overflow %d, login: %s", p->index, c_r.login);
203+
return;
204+
}
205+
200206
if (!c_r.players[p->index].bChangeName)
201207
return;
202208

@@ -229,12 +235,19 @@ void CInputLogin::CharacterSelect(LPDESC d, const char * data)
229235
return;
230236
}
231237

232-
if (pinfo->index >= PLAYER_PER_ACCOUNT)
238+
if (pinfo->index < 0 || pinfo->index >= PLAYER_PER_ACCOUNT)
233239
{
234240
sys_err("index overflow %d, login: %s", pinfo->index, c_r.login);
235241
return;
236242
}
237243

244+
if (c_r.players[pinfo->index].dwID == 0)
245+
{
246+
sys_err("player index(%d) is null. login %s",
247+
pinfo->index, c_r.login);
248+
return;
249+
}
250+
238251
if (c_r.players[pinfo->index].bChangeName)
239252
{
240253
sys_err("name must be changed idx %d, login %s, name %s",
@@ -431,6 +444,13 @@ void CInputLogin::CharacterCreate(LPDESC d, const char * data)
431444
return;
432445
}
433446

447+
if (pinfo->index < 0 || pinfo->index >= PLAYER_PER_ACCOUNT)
448+
{
449+
sys_err("index overflow %d, login: %s", pinfo->index, d->GetAccountTable().login);
450+
d->Packet(&packFailure, sizeof(packFailure));
451+
return;
452+
}
453+
434454
// 사용할 수 없는 이름이거나, 잘못된 평상복이면 생설 실패
435455
if (!check_name(pinfo->name) || pinfo->shape > 1)
436456
{
@@ -502,7 +522,7 @@ void CInputLogin::CharacterDelete(LPDESC d, const char * data)
502522

503523
sys_log(0, "PlayerDelete: login: %s index: %d, social_id %s", c_rAccountTable.login, pinfo->index, pinfo->private_code);
504524

505-
if (pinfo->index >= PLAYER_PER_ACCOUNT)
525+
if (pinfo->index < 0 || pinfo->index >= PLAYER_PER_ACCOUNT)
506526
{
507527
sys_err("PlayerDelete: index overflow %d, login: %s", pinfo->index, c_rAccountTable.login);
508528
return;

0 commit comments

Comments
 (0)