1
0
Fork 0

Re-added BSD string functions

This commit is contained in:
Exynox 2023-05-01 08:10:00 +03:00
parent a04cd735de
commit 19cc2f3e34
61 changed files with 308 additions and 297 deletions

View File

@ -21,6 +21,9 @@ set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)
target_link_libraries(${PROJECT_NAME} PRIVATE Threads::Threads)
# LibBSD
target_link_libraries(${PROJECT_NAME} PRIVATE bsd)
# Libevent
find_package(Libevent CONFIG REQUIRED)
target_link_libraries(${PROJECT_NAME} PRIVATE libevent::core libevent::extra libevent::pthreads)

View File

@ -61,7 +61,7 @@ bool CBlockCountry::Load()
BLOCK_IP *block_ip = new BLOCK_IP;
block_ip->ip_from = strtoul(row[0], NULL, 10);
block_ip->ip_to = strtoul(row[1], NULL, 10);
strncpy(block_ip->country, row[2], sizeof(block_ip->country));
strlcpy(block_ip->country, row[2], sizeof(block_ip->country));
m_block_ip.push_back(block_ip);
sys_log(0, "BLOCKED_IP : %u - %u", block_ip->ip_from, block_ip->ip_to);
@ -174,7 +174,7 @@ void CBlockCountry::SendBlockExceptionOne(CPeer *peer, const char *login, BYTE c
TPacketBlockException packet;
packet.cmd = cmd;
strncpy(packet.login, login, sizeof(packet.login));
strlcpy(packet.login, login, sizeof(packet.login));
peer->EncodeHeader(HEADER_DG_BLOCK_EXCEPTION, 0, sizeof(TPacketBlockException));
peer->Encode(&packet, sizeof(packet));

View File

@ -192,7 +192,7 @@ bool CClientManager::Initialize()
char szBindIP[128];
if (!CConfig::instance().GetValue("BIND_IP", szBindIP, 128))
strncpy(szBindIP, "0", sizeof(szBindIP));
strlcpy(szBindIP, "0", sizeof(szBindIP));
// Create a new libevent base and listen for new connections
m_base = event_base_new();
@ -569,11 +569,11 @@ void CClientManager::QUERY_QUEST_SAVE(CPeer * pkPeer, TQuestTable * pTable, DWOR
void CClientManager::QUERY_SAFEBOX_LOAD(CPeer * pkPeer, DWORD dwHandle, TSafeboxLoadPacket * packet, bool bMall)
{
ClientHandleInfo * pi = new ClientHandleInfo(dwHandle);
strncpy(pi->safebox_password, packet->szPassword, sizeof(pi->safebox_password));
strlcpy(pi->safebox_password, packet->szPassword, sizeof(pi->safebox_password));
pi->account_id = packet->dwID;
pi->account_index = 0;
pi->ip[0] = bMall ? 1 : 0;
strncpy(pi->login, packet->szLogin, sizeof(pi->login));
strlcpy(pi->login, packet->szLogin, sizeof(pi->login));
char szQuery[QUERY_MAX_LEN];
snprintf(szQuery, sizeof(szQuery),
@ -599,7 +599,7 @@ void CClientManager::RESULT_SAFEBOX_LOAD(CPeer * pkPeer, SQLMsg * msg)
if (pi->account_index == 0)
{
char szSafeboxPassword[SAFEBOX_PASSWORD_MAX_LEN + 1];
strncpy(szSafeboxPassword, pi->safebox_password, sizeof(szSafeboxPassword));
strlcpy(szSafeboxPassword, pi->safebox_password, sizeof(szSafeboxPassword));
TSafeboxTable * pSafebox = new TSafeboxTable;
memset(pSafebox, 0, sizeof(TSafeboxTable));
@ -939,8 +939,8 @@ void CClientManager::RESULT_SAFEBOX_CHANGE_SIZE(CPeer * pkPeer, SQLMsg * msg)
void CClientManager::QUERY_SAFEBOX_CHANGE_PASSWORD(CPeer * pkPeer, DWORD dwHandle, TSafeboxChangePasswordPacket * p)
{
ClientHandleInfo * pi = new ClientHandleInfo(dwHandle);
strncpy(pi->safebox_password, p->szNewPassword, sizeof(pi->safebox_password));
strncpy(pi->login, p->szOldPassword, sizeof(pi->login));
strlcpy(pi->safebox_password, p->szNewPassword, sizeof(pi->safebox_password));
strlcpy(pi->login, p->szOldPassword, sizeof(pi->login));
pi->account_id = p->dwID;
char szQuery[QUERY_MAX_LEN];
@ -1167,7 +1167,7 @@ void CClientManager::QUERY_SETUP(CPeer * peer, DWORD dwHandle, const char * c_pD
//
TMapLocation kMapLocations;
strncpy(kMapLocations.szHost, peer->GetPublicIP(), sizeof(kMapLocations.szHost));
strlcpy(kMapLocations.szHost, peer->GetPublicIP(), sizeof(kMapLocations.szHost));
kMapLocations.wPort = peer->GetListenPort();
memcpy(kMapLocations.alMaps, peer->GetMaps(), sizeof(kMapLocations.alMaps));
@ -1190,7 +1190,7 @@ void CClientManager::QUERY_SETUP(CPeer * peer, DWORD dwHandle, const char * c_pD
if (tmp->GetChannel() == GUILD_WARP_WAR_CHANNEL || tmp->GetChannel() == peer->GetChannel())
{
TMapLocation kMapLocation2;
strncpy(kMapLocation2.szHost, tmp->GetPublicIP(), sizeof(kMapLocation2.szHost));
strlcpy(kMapLocation2.szHost, tmp->GetPublicIP(), sizeof(kMapLocation2.szHost));
kMapLocation2.wPort = tmp->GetListenPort();
memcpy(kMapLocation2.alMaps, tmp->GetMaps(), sizeof(kMapLocation2.alMaps));
vec_kMapLocations.push_back(kMapLocation2);
@ -1217,7 +1217,7 @@ void CClientManager::QUERY_SETUP(CPeer * peer, DWORD dwHandle, const char * c_pD
if (tmp->GetChannel() == 1 || tmp->GetChannel() == peer->GetChannel())
{
TMapLocation kMapLocation2;
strncpy(kMapLocation2.szHost, tmp->GetPublicIP(), sizeof(kMapLocation2.szHost));
strlcpy(kMapLocation2.szHost, tmp->GetPublicIP(), sizeof(kMapLocation2.szHost));
kMapLocation2.wPort = tmp->GetListenPort();
memcpy(kMapLocation2.alMaps, tmp->GetMaps(), sizeof(kMapLocation2.alMaps));
vec_kMapLocations.push_back(kMapLocation2);
@ -1245,7 +1245,7 @@ void CClientManager::QUERY_SETUP(CPeer * peer, DWORD dwHandle, const char * c_pD
{
TMapLocation kMapLocation2;
strncpy(kMapLocation2.szHost, tmp->GetPublicIP(), sizeof(kMapLocation2.szHost));
strlcpy(kMapLocation2.szHost, tmp->GetPublicIP(), sizeof(kMapLocation2.szHost));
kMapLocation2.wPort = tmp->GetListenPort();
memcpy(kMapLocation2.alMaps, tmp->GetMaps(), sizeof(kMapLocation2.alMaps));
@ -1277,7 +1277,7 @@ void CClientManager::QUERY_SETUP(CPeer * peer, DWORD dwHandle, const char * c_pD
TPacketDGP2P p2pSetupPacket;
p2pSetupPacket.wPort = peer->GetP2PPort();
p2pSetupPacket.bChannel = peer->GetChannel();
strncpy(p2pSetupPacket.szHost, peer->GetPublicIP(), sizeof(p2pSetupPacket.szHost));
strlcpy(p2pSetupPacket.szHost, peer->GetPublicIP(), sizeof(p2pSetupPacket.szHost));
for (itertype(m_peerList) i = m_peerList.begin(); i != m_peerList.end();++i)
{
@ -1312,8 +1312,8 @@ void CClientManager::QUERY_SETUP(CPeer * peer, DWORD dwHandle, const char * c_pD
r.id = pck->dwID;
trim_and_lower(pck->szLogin, r.login, sizeof(r.login));
strncpy(r.social_id, pck->szSocialID, sizeof(r.social_id));
strncpy(r.passwd, "TEMP", sizeof(r.passwd));
strlcpy(r.social_id, pck->szSocialID, sizeof(r.social_id));
strlcpy(r.passwd, "TEMP", sizeof(r.passwd));
InsertLoginData(pkLD);
@ -1326,8 +1326,8 @@ void CClientManager::QUERY_SETUP(CPeer * peer, DWORD dwHandle, const char * c_pD
{
TPacketBillingRepair pck_repair;
pck_repair.dwLoginKey = pkLD->GetKey();
strncpy(pck_repair.szLogin, pck->szLogin, sizeof(pck_repair.szLogin));
strncpy(pck_repair.szHost, pck->szHost, sizeof(pck_repair.szHost));
strlcpy(pck_repair.szLogin, pck->szLogin, sizeof(pck_repair.szLogin));
strlcpy(pck_repair.szHost, pck->szHost, sizeof(pck_repair.szHost));
vec_repair.push_back(pck_repair);
}
}
@ -1877,8 +1877,8 @@ void CClientManager::QUERY_AUTH_LOGIN(CPeer * pkPeer, DWORD dwHandle, TPacketGDA
r.id = p->dwID;
trim_and_lower(p->szLogin, r.login, sizeof(r.login));
strncpy(r.social_id, p->szSocialID, sizeof(r.social_id));
strncpy(r.passwd, "TEMP", sizeof(r.passwd));
strlcpy(r.social_id, p->szSocialID, sizeof(r.social_id));
strlcpy(r.passwd, "TEMP", sizeof(r.passwd));
sys_log(0, "AUTH_LOGIN id(%u) login(%s) social_id(%s) login_key(%u), client_key(%u %u %u %u)",
p->dwID, p->szLogin, p->szSocialID, p->dwLoginKey,
@ -1918,7 +1918,7 @@ void CClientManager::BillingExpire(TPacketBillingExpire * p)
if (pkPeer)
{
strncpy(p->szLogin, pkLD->GetAccountRef().login, sizeof(p->szLogin));
strlcpy(p->szLogin, pkLD->GetAccountRef().login, sizeof(p->szLogin));
pkPeer->EncodeHeader(HEADER_DG_BILLING_EXPIRE, 0, sizeof(TPacketBillingExpire));
pkPeer->Encode(p, sizeof(TPacketBillingExpire));
}
@ -2031,8 +2031,8 @@ void CClientManager::SendAllLoginToBilling()
CLoginData * pkLD = (it++)->second;
p.dwLoginKey = pkLD->GetKey();
strncpy(p.szLogin, pkLD->GetAccountRef().login, sizeof(p.szLogin));
strncpy(p.szHost, pkLD->GetIP(), sizeof(p.szHost));
strlcpy(p.szLogin, pkLD->GetAccountRef().login, sizeof(p.szLogin));
strlcpy(p.szHost, pkLD->GetIP(), sizeof(p.szHost));
sys_log(0, "SendAllLoginToBilling %s %s", pkLD->GetAccountRef().login, pkLD->GetIP());
vec.push_back(p);
}
@ -3351,8 +3351,8 @@ bool CClientManager::InitializeLocalization()
int col = 0;
tLocale locale;
strncpy(locale.szValue, row[col++], sizeof(locale.szValue));
strncpy(locale.szKey, row[col++], sizeof(locale.szKey));
strlcpy(locale.szValue, row[col++], sizeof(locale.szValue));
strlcpy(locale.szKey, row[col++], sizeof(locale.szKey));
//DB_NAME_COLUMN Setting
if (strcmp(locale.szKey, "LOCALE") == 0)
@ -3750,9 +3750,9 @@ bool CClientManager::__GetAdminInfo(const char *szIP, std::vector<tAdminInfo> &
str_to_number(Info.m_ID, row[idx++]);
trim_and_lower(row[idx++], Info.m_szAccount, sizeof(Info.m_szAccount));
strncpy(Info.m_szName, row[idx++], sizeof(Info.m_szName));
strncpy(Info.m_szContactIP, row[idx++], sizeof(Info.m_szContactIP));
strncpy(Info.m_szServerIP, row[idx++], sizeof(Info.m_szServerIP));
strlcpy(Info.m_szName, row[idx++], sizeof(Info.m_szName));
strlcpy(Info.m_szContactIP, row[idx++], sizeof(Info.m_szContactIP));
strlcpy(Info.m_szServerIP, row[idx++], sizeof(Info.m_szServerIP));
std::string stAuth = row[idx++];
if (!stAuth.compare("IMPLEMENTOR"))
@ -4073,7 +4073,7 @@ void CClientManager::RMCandidacy(CPeer * peer, DWORD dwHandle, const char * data
{
char szName[32];
strncpy(szName, data, sizeof(szName));
strlcpy(szName, data, sizeof(szName));
sys_log(0, "[MONARCH_GM] Remove candidacy name(%s)", szName);
int iRet = CMonarch::instance().DelCandidacy(szName) ? 1 : 0;
@ -4114,7 +4114,7 @@ void CClientManager::SetMonarch(CPeer * peer, DWORD dwHandle, const char * data)
{
char szName[32];
strncpy(szName, data, sizeof(szName));
strlcpy(szName, data, sizeof(szName));
if (g_test_server)
sys_log(0, "[MONARCH_GM] Set Monarch name(%s)", szName);
@ -4157,7 +4157,7 @@ void CClientManager::RMMonarch(CPeer * peer, DWORD dwHandle, const char * data)
{
char szName[32];
strncpy(szName, data, sizeof(szName));
strlcpy(szName, data, sizeof(szName));
if (g_test_server)
sys_log(0, "[MONARCH_GM] Remove Monarch name(%s)", szName);
@ -4216,8 +4216,8 @@ void CClientManager::ChangeMonarchLord(CPeer * peer, DWORD dwHandle, TPacketChan
ack.dwPID = info->dwPID;
MYSQL_ROW row = mysql_fetch_row(pMsg->Get()->pSQLResult);
strncpy(ack.szName, row[0], sizeof(ack.szName));
strncpy(ack.szDate, row[1], sizeof(ack.szDate));
strlcpy(ack.szName, row[0], sizeof(ack.szName));
strlcpy(ack.szDate, row[1], sizeof(ack.szDate));
snprintf(szQuery, sizeof(szQuery), "UPDATE monarch SET pid=%u, windate=NOW() WHERE empire=%d", ack.dwPID, ack.bEmpire);
SQLMsg* pMsg2 = CDBManager::instance().DirectQuery(szQuery, SQL_PLAYER);

View File

@ -312,8 +312,8 @@ bool CClientManager::InitializeMobTable()
TMobTable *tempTable = it_map_mobTable->second;
mob_table->dwVnum = tempTable->dwVnum;
strncpy(mob_table->szName, tempTable->szName, sizeof(tempTable->szName));
strncpy(mob_table->szLocaleName, tempTable->szLocaleName, sizeof(tempTable->szName));
strlcpy(mob_table->szName, tempTable->szName, sizeof(tempTable->szName));
strlcpy(mob_table->szLocaleName, tempTable->szLocaleName, sizeof(tempTable->szName));
mob_table->bRank = tempTable->bRank;
mob_table->bType = tempTable->bType;
mob_table->bBattleType = tempTable->bBattleType;
@ -323,7 +323,7 @@ bool CClientManager::InitializeMobTable()
mob_table->dwRaceFlag = tempTable->dwRaceFlag;
mob_table->dwImmuneFlag = tempTable->dwImmuneFlag;
mob_table->bEmpire = tempTable->bEmpire;
strncpy(mob_table->szFolder, tempTable->szFolder, sizeof(tempTable->szName));
strlcpy(mob_table->szFolder, tempTable->szFolder, sizeof(tempTable->szName));
mob_table->bOnClickType = tempTable->bOnClickType;
mob_table->bStr = tempTable->bStr;
mob_table->bDex = tempTable->bDex;
@ -545,12 +545,12 @@ bool CClientManager::InitializeQuestItemTable()
str_to_number(tbl.dwVnum, row[col++]);
if (row[col])
strncpy(tbl.szName, row[col], sizeof(tbl.szName));
strlcpy(tbl.szName, row[col], sizeof(tbl.szName));
col++;
if (row[col])
strncpy(tbl.szLocaleName, row[col], sizeof(tbl.szLocaleName));
strlcpy(tbl.szLocaleName, row[col], sizeof(tbl.szLocaleName));
col++;
@ -724,8 +724,8 @@ bool CClientManager::InitializeItemTable()
TItemTable *tempTable = it_map_itemTable->second;
item_table->dwVnum = tempTable->dwVnum;
strncpy(item_table->szName, tempTable->szName, sizeof(item_table->szName));
strncpy(item_table->szLocaleName, tempTable->szLocaleName, sizeof(item_table->szLocaleName));
strlcpy(item_table->szName, tempTable->szName, sizeof(item_table->szName));
strlcpy(item_table->szLocaleName, tempTable->szLocaleName, sizeof(item_table->szLocaleName));
item_table->bType = tempTable->bType;
item_table->bSubType = tempTable->bSubType;
item_table->bSize = tempTable->bSize;
@ -888,33 +888,33 @@ bool CClientManager::InitializeSkillTable()
col = 0;
str_to_number(t.dwVnum, data[col++]);
strncpy(t.szName, data[col++], sizeof(t.szName));
strlcpy(t.szName, data[col++], sizeof(t.szName));
str_to_number(t.bType, data[col++]);
str_to_number(t.bMaxLevel, data[col++]);
str_to_number(t.dwSplashRange, data[col++]);
strncpy(t.szPointOn, data[col++], sizeof(t.szPointOn));
strncpy(t.szPointPoly, data[col++], sizeof(t.szPointPoly));
strncpy(t.szSPCostPoly, data[col++], sizeof(t.szSPCostPoly));
strncpy(t.szDurationPoly, data[col++], sizeof(t.szDurationPoly));
strncpy(t.szDurationSPCostPoly, data[col++], sizeof(t.szDurationSPCostPoly));
strncpy(t.szCooldownPoly, data[col++], sizeof(t.szCooldownPoly));
strncpy(t.szMasterBonusPoly, data[col++], sizeof(t.szMasterBonusPoly));
strlcpy(t.szPointOn, data[col++], sizeof(t.szPointOn));
strlcpy(t.szPointPoly, data[col++], sizeof(t.szPointPoly));
strlcpy(t.szSPCostPoly, data[col++], sizeof(t.szSPCostPoly));
strlcpy(t.szDurationPoly, data[col++], sizeof(t.szDurationPoly));
strlcpy(t.szDurationSPCostPoly, data[col++], sizeof(t.szDurationSPCostPoly));
strlcpy(t.szCooldownPoly, data[col++], sizeof(t.szCooldownPoly));
strlcpy(t.szMasterBonusPoly, data[col++], sizeof(t.szMasterBonusPoly));
str_to_number(t.dwFlag, data[col++]);
str_to_number(t.dwAffectFlag, data[col++]);
strncpy(t.szPointOn2, data[col++], sizeof(t.szPointOn2));
strncpy(t.szPointPoly2, data[col++], sizeof(t.szPointPoly2));
strncpy(t.szDurationPoly2, data[col++], sizeof(t.szDurationPoly2));
strlcpy(t.szPointOn2, data[col++], sizeof(t.szPointOn2));
strlcpy(t.szPointPoly2, data[col++], sizeof(t.szPointPoly2));
strlcpy(t.szDurationPoly2, data[col++], sizeof(t.szDurationPoly2));
str_to_number(t.dwAffectFlag2, data[col++]);
// ADD_GRANDMASTER_SKILL
strncpy(t.szPointOn3, data[col++], sizeof(t.szPointOn3));
strncpy(t.szPointPoly3, data[col++], sizeof(t.szPointPoly3));
strncpy(t.szDurationPoly3, data[col++], sizeof(t.szDurationPoly3));
strlcpy(t.szPointOn3, data[col++], sizeof(t.szPointOn3));
strlcpy(t.szPointPoly3, data[col++], sizeof(t.szPointPoly3));
strlcpy(t.szDurationPoly3, data[col++], sizeof(t.szDurationPoly3));
strncpy(t.szGrandMasterAddSPCostPoly, data[col++], sizeof(t.szGrandMasterAddSPCostPoly));
strlcpy(t.szGrandMasterAddSPCostPoly, data[col++], sizeof(t.szGrandMasterAddSPCostPoly));
// END_OF_ADD_GRANDMASTER_SKILL
str_to_number(t.bLevelStep, data[col++]);
@ -924,7 +924,7 @@ bool CClientManager::InitializeSkillTable()
str_to_number(t.lMaxHit, data[col++]);
strncpy(t.szSplashAroundDamageAdjustPoly, data[col++], sizeof(t.szSplashAroundDamageAdjustPoly));
strlcpy(t.szSplashAroundDamageAdjustPoly, data[col++], sizeof(t.szSplashAroundDamageAdjustPoly));
str_to_number(t.bSkillAttrType, data[col++]);
str_to_number(t.dwTargetRange, data[col++]);
@ -956,7 +956,7 @@ bool CClientManager::InitializeBanwordTable()
if (data[0])
{
strncpy(t.szWord, data[0], sizeof(t.szWord));
strlcpy(t.szWord, data[0], sizeof(t.szWord));
m_vec_banwordTable.push_back(t);
}
}
@ -999,7 +999,7 @@ bool CClientManager::InitializeItemAttrTable()
int col = 0;
strncpy(t.szApply, data[col++], sizeof(t.szApply));
strlcpy(t.szApply, data[col++], sizeof(t.szApply));
str_to_number(t.dwApplyIndex, data[col++]);
str_to_number(t.dwProb, data[col++]);
str_to_number(t.lValues[0], data[col++]);
@ -1073,7 +1073,7 @@ bool CClientManager::InitializeItemRareTable()
int col = 0;
strncpy(t.szApply, data[col++], sizeof(t.szApply));
strlcpy(t.szApply, data[col++], sizeof(t.szApply));
str_to_number(t.dwApplyIndex, data[col++]);
str_to_number(t.dwProb, data[col++]);
str_to_number(t.lValues[0], data[col++]);
@ -1178,7 +1178,7 @@ void parse_pair_number_string(const char * c_pszString, std::vector<std::pair<in
{
if (isdigit(*t))
{
strncpy(szNum, t, std::min<size_t>(sizeof(szNum), (p-t)+1));
strlcpy(szNum, t, std::min<size_t>(sizeof(szNum), (p-t)+1));
comma = strchr(szNum, ',');
@ -1200,7 +1200,7 @@ void parse_pair_number_string(const char * c_pszString, std::vector<std::pair<in
if (isdigit(*t))
{
strncpy(szNum, t, sizeof(szNum));
strlcpy(szNum, t, sizeof(szNum));
comma = strchr(const_cast<char*>(t), ',');

View File

@ -19,7 +19,7 @@ void CClientManager::LoadEventFlag()
while ((row = mysql_fetch_row(pRes->pSQLResult)))
{
TPacketSetEventFlag p;
strncpy(p.szFlagName, row[0], sizeof(p.szFlagName));
strlcpy(p.szFlagName, row[0], sizeof(p.szFlagName));
str_to_number(p.lValue, row[1]);
sys_log(0, "EventFlag Load %s %d", p.szFlagName, p.lValue);
m_map_lEventFlag.insert(std::make_pair(std::string(p.szFlagName), p.lValue));
@ -68,7 +68,7 @@ void CClientManager::SendEventFlagsOnSetup(CPeer* peer)
for (it = m_map_lEventFlag.begin(); it != m_map_lEventFlag.end(); ++it)
{
TPacketSetEventFlag p;
strncpy(p.szFlagName, it->first.c_str(), sizeof(p.szFlagName));
strlcpy(p.szFlagName, it->first.c_str(), sizeof(p.szFlagName));
p.lValue = it->second;
peer->EncodeHeader(HEADER_DG_SET_EVENT_FLAG, 0, sizeof(TPacketSetEventFlag));
peer->Encode(&p, sizeof(TPacketSetEventFlag));

View File

@ -60,7 +60,7 @@ void CClientManager::GuildAddMember(CPeer* peer, TPacketGDGuildAddMember * p)
str_to_number(dg.dwOffer, row[3]);
str_to_number(dg.bLevel, row[4]);
str_to_number(dg.bJob, row[5]);
strncpy(dg.szName, row[6], sizeof(dg.szName));
strlcpy(dg.szName, row[6], sizeof(dg.szName));
ForwardPacket(HEADER_DG_GUILD_ADD_MEMBER, &dg, sizeof(TPacketDGGuildMember));
}

View File

@ -31,7 +31,7 @@ void CClientManager::AckHorseName(DWORD dwPID, CPeer* peer)
else
{
MYSQL_ROW row = mysql_fetch_row(pmsg->Get()->pSQLResult);
strncpy(packet.szHorseName, row[0], sizeof(packet.szHorseName));
strlcpy(packet.szHorseName, row[0], sizeof(packet.szHorseName));
}
peer->EncodeHeader(HEADER_DG_ACK_HORSE_NAME, 0, sizeof(TPacketUpdateHorseName));

View File

@ -98,7 +98,7 @@ void CClientManager::QUERY_LOGIN_BY_KEY(CPeer * pkPeer, DWORD dwHandle, TPacketG
{
sys_log(0, "LOGIN_BY_KEY already login %s %lu", r.login, p->dwLoginKey);
TPacketDGLoginAlready ptog;
strncpy(ptog.szLogin, szLogin, sizeof(ptog.szLogin));
strlcpy(ptog.szLogin, szLogin, sizeof(ptog.szLogin));
pkPeer->EncodeHeader(HEADER_DG_LOGIN_ALREADY, dwHandle, sizeof(TPacketDGLoginAlready));
pkPeer->Encode(&ptog, sizeof(TPacketDGLoginAlready));
return;
@ -129,13 +129,13 @@ void CClientManager::QUERY_LOGIN_BY_KEY(CPeer * pkPeer, DWORD dwHandle, TPacketG
pkTab->id = r.id;
trim_and_lower(r.login, pkTab->login, sizeof(pkTab->login));
strncpy(pkTab->passwd, r.passwd, sizeof(pkTab->passwd));
strncpy(pkTab->social_id, r.social_id, sizeof(pkTab->social_id));
strncpy(pkTab->status, "OK", sizeof(pkTab->status));
strlcpy(pkTab->passwd, r.passwd, sizeof(pkTab->passwd));
strlcpy(pkTab->social_id, r.social_id, sizeof(pkTab->social_id));
strlcpy(pkTab->status, "OK", sizeof(pkTab->status));
ClientHandleInfo * info = new ClientHandleInfo(dwHandle);
info->pAccountTable = pkTab;
strncpy(info->ip, p->szIP, sizeof(info->ip));
strlcpy(info->ip, p->szIP, sizeof(info->ip));
sys_log(0, "LOGIN_BY_KEY success %s %lu %s", r.login, p->dwLoginKey, info->ip);
char szQuery[QUERY_MAX_LEN];
@ -232,17 +232,17 @@ TAccountTable * CreateAccountTableFromRes(MYSQL_RES * res)
memset(pkTab, 0, sizeof(TAccountTable));
// 첫번째 컬럼 것만 참고 한다 (JOIN QUERY를 위한 것 임)
strncpy(input_pwd, row[col++], sizeof(input_pwd));
strlcpy(input_pwd, row[col++], sizeof(input_pwd));
str_to_number(pkTab->id, row[col++]);
strncpy(pkTab->login, row[col++], sizeof(pkTab->login));
strncpy(pkTab->passwd, row[col++], sizeof(pkTab->passwd));
strncpy(pkTab->social_id, row[col++], sizeof(pkTab->social_id));
strlcpy(pkTab->login, row[col++], sizeof(pkTab->login));
strlcpy(pkTab->passwd, row[col++], sizeof(pkTab->passwd));
strlcpy(pkTab->social_id, row[col++], sizeof(pkTab->social_id));
str_to_number(pkTab->bEmpire, row[col++]);
for (int j = 0; j < PLAYER_PER_ACCOUNT; ++j)
str_to_number(pkTab->players[j].dwID, row[col++]);
strncpy(pkTab->status, row[col++], sizeof(pkTab->status));
strlcpy(pkTab->status, row[col++], sizeof(pkTab->status));
if (strcmp(pkTab->passwd, input_pwd))
{
@ -280,7 +280,7 @@ void CreateAccountPlayerDataFromRes(MYSQL_RES * pRes, TAccountTable * pkTab)
if (pt)
{
strncpy(pkTab->players[j].szName, pt->name, sizeof(pkTab->players[j].szName));
strlcpy(pkTab->players[j].szName, pt->name, sizeof(pkTab->players[j].szName));
pkTab->players[j].byJob = pt->job;
pkTab->players[j].byLevel = pt->level;
@ -301,7 +301,7 @@ void CreateAccountPlayerDataFromRes(MYSQL_RES * pRes, TAccountTable * pkTab)
if (!row[col++])
*pkTab->players[j].szName = '\0';
else
strncpy(pkTab->players[j].szName, row[col - 1], sizeof(pkTab->players[j].szName));
strlcpy(pkTab->players[j].szName, row[col - 1], sizeof(pkTab->players[j].szName));
pkTab->players[j].byJob = 0;
pkTab->players[j].byLevel = 0;
@ -410,7 +410,7 @@ void CClientManager::RESULT_LOGIN(CPeer * peer, SQLMsg * msg)
sys_log(0, "RESULT_LOGIN: already logon %s", info->pAccountTable->login);
TPacketDGLoginAlready p;
strncpy(p.szLogin, info->pAccountTable->login, sizeof(p.szLogin));
strlcpy(p.szLogin, info->pAccountTable->login, sizeof(p.szLogin));
peer->EncodeHeader(HEADER_DG_LOGIN_ALREADY, info->dwHandle, sizeof(TPacketDGLoginAlready));
peer->Encode(&p, sizeof(p));
@ -520,7 +520,7 @@ void CClientManager::QUERY_CHANGE_NAME(CPeer * peer, DWORD dwHandle, TPacketGDCh
TPacketDGChangeName pdg;
peer->EncodeHeader(HEADER_DG_CHANGE_NAME, dwHandle, sizeof(TPacketDGChangeName));
pdg.pid = p->pid;
strncpy(pdg.name, p->name, sizeof(pdg.name));
strlcpy(pdg.name, p->name, sizeof(pdg.name));
peer->Encode(&pdg, sizeof(TPacketDGChangeName));
}

View File

@ -405,7 +405,7 @@ void CClientManager::QUERY_PLAYER_LOAD(CPeer * peer, DWORD dwHandle, TPlayerLoad
void CClientManager::ItemAward(CPeer * peer,char* login)
{
char login_t[LOGIN_MAX_LEN + 1] = "";
strncpy(login_t,login,LOGIN_MAX_LEN + 1);
strlcpy(login_t,login,LOGIN_MAX_LEN + 1);
std::set<TItemAward *> * pSet = ItemAwardManager::instance().GetByLogin(login_t);
if(pSet == NULL)
return;
@ -458,7 +458,7 @@ bool CreatePlayerTableFromRes(MYSQL_RES * res, TPlayerTable * pkTab)
// "stat_point,skill_point,sub_skill_point,stat_reset_count,part_base,part_hair,"
// "skill_level,quickslot,skill_group,alignment,mobile,horse_level,horse_riding,horse_hp,horse_stamina FROM player%s WHERE id=%d",
str_to_number(pkTab->id, row[col++]);
strncpy(pkTab->name, row[col++], sizeof(pkTab->name));
strlcpy(pkTab->name, row[col++], sizeof(pkTab->name));
str_to_number(pkTab->job, row[col++]);
str_to_number(pkTab->voice, row[col++]);
str_to_number(pkTab->dir, row[col++]);
@ -509,7 +509,7 @@ bool CreatePlayerTableFromRes(MYSQL_RES * res, TPlayerTable * pkTab)
if (row[col])
{
strncpy(pkTab->szMobile, row[col], sizeof(pkTab->szMobile));
strlcpy(pkTab->szMobile, row[col], sizeof(pkTab->szMobile));
}
col++;
@ -759,8 +759,8 @@ void CClientManager::RESULT_QUEST_LOAD(CPeer * peer, MYSQL_RES * pRes, DWORD dwH
row = mysql_fetch_row(pRes);
str_to_number(r.dwPID, row[0]);
strncpy(r.szName, row[1], sizeof(r.szName));
strncpy(r.szState, row[2], sizeof(r.szState));
strlcpy(r.szName, row[1], sizeof(r.szName));
strlcpy(r.szState, row[2], sizeof(r.szState));
str_to_number(r.lValue, row[3]);
}
@ -939,7 +939,7 @@ void CClientManager::__QUERY_PLAYER_CREATE(CPeer *peer, DWORD dwHandle, TPlayerC
pack.bAccountCharacterIndex = packet->account_index;
pack.player.dwID = player_id;
strncpy(pack.player.szName, packet->player_table.name, sizeof(pack.player.szName));
strlcpy(pack.player.szName, packet->player_table.name, sizeof(pack.player.szName));
pack.player.byJob = packet->player_table.job;
pack.player.byLevel = 1;
pack.player.dwPlayMinutes = 0;
@ -1045,7 +1045,7 @@ void CClientManager::__RESULT_PLAYER_DELETE(CPeer *peer, SQLMsg* msg)
str_to_number(deletedLevelLimit, row[1]);
char szName[64];
strncpy(szName, row[2], sizeof(szName));
strlcpy(szName, row[2], sizeof(szName));
if (deletedLevelLimit >= m_iPlayerDeleteLevelLimit && !IsChinaEventServer())
{
@ -1220,7 +1220,7 @@ void CClientManager::QUERY_HIGHSCORE_REGISTER(CPeer* peer, TPacketGDHighscore *
sys_log(0, "HEADER_GD_HIGHSCORE_REGISTER: PID %u", data->dwPID);
ClientHandleInfo * pi = new ClientHandleInfo(0);
strncpy(pi->login, data->szBoard, sizeof(pi->login));
strlcpy(pi->login, data->szBoard, sizeof(pi->login));
pi->account_id = (DWORD)data->lValue;
pi->player_id = data->dwPID;
pi->account_index = (data->cDir > 0);
@ -1235,7 +1235,7 @@ void CClientManager::RESULT_HIGHSCORE_REGISTER(CPeer * pkPeer, SQLMsg * msg)
//DWORD dwHandle = pi->dwHandle;
char szBoard[21];
strncpy(szBoard, pi->login, sizeof(szBoard));
strlcpy(szBoard, pi->login, sizeof(szBoard));
int value = (int)pi->account_id;
SQLResult * res = msg->Get();

View File

@ -117,7 +117,7 @@ bool CConfig::LoadFile(const char* filename)
switch (mode)
{
case 0:
strncpy(comment, szTmp, sizeof(comment));
strlcpy(comment, szTmp, sizeof(comment));
++mode;
break;
@ -229,7 +229,7 @@ bool CConfig::GetValue(const char * key, char *dest, size_t destSize)
if (!Search(key))
return false;
strncpy(dest, Get(key), destSize);
strlcpy(dest, Get(key), destSize);
if (!*dest)
return false;

View File

@ -137,7 +137,7 @@ void CGuildManager::ParseResult(SQLResult * pRes)
TGuild & r_info = TouchGuild(GID);
strncpy(r_info.szName, row[1], sizeof(r_info.szName));
strlcpy(r_info.szName, row[1], sizeof(r_info.szName));
str_to_number(r_info.ladder_point, row[2]);
str_to_number(r_info.win, row[3]);
str_to_number(r_info.draw, row[4]);
@ -1228,7 +1228,7 @@ void CGuildWarReserve::Initialize()
while ((row = mysql_fetch_row(res)))
{
dwGuild = dwGold = 0;
strncpy(szLogin, row[0], sizeof(szLogin));
strlcpy(szLogin, row[0], sizeof(szLogin));
str_to_number(dwGuild, row[1]);
str_to_number(dwGold, row[2]);
@ -1254,7 +1254,7 @@ void CGuildWarReserve::OnSetup(CPeer * peer)
while (it != mapBet.end())
{
strncpy(pckBet.szLogin, it->first.c_str(), sizeof(pckBet.szLogin));
strlcpy(pckBet.szLogin, it->first.c_str(), sizeof(pckBet.szLogin));
pckBet.dwGuild = it->second.first;
pckBet.dwGold = it->second.second;
@ -1316,7 +1316,7 @@ bool CGuildWarReserve::Bet(const char * pszLogin, DWORD dwGold, DWORD dwGuild)
TPacketGDGuildWarBet pckBet;
pckBet.dwWarID = m_data.dwID;
strncpy(pckBet.szLogin, pszLogin, sizeof(pckBet.szLogin));
strlcpy(pckBet.szLogin, pszLogin, sizeof(pckBet.szLogin));
pckBet.dwGuild = dwGuild;
pckBet.dwGold = dwGold;

View File

@ -53,7 +53,7 @@ void ItemAwardManager::Load(SQLMsg * pMsg)
if (row[col])
{
strncpy(kData->szWhy, row[col], sizeof(kData->szWhy));
strlcpy(kData->szWhy, row[col], sizeof(kData->szWhy));
//게임 중에 why콜룸에 변동이 생기면
char* whyStr = kData->szWhy; //why 콜룸 읽기
char cmdStr[100] = ""; //why콜룸에서 읽은 값을 임시 문자열에 복사해둠

View File

@ -66,7 +66,7 @@ DWORD CLoginData::GetLogonTime()
void CLoginData::SetIP(const char * c_pszIP)
{
strncpy(m_szIP, c_pszIP, sizeof(m_szIP));
strlcpy(m_szIP, c_pszIP, sizeof(m_szIP));
}
const char * CLoginData::GetIP()

View File

@ -121,8 +121,8 @@ namespace marriage
p.dwPID1 = dwPID1;
p.dwPID2 = dwPID2;
p.tMarryTime = now;
strncpy(p.szName1, szName1, sizeof(p.szName1));
strncpy(p.szName2, szName2, sizeof(p.szName2));
strlcpy(p.szName1, szName1, sizeof(p.szName1));
strlcpy(p.szName2, szName2, sizeof(p.szName2));
CClientManager::instance().ForwardPacket(HEADER_DG_MARRIAGE_ADD, &p, sizeof(p));
}
@ -263,8 +263,8 @@ namespace marriage
p.dwPID1 = pMarriage->pid1;
p.dwPID2 = pMarriage->pid2;
p.tMarryTime = pMarriage->time;
strncpy(p.szName1, pMarriage->name1.c_str(), sizeof(p.szName1));
strncpy(p.szName2, pMarriage->name2.c_str(), sizeof(p.szName2));
strlcpy(p.szName1, pMarriage->name1.c_str(), sizeof(p.szName1));
strlcpy(p.szName2, pMarriage->name2.c_str(), sizeof(p.szName2));
peer->EncodeHeader(HEADER_DG_MARRIAGE_ADD, 0, sizeof(p));
peer->Encode(&p, sizeof(p));
}

View File

@ -81,7 +81,7 @@ bool CMonarch::AddCandidacy(DWORD pid, const char * name)
MonarchCandidacy info;
info.pid = pid;
strncpy(info.name, name, sizeof(info.name));
strlcpy(info.name, name, sizeof(info.name));
m_vec_MonarchCandidacy.push_back(info);
char szQuery[256];
@ -192,10 +192,10 @@ bool CMonarch::LoadMonarch()
int Empire = 0; str_to_number(Empire, row[idx++]);
str_to_number(p->pid[Empire], row[idx++]);
strncpy(p->name[Empire], row[idx++], sizeof(p->name[Empire]));
strlcpy(p->name[Empire], row[idx++], sizeof(p->name[Empire]));
str_to_number(p->money[Empire], row[idx++]);
strncpy(p->date[Empire], row[idx++], sizeof(p->date[Empire]));
strlcpy(p->date[Empire], row[idx++], sizeof(p->date[Empire]));
if (g_test_server)
sys_log(0, "[LOAD_MONARCH] Empire %d pid %d money %lld windate %s", Empire, p->pid[Empire], p->money[Empire], p->date[Empire]);
@ -227,7 +227,7 @@ bool CMonarch::SetMonarch(const char * name)
str_to_number(Empire, row[idx++]);
str_to_number(p->pid[Empire], row[idx++]);
strncpy(p->name[Empire], row[idx++], sizeof(p->name[Empire]));
strlcpy(p->name[Empire], row[idx++], sizeof(p->name[Empire]));
p->money[Empire] = atoll(row[idx++]);
if (g_test_server)

View File

@ -586,16 +586,16 @@ bool Set_Proto_Mob_Table(TMobTable *mobTable, cCsvTable &csvTable,std::map<int,c
{
int col = 0;
str_to_number(mobTable->dwVnum, csvTable.AsStringByIndex(col++));
strncpy(mobTable->szName, csvTable.AsStringByIndex(col++), sizeof(mobTable->szName));
strlcpy(mobTable->szName, csvTable.AsStringByIndex(col++), sizeof(mobTable->szName));
//3. 지역별 이름 넣어주기.
map<int,const char*>::iterator it;
it = nameMap.find(mobTable->dwVnum);
if (it != nameMap.end()) {
const char * localeName = it->second;
strncpy(mobTable->szLocaleName, localeName, sizeof (mobTable->szLocaleName));
strlcpy(mobTable->szLocaleName, localeName, sizeof (mobTable->szLocaleName));
} else {
strncpy(mobTable->szLocaleName, mobTable->szName, sizeof (mobTable->szLocaleName));
strlcpy(mobTable->szLocaleName, mobTable->szName, sizeof (mobTable->szLocaleName));
}
//RANK
@ -626,7 +626,7 @@ bool Set_Proto_Mob_Table(TMobTable *mobTable, cCsvTable &csvTable,std::map<int,c
str_to_number(mobTable->bEmpire, csvTable.AsStringByIndex(col++)); //col = 11
strncpy(mobTable->szFolder, csvTable.AsStringByIndex(col++), sizeof(mobTable->szFolder));
strlcpy(mobTable->szFolder, csvTable.AsStringByIndex(col++), sizeof(mobTable->szFolder));
str_to_number(mobTable->bOnClickType, csvTable.AsStringByIndex(col++));
@ -776,15 +776,15 @@ bool Set_Proto_Item_Table(TItemTable *itemTable, cCsvTable &csvTable,std::map<in
}
}
strncpy(itemTable->szName, csvTable.AsStringByIndex(1), sizeof(itemTable->szName));
strlcpy(itemTable->szName, csvTable.AsStringByIndex(1), sizeof(itemTable->szName));
//지역별 이름 넣어주기.
map<int,const char*>::iterator it;
it = nameMap.find(itemTable->dwVnum);
if (it != nameMap.end()) {
const char * localeName = it->second;
strncpy(itemTable->szLocaleName, localeName, sizeof (itemTable->szLocaleName));
strlcpy(itemTable->szLocaleName, localeName, sizeof (itemTable->szLocaleName));
} else {
strncpy(itemTable->szLocaleName, itemTable->szName, sizeof (itemTable->szLocaleName));
strlcpy(itemTable->szLocaleName, itemTable->szName, sizeof (itemTable->szLocaleName));
}
itemTable->bType = dataArray[2];
itemTable->bSubType = dataArray[3];

View File

@ -47,6 +47,9 @@ set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package (Threads REQUIRED)
target_link_libraries (${PROJECT_NAME} Threads::Threads)
# LibBSD
target_link_libraries(${PROJECT_NAME} bsd)
# effolkronium/random
find_package(effolkronium_random CONFIG REQUIRED)
target_link_libraries(${PROJECT_NAME} effolkronium_random)

View File

@ -140,7 +140,7 @@ bool COXEventManager::AddQuiz(unsigned char level, const char* pszQuestion, bool
struct tag_Quiz tmpQuiz;
tmpQuiz.level = level;
strncpy(tmpQuiz.Quiz, pszQuestion, sizeof(tmpQuiz.Quiz));
strlcpy(tmpQuiz.Quiz, pszQuestion, sizeof(tmpQuiz.Quiz));
tmpQuiz.answer = answer;
m_vec_quiz[level].push_back(tmpQuiz);

View File

@ -157,27 +157,27 @@ DWORD ANI::load_one_weapon(const char *dir_name, int weapon, BYTE combo, bool ho
switch (weapon)
{
case WEAPON_SWORD:
strncpy(format, "%s/%sonehand_sword/combo_%02d.msa", sizeof(format));
strlcpy(format, "%s/%sonehand_sword/combo_%02d.msa", sizeof(format));
break;
case WEAPON_DAGGER:
strncpy(format, "%s/%sdualhand_sword/combo_%02d.msa", sizeof(format));
strlcpy(format, "%s/%sdualhand_sword/combo_%02d.msa", sizeof(format));
break;
case WEAPON_BOW:
strncpy(format, "%s/%sbow/attack.msa", sizeof(format));
strlcpy(format, "%s/%sbow/attack.msa", sizeof(format));
break;
case WEAPON_TWO_HANDED:
strncpy(format, "%s/%stwohand_sword/combo_%02d.msa", sizeof(format));
strlcpy(format, "%s/%stwohand_sword/combo_%02d.msa", sizeof(format));
break;
case WEAPON_BELL:
strncpy(format, "%s/%sbell/combo_%02d.msa", sizeof(format));
strlcpy(format, "%s/%sbell/combo_%02d.msa", sizeof(format));
break;
case WEAPON_FAN:
strncpy(format, "%s/%sfan/combo_%02d.msa", sizeof(format));
strlcpy(format, "%s/%sfan/combo_%02d.msa", sizeof(format));
break;
default:

View File

@ -597,7 +597,7 @@ void CHARACTER::OpenMyShop(const char * c_pszSign, TShopItemTable * pTable, BYTE
}
char szSign[SHOP_SIGN_MAX_LEN+1];
strncpy(szSign, c_pszSign, sizeof(szSign));
strlcpy(szSign, c_pszSign, sizeof(szSign));
m_stShopSign = szSign;
@ -698,7 +698,7 @@ void CHARACTER::OpenMyShop(const char * c_pszSign, TShopItemTable * pTable, BYTE
p.bHeader = HEADER_GC_SHOP_SIGN;
p.dwVID = GetVID();
strncpy(p.szSign, c_pszSign, sizeof(p.szSign));
strlcpy(p.szSign, c_pszSign, sizeof(p.szSign));
PacketAround(&p, sizeof(TPacketGCShopSign));
@ -894,7 +894,7 @@ void CHARACTER::EncodeInsertPacket(LPENTITY entity)
else
{
show_all_info:
strncpy(addPacket.name, GetName(), sizeof(addPacket.name));
strlcpy(addPacket.name, GetName(), sizeof(addPacket.name));
if (GetGuild() != NULL)
{
@ -944,7 +944,7 @@ void CHARACTER::EncodeInsertPacket(LPENTITY entity)
p.bHeader = HEADER_GC_SHOP_SIGN;
p.dwVID = GetVID();
strncpy(p.szSign, m_stShopSign.c_str(), sizeof(p.szSign));
strlcpy(p.szSign, m_stShopSign.c_str(), sizeof(p.szSign));
d->Packet(&p, sizeof(TPacketGCShopSign));
}
@ -1127,14 +1127,14 @@ void CHARACTER::CreatePlayerProto(TPlayerTable & tab)
if (GetNewName().empty())
{
strncpy(tab.name, GetName(), sizeof(tab.name));
strlcpy(tab.name, GetName(), sizeof(tab.name));
}
else
{
strncpy(tab.name, GetNewName().c_str(), sizeof(tab.name));
strlcpy(tab.name, GetNewName().c_str(), sizeof(tab.name));
}
strncpy(tab.ip, GetDesc()->GetHostName(), sizeof(tab.ip));
strlcpy(tab.ip, GetDesc()->GetHostName(), sizeof(tab.ip));
tab.id = m_dwPlayerID;
tab.voice = GetPoint(POINT_VOICE);
@ -1224,7 +1224,7 @@ void CHARACTER::CreatePlayerProto(TPlayerTable & tab)
tab.quickslot[i] = m_quickslot[i];
if (m_stMobile.length() && !*m_szMobileAuth)
strncpy(tab.szMobile, m_stMobile.c_str(), sizeof(tab.szMobile));
strlcpy(tab.szMobile, m_stMobile.c_str(), sizeof(tab.szMobile));
memcpy(tab.parts, m_pointsInstant.parts, sizeof(tab.parts));
@ -1303,7 +1303,7 @@ void CHARACTER::Disconnect(const char * c_pszReason)
// P2P Logout
TPacketGGLogout p;
p.bHeader = HEADER_GG_LOGOUT;
strncpy(p.szName, GetName(), sizeof(p.szName));
strlcpy(p.szName, GetName(), sizeof(p.szName));
P2P_MANAGER::instance().Send(&p, sizeof(TPacketGGLogout));
char buf[51];
snprintf(buf, sizeof(buf), "%s %d %d %d %d",
@ -1534,10 +1534,10 @@ void CHARACTER::MainCharacterPacket()
mainChrPacket.lz = GetZ();
mainChrPacket.empire = GetDesc()->GetEmpire();
mainChrPacket.skill_group = GetSkillGroup();
strncpy(mainChrPacket.szChrName, GetName(), sizeof(mainChrPacket.szChrName));
strlcpy(mainChrPacket.szChrName, GetName(), sizeof(mainChrPacket.szChrName));
mainChrPacket.fBGMVol = bgmInfo.vol;
strncpy(mainChrPacket.szBGMName, bgmInfo.name.c_str(), sizeof(mainChrPacket.szBGMName));
strlcpy(mainChrPacket.szBGMName, bgmInfo.name.c_str(), sizeof(mainChrPacket.szBGMName));
GetDesc()->Packet(&mainChrPacket, sizeof(TPacketGCMainCharacter4_BGM_VOL));
}
else
@ -1552,8 +1552,8 @@ void CHARACTER::MainCharacterPacket()
mainChrPacket.lz = GetZ();
mainChrPacket.empire = GetDesc()->GetEmpire();
mainChrPacket.skill_group = GetSkillGroup();
strncpy(mainChrPacket.szChrName, GetName(), sizeof(mainChrPacket.szChrName));
strncpy(mainChrPacket.szBGMName, bgmInfo.name.c_str(), sizeof(mainChrPacket.szBGMName));
strlcpy(mainChrPacket.szChrName, GetName(), sizeof(mainChrPacket.szChrName));
strlcpy(mainChrPacket.szBGMName, bgmInfo.name.c_str(), sizeof(mainChrPacket.szBGMName));
GetDesc()->Packet(&mainChrPacket, sizeof(TPacketGCMainCharacter3_BGM));
}
//if (m_stMobile.length())
@ -1573,7 +1573,7 @@ void CHARACTER::MainCharacterPacket()
pack.lz = GetZ();
pack.empire = GetDesc()->GetEmpire();
pack.skill_group = GetSkillGroup();
strncpy(pack.szName, GetName(), sizeof(pack.szName));
strlcpy(pack.szName, GetName(), sizeof(pack.szName));
GetDesc()->Packet(&pack, sizeof(TPacketGCMainCharacter));
if (m_stMobile.length())
@ -5306,7 +5306,7 @@ void CHARACTER::WarpEnd()
TPacketGGLogin p;
p.bHeader = HEADER_GG_LOGIN;
strncpy(p.szName, GetName(), sizeof(p.szName));
strlcpy(p.szName, GetName(), sizeof(p.szName));
p.dwPID = GetPlayerID();
p.bEmpire = GetEmpire();
p.lMapIndex = SECTREE_MANAGER::instance().GetMapIndex(GetX(), GetY());
@ -5552,8 +5552,8 @@ void CHARACTER::ReqSafeboxLoad(const char* pszPassword)
TSafeboxLoadPacket p;
p.dwID = GetDesc()->GetAccountTable().id;
strncpy(p.szLogin, GetDesc()->GetAccountTable().login, sizeof(p.szLogin));
strncpy(p.szPassword, pszPassword, sizeof(p.szPassword));
strlcpy(p.szLogin, GetDesc()->GetAccountTable().login, sizeof(p.szLogin));
strlcpy(p.szPassword, pszPassword, sizeof(p.szPassword));
db_clientdesc->DBPacket(HEADER_GD_SAFEBOX_LOAD, GetDesc()->GetHandle(), &p, sizeof(p));
}
@ -6500,7 +6500,7 @@ void CHARACTER::ConfirmWithMsg(const char* szMsg, int iTimeout, DWORD dwRequestP
p.header = HEADER_GC_QUEST_CONFIRM;
p.requestPID = dwRequestPID;
p.timeout = iTimeout;
strncpy(p.msg, szMsg, sizeof(p.msg));
strlcpy(p.msg, szMsg, sizeof(p.msg));
GetDesc()->Packet(&p, sizeof(p));
}

View File

@ -384,7 +384,7 @@ ACMD(do_cmd)
info->ch = ch;
info->subcmd = subcmd;
strncpy(info->szReason, argument, sizeof(info->szReason));
strlcpy(info->szReason, argument, sizeof(info->szReason));
ch->m_pkTimedEvent = event_create(timed_event, info, 1);
}
@ -922,8 +922,8 @@ ACMD(do_safebox_change_password)
TSafeboxChangePasswordPacket p;
p.dwID = ch->GetDesc()->GetAccountTable().id;
strncpy(p.szOldPassword, arg1, sizeof(p.szOldPassword));
strncpy(p.szNewPassword, arg2, sizeof(p.szNewPassword));
strlcpy(p.szOldPassword, arg1, sizeof(p.szOldPassword));
strlcpy(p.szNewPassword, arg2, sizeof(p.szNewPassword));
db_clientdesc->DBPacket(HEADER_GD_SAFEBOX_CHANGE_PASSWORD, ch->GetDesc()->GetHandle(), &p, sizeof(p));
}
@ -957,8 +957,8 @@ ACMD(do_mall_password)
TSafeboxLoadPacket p;
p.dwID = ch->GetDesc()->GetAccountTable().id;
strncpy(p.szLogin, ch->GetDesc()->GetAccountTable().login, sizeof(p.szLogin));
strncpy(p.szPassword, arg1, sizeof(p.szPassword));
strlcpy(p.szLogin, ch->GetDesc()->GetAccountTable().login, sizeof(p.szLogin));
strlcpy(p.szPassword, arg1, sizeof(p.szPassword));
db_clientdesc->DBPacket(HEADER_GD_MALL_LOAD, ch->GetDesc()->GetHandle(), &p, sizeof(p));
}
@ -1629,7 +1629,7 @@ ACMD(do_monarch_transfer)
TPacketGGTransfer pgg;
pgg.bHeader = HEADER_GG_TRANSFER;
strncpy(pgg.szName, arg1, sizeof(pgg.szName));
strlcpy(pgg.szName, arg1, sizeof(pgg.szName));
pgg.lX = ch->GetX();
pgg.lY = ch->GetY();

View File

@ -165,7 +165,7 @@ ACMD(do_transfer)
TPacketGGTransfer pgg;
pgg.bHeader = HEADER_GG_TRANSFER;
strncpy(pgg.szName, arg1, sizeof(pgg.szName));
strlcpy(pgg.szName, arg1, sizeof(pgg.szName));
pgg.lX = ch->GetX();
pgg.lY = ch->GetY();
@ -258,7 +258,7 @@ bool FindInString(const char * c_pszFind, const char * c_pszIn)
do
{
strncpy(sz, c, std::min<size_t>(sizeof(sz), (p - c) + 1));
strlcpy(sz, c, std::min<size_t>(sizeof(sz), (p - c) + 1));
if (!strncasecmp(c_pszFind, sz, strlen(c_pszFind)))
return true;
@ -266,7 +266,7 @@ bool FindInString(const char * c_pszFind, const char * c_pszIn)
c = p + 1;
} while ((p = strchr(c, '|')));
strncpy(sz, c, sizeof(sz));
strlcpy(sz, c, sizeof(sz));
if (!strncasecmp(c_pszFind, sz, strlen(c_pszFind)))
return true;
@ -974,17 +974,17 @@ ACMD(do_state)
snprintf(buf, sizeof(buf), "%s's State: ", tch->GetName());
if (tch->IsPosition(POS_FIGHTING))
strncat(buf, "Battle", sizeof(buf) - strlen(buf) - 1);
strlcat(buf, "Battle", sizeof(buf) - strlen(buf) - 1);
else if (tch->IsPosition(POS_DEAD))
strncat(buf, "Dead", sizeof(buf) - strlen(buf) - 1);
strlcat(buf, "Dead", sizeof(buf) - strlen(buf) - 1);
else
strncat(buf, "Standing", sizeof(buf) - strlen(buf) - 1);
strlcat(buf, "Standing", sizeof(buf) - strlen(buf) - 1);
if (ch->GetShop())
strncat(buf, ", Shop", sizeof(buf) - strlen(buf) - 1);
strlcat(buf, ", Shop", sizeof(buf) - strlen(buf) - 1);
if (ch->GetExchange())
strncat(buf, ", Exchange", sizeof(buf) - strlen(buf) - 1);
strlcat(buf, ", Exchange", sizeof(buf) - strlen(buf) - 1);
ch->ChatPacket(CHAT_TYPE_INFO, "%s", buf);
@ -1599,7 +1599,7 @@ ACMD(do_makeguild)
memset(&cp, 0, sizeof(cp));
cp.master = ch;
strncpy(cp.name, arg1, sizeof(cp.name));
strlcpy(cp.name, arg1, sizeof(cp.name));
if (!check_name(cp.name))
{
@ -2672,7 +2672,7 @@ ACMD(do_vote_block_chat)
TPacketGGBlockChat p;
p.bHeader = HEADER_GG_BLOCK_CHAT;
strncpy(p.szName, name, sizeof(p.szName));
strlcpy(p.szName, name, sizeof(p.szName));
p.lBlockDuration = lBlockDuration;
P2P_MANAGER::instance().Send(&p, sizeof(TPacketGGBlockChat));
}
@ -2680,7 +2680,7 @@ ACMD(do_vote_block_chat)
{
TPacketBlockChat p;
strncpy(p.szName, name, sizeof(p.szName));
strlcpy(p.szName, name, sizeof(p.szName));
p.lDuration = lBlockDuration;
db_clientdesc->DBPacket(HEADER_GD_BLOCK_CHAT, ch ? ch->GetDesc()->GetHandle() : 0, &p, sizeof(p));
@ -2742,7 +2742,7 @@ ACMD(do_block_chat)
TPacketGGBlockChat p;
p.bHeader = HEADER_GG_BLOCK_CHAT;
strncpy(p.szName, name, sizeof(p.szName));
strlcpy(p.szName, name, sizeof(p.szName));
p.lBlockDuration = lBlockDuration;
P2P_MANAGER::instance().Send(&p, sizeof(TPacketGGBlockChat));
}
@ -2750,7 +2750,7 @@ ACMD(do_block_chat)
{
TPacketBlockChat p;
strncpy(p.szName, name, sizeof(p.szName));
strlcpy(p.szName, name, sizeof(p.szName));
p.lDuration = lBlockDuration;
db_clientdesc->DBPacket(HEADER_GD_BLOCK_CHAT, ch ? ch->GetDesc()->GetHandle() : 0, &p, sizeof(p));
}

View File

@ -250,7 +250,7 @@ bool GetIPInfo()
if (!strncmp(netip, "192.168", 7)) // ignore if address is starting with 192
{
strncpy(g_szInternalIP, netip, sizeof(g_szInternalIP));
strlcpy(g_szInternalIP, netip, sizeof(g_szInternalIP));
#ifndef __WIN32__
fprintf(stderr, "INTERNAL_IP: %s interface %s\n", netip, ifap->ifa_name);
#else
@ -259,7 +259,7 @@ bool GetIPInfo()
}
else if (!strncmp(netip, "10.", 3))
{
strncpy(g_szInternalIP, netip, sizeof(g_szInternalIP));
strlcpy(g_szInternalIP, netip, sizeof(g_szInternalIP));
#ifndef __WIN32__
fprintf(stderr, "INTERNAL_IP: %s interface %s\n", netip, ifap->ifa_name);
#else
@ -268,7 +268,7 @@ bool GetIPInfo()
}
else if (g_szPublicIP[0] == '0')
{
strncpy(g_szPublicIP, netip, sizeof(g_szPublicIP));
strlcpy(g_szPublicIP, netip, sizeof(g_szPublicIP));
#ifndef __WIN32__
fprintf(stderr, "PUBLIC_IP: %s interface %s\n", netip, ifap->ifa_name);
#else
@ -733,7 +733,7 @@ void config_init(const string& st_localeServiceName)
TOKEN("db_addr")
{
strncpy(db_addr, value_string, sizeof(db_addr));
strlcpy(db_addr, value_string, sizeof(db_addr));
for (int n =0; n < ADDRESS_MAX_LEN; ++n)
{
@ -929,7 +929,7 @@ void config_init(const string& st_localeServiceName)
TOKEN("teen_addr")
{
strncpy(teen_addr, value_string, sizeof(teen_addr));
strlcpy(teen_addr, value_string, sizeof(teen_addr));
for (int n =0; n < ADDRESS_MAX_LEN; ++n)
{
@ -972,7 +972,7 @@ void config_init(const string& st_localeServiceName)
TOKEN("bind_ip")
{
strncpy(g_szPublicIP, value_string, sizeof(g_szPublicIP));
strlcpy(g_szPublicIP, value_string, sizeof(g_szPublicIP));
}
TOKEN("view_range")

View File

@ -219,9 +219,9 @@ void DBManager::PushBilling(CLoginData * pkLD)
if (t.bBillType == BILLING_IP_FREE || t.bBillType == BILLING_IP_TIME || t.bBillType == BILLING_IP_DAY)
snprintf(t.szLogin, sizeof(t.szLogin), "%u", pkLD->GetBillID());
else
strncpy(t.szLogin, pkLD->GetLogin(), sizeof(t.szLogin));
strlcpy(t.szLogin, pkLD->GetLogin(), sizeof(t.szLogin));
strncpy(t.szIP, pkLD->GetIP(), sizeof(t.szIP));
strlcpy(t.szIP, pkLD->GetIP(), sizeof(t.szIP));
m_vec_kUseTime.push_back(t);
}
@ -426,7 +426,7 @@ void DBManager::SendLoginPing(const char * c_pszLogin)
TPacketGGLoginPing ptog;
ptog.bHeader = HEADER_GG_LOGIN_PING;
strncpy(ptog.szLogin, c_pszLogin, sizeof(ptog.szLogin));
strlcpy(ptog.szLogin, c_pszLogin, sizeof(ptog.szLogin));
if (!g_pkAuthMasterDesc) // If I am master, broadcast to others
{
@ -451,7 +451,7 @@ void DBManager::SendAuthLogin(LPDESC d)
ptod.dwID = r.id;
trim_and_lower(r.login, ptod.szLogin, sizeof(ptod.szLogin));
strncpy(ptod.szSocialID, r.social_id, sizeof(ptod.szSocialID));
strlcpy(ptod.szSocialID, r.social_id, sizeof(ptod.szSocialID));
ptod.dwLoginKey = d->GetLoginKey();
ptod.bBillType = pkLD->GetBillType();
ptod.dwBillID = pkLD->GetBillID();
@ -542,7 +542,7 @@ bool GetGameTimeIP(MYSQL_RES * pRes, BYTE & bBillType, DWORD & dwBillID, int & s
str_to_number(day_seconds, row[col++]);
char szIP[MAX_HOST_LENGTH + 1];
strncpy(szIP, c_pszIP, sizeof(szIP));
strlcpy(szIP, c_pszIP, sizeof(szIP));
char * p = strrchr(szIP, '.');
++p;
@ -612,7 +612,7 @@ void SendBillingExpire(const char * c_pszLogin, BYTE bBillType, int iSecs, CLogi
{
TPacketBillingExpire ptod;
strncpy(ptod.szLogin, c_pszLogin, sizeof(ptod.szLogin));
strlcpy(ptod.szLogin, c_pszLogin, sizeof(ptod.szLogin));
ptod.bBillType = bBillType;
ptod.dwRemainSeconds = std::max(0, iSecs);
db_clientdesc->DBPacket(HEADER_GD_BILLING_EXPIRE, 0, &ptod, sizeof(TPacketBillingExpire));
@ -666,7 +666,7 @@ void DBManager::AnalyzeReturnQuery(SQLMsg * pMsg)
break;
}
strncpy(szEncrytPassword, row[col++], sizeof(szEncrytPassword));
strlcpy(szEncrytPassword, row[col++], sizeof(szEncrytPassword));
if (!row[col])
{
@ -675,7 +675,7 @@ void DBManager::AnalyzeReturnQuery(SQLMsg * pMsg)
break;
}
strncpy(szPassword, row[col++], sizeof(szPassword));
strlcpy(szPassword, row[col++], sizeof(szPassword));
if (!row[col])
{
@ -684,7 +684,7 @@ void DBManager::AnalyzeReturnQuery(SQLMsg * pMsg)
}
else
{
strncpy(szMatrixCode, row[col++], sizeof(szMatrixCode));
strlcpy(szMatrixCode, row[col++], sizeof(szMatrixCode));
}
if (!row[col])
@ -694,7 +694,7 @@ void DBManager::AnalyzeReturnQuery(SQLMsg * pMsg)
break;
}
strncpy(szSocialID, row[col++], sizeof(szSocialID));
strlcpy(szSocialID, row[col++], sizeof(szSocialID));
if (!row[col])
{
@ -712,7 +712,7 @@ void DBManager::AnalyzeReturnQuery(SQLMsg * pMsg)
break;
}
strncpy(szStatus, row[col++], sizeof(szStatus));
strlcpy(szStatus, row[col++], sizeof(szStatus));
BYTE bNotAvail = 0;
str_to_number(bNotAvail, row[col++]);
@ -810,8 +810,8 @@ void DBManager::AnalyzeReturnQuery(SQLMsg * pMsg)
r.id = dwID;
trim_and_lower(pinfo->login, r.login, sizeof(r.login));
strncpy(r.passwd, pinfo->passwd, sizeof(r.passwd));
strncpy(r.social_id, szSocialID, sizeof(r.social_id));
strlcpy(r.passwd, pinfo->passwd, sizeof(r.passwd));
strlcpy(r.social_id, szSocialID, sizeof(r.social_id));
DESC_MANAGER::instance().ConnectAccount(r.login, d);
d->SetMatrixCode(szMatrixCode);
@ -1178,10 +1178,10 @@ void VCardUse(LPCHARACTER CardOwner, LPCHARACTER CardTaker, LPITEM item)
TPacketGDVCard p;
p.dwID = item->GetSocket(0);
strncpy(p.szSellCharacter, CardOwner->GetName(), sizeof(p.szSellCharacter));
strncpy(p.szSellAccount, CardOwner->GetDesc()->GetAccountTable().login, sizeof(p.szSellAccount));
strncpy(p.szBuyCharacter, CardTaker->GetName(), sizeof(p.szBuyCharacter));
strncpy(p.szBuyAccount, CardTaker->GetDesc()->GetAccountTable().login, sizeof(p.szBuyAccount));
strlcpy(p.szSellCharacter, CardOwner->GetName(), sizeof(p.szSellCharacter));
strlcpy(p.szSellAccount, CardOwner->GetDesc()->GetAccountTable().login, sizeof(p.szSellAccount));
strlcpy(p.szBuyCharacter, CardTaker->GetName(), sizeof(p.szBuyCharacter));
strlcpy(p.szBuyAccount, CardTaker->GetDesc()->GetAccountTable().login, sizeof(p.szBuyAccount));
db_clientdesc->DBPacket(HEADER_GD_VCARD, 0, &p, sizeof(TPacketGDVCard));
@ -1209,7 +1209,7 @@ void DBManager::RequestBlockException(const char *login, int cmd)
TPacketBlockException packet;
packet.cmd = cmd;
strncpy(packet.login, login, sizeof(packet.login));
strlcpy(packet.login, login, sizeof(packet.login));
db_clientdesc->DBPacket(HEADER_GD_BLOCK_EXCEPTION, 0, &packet, sizeof(packet));
}

View File

@ -175,8 +175,8 @@ void DESC::Destroy()
{
TLogoutPacket pack;
strncpy(pack.login, m_accountTable.login, sizeof(pack.login));
strncpy(pack.passwd, m_accountTable.passwd, sizeof(pack.passwd));
strlcpy(pack.login, m_accountTable.login, sizeof(pack.login));
strlcpy(pack.passwd, m_accountTable.passwd, sizeof(pack.passwd));
db_clientdesc->DBPacket(HEADER_GD_LOGOUT, m_dwHandle, &pack, sizeof(TLogoutPacket));
}
@ -345,7 +345,7 @@ void DESC::Packet(const void * c_pvData, int iSize)
TPacketGGRelay p;
p.bHeader = HEADER_GG_RELAY;
strncpy(p.szName, m_stRelayName.c_str(), sizeof(p.szName));
strlcpy(p.szName, m_stRelayName.c_str(), sizeof(p.szName));
p.lSize = iSize;
if (!RawPacket(&p, sizeof(p)))
@ -649,7 +649,7 @@ void DESC::SendLoginSuccessPacket()
if (g)
{
p.guild_id[i] = g->GetID();
strncpy(p.guild_name[i], g->GetName(), sizeof(p.guild_name[i]));
strlcpy(p.guild_name[i], g->GetName(), sizeof(p.guild_name[i]));
}
else
{

View File

@ -172,7 +172,7 @@ void CLIENT_DESC::SetPhase(int iPhase)
TPacketGDSetup p;
memset(&p, 0, sizeof(p));
strncpy(p.szPublicIP, g_szPublicIP, sizeof(p.szPublicIP));
strlcpy(p.szPublicIP, g_szPublicIP, sizeof(p.szPublicIP));
if (!g_bAuthServer)
{
@ -208,9 +208,9 @@ void CLIENT_DESC::SetPhase(int iPhase)
if (r.id != 0)
{
pck.dwID = r.id;
strncpy(pck.szLogin, r.login, sizeof(pck.szLogin));
strncpy(pck.szSocialID, r.social_id, sizeof(pck.szSocialID));
strncpy(pck.szHost, d->GetHostName(), sizeof(pck.szHost));
strlcpy(pck.szLogin, r.login, sizeof(pck.szLogin));
strlcpy(pck.szSocialID, r.social_id, sizeof(pck.szSocialID));
strlcpy(pck.szHost, d->GetHostName(), sizeof(pck.szHost));
pck.dwLoginKey = d->GetLoginKey();
buf.write(&pck, sizeof(TPacketLoginOnSetup));

View File

@ -248,7 +248,7 @@ void Initialize()
do
{
strncpy(szCol2, start, std::min<size_t>(sizeof(szCol2), (tab - start) + 1));
strlcpy(szCol2, start, std::min<size_t>(sizeof(szCol2), (tab - start) + 1));
szCol2[tab-start] = '\0';
trim_and_lower(szCol2, szCol, sizeof(szCol));
@ -259,7 +259,7 @@ void Initialize()
{
switch (iColCount++)
{
case 0: strncpy(fish_info[idx].name, szCol, sizeof(fish_info[idx].name)); break;
case 0: strlcpy(fish_info[idx].name, szCol, sizeof(fish_info[idx].name)); break;
case 1: str_to_number(fish_info[idx].vnum, szCol); break;
case 2: str_to_number(fish_info[idx].dead_vnum, szCol); break;
case 3: str_to_number(fish_info[idx].grill_vnum, szCol); break;
@ -660,11 +660,11 @@ void Take(fishing_event_info* info, LPCHARACTER ch)
if (info->fish_id == 5)
{
strncpy(p.szBoard, LC_TEXT("낚시이벤트월척붕어"), sizeof(p.szBoard));
strlcpy(p.szBoard, LC_TEXT("낚시이벤트월척붕어"), sizeof(p.szBoard));
}
else if (info->fish_id == 6)
{
strncpy(p.szBoard, LC_TEXT("낚시이벤트잉어"), sizeof(p.szBoard));
strlcpy(p.szBoard, LC_TEXT("낚시이벤트잉어"), sizeof(p.szBoard));
}
db_clientdesc->DBPacket(HEADER_GD_HIGHSCORE_REGISTER, 0, &p, sizeof(TPacketGDHighscore));

View File

@ -61,14 +61,14 @@ CGuild::CGuild(TGuildCreateParameter & cp)
m_iMemberCountBonus = 0;
strncpy(m_data.name, cp.name, sizeof(m_data.name));
strlcpy(m_data.name, cp.name, sizeof(m_data.name));
m_data.master_pid = cp.master->GetPlayerID();
strncpy(m_data.grade_array[0].grade_name, LC_TEXT("±æµåÀå"), sizeof(m_data.grade_array[0].grade_name));
strlcpy(m_data.grade_array[0].grade_name, LC_TEXT("±æµåÀå"), sizeof(m_data.grade_array[0].grade_name));
m_data.grade_array[0].auth_flag = GUILD_AUTH_ADD_MEMBER | GUILD_AUTH_REMOVE_MEMBER | GUILD_AUTH_NOTICE | GUILD_AUTH_USE_SKILL;
for (int i = 1; i < GUILD_GRADE_COUNT; ++i)
{
strncpy(m_data.grade_array[i].grade_name, LC_TEXT("±æµå¿ø"), sizeof(m_data.grade_array[i].grade_name));
strlcpy(m_data.grade_array[i].grade_name, LC_TEXT("±æµå¿ø"), sizeof(m_data.grade_array[i].grade_name));
m_data.grade_array[i].auth_flag = 0;
}
@ -446,7 +446,7 @@ void CGuild::SendListPacket(LPCHARACTER ch)
buf.write(&(it->second), sizeof(DWORD)*3+1);
strncpy(c, it->second.name.c_str(), std::min(sizeof(c), it->second.name.length() + 1));
strlcpy(c, it->second.name.c_str(), std::min(sizeof(c), it->second.name.length() + 1));
buf.write(c, CHARACTER_NAME_MAX_LEN+1 );
@ -579,7 +579,7 @@ void CGuild::LoadGuildGradeData(SQLMsg* pmsg)
if (grade >= 1 && grade <= 15)
{
//sys_log(0, "GuildGradeLoad %s", name);
strncpy(m_data.grade_array[grade-1].grade_name, name, sizeof(m_data.grade_array[grade-1].grade_name));
strlcpy(m_data.grade_array[grade-1].grade_name, name, sizeof(m_data.grade_array[grade-1].grade_name));
m_data.grade_array[grade-1].auth_flag = auth;
}
}
@ -596,7 +596,7 @@ void CGuild::LoadGuildData(SQLMsg* pmsg)
m_data.master_pid = strtoul(row[0], (char **)NULL, 10);
m_data.level = (BYTE)strtoul(row[1], (char **)NULL, 10);
m_data.exp = strtoul(row[2], (char **)NULL, 10);
strncpy(m_data.name, row[3], sizeof(m_data.name));
strlcpy(m_data.name, row[3], sizeof(m_data.name));
m_data.skill_point = (BYTE) strtoul(row[4], (char **) NULL, 10);
if (row[5])
@ -703,7 +703,7 @@ void CGuild::__P2PUpdateGrade(SQLMsg* pmsg)
// 등급 명칭이 현재와 다르다면 업데이트
if (0 != strcmp(m_data.grade_array[grade].grade_name, name))
{
strncpy(m_data.grade_array[grade].grade_name, name, sizeof(m_data.grade_array[grade].grade_name));
strlcpy(m_data.grade_array[grade].grade_name, name, sizeof(m_data.grade_array[grade].grade_name));
TPacketGCGuild pack;
@ -715,7 +715,7 @@ void CGuild::__P2PUpdateGrade(SQLMsg* pmsg)
pack.size += sizeof(pack2);
pack2.grade = grade + 1;
strncpy(pack2.grade_name, name, sizeof(pack2.grade_name));
strlcpy(pack2.grade_name, name, sizeof(pack2.grade_name));
TEMP_BUFFER buf;
@ -810,7 +810,7 @@ void CGuild::ChangeGradeName(BYTE grade, const char* grade_name)
DBManager::instance().FuncAfterQuery(FSendChangeGrade(GetID(), grade), "UPDATE guild_grade%s SET name = '%s' where guild_id = %u and grade = %d", get_table_postfix(), text, m_data.guild_id, grade);
grade--;
strncpy(m_data.grade_array[grade].grade_name, grade_name, sizeof(m_data.grade_array[grade].grade_name));
strlcpy(m_data.grade_array[grade].grade_name, grade_name, sizeof(m_data.grade_array[grade].grade_name));
TPacketGCGuild pack;
pack.header = HEADER_GC_GUILD;
@ -820,7 +820,7 @@ void CGuild::ChangeGradeName(BYTE grade, const char* grade_name)
TOneGradeNamePacket pack2;
pack.size+=sizeof(pack2);
pack2.grade = grade+1;
strncpy(pack2.grade_name,grade_name, sizeof(pack2.grade_name));
strlcpy(pack2.grade_name,grade_name, sizeof(pack2.grade_name));
TEMP_BUFFER buf;
buf.write(&pack,sizeof(pack));
@ -896,7 +896,7 @@ void CGuild::SendGuildInfoPacket(LPCHARACTER ch)
pack_sub.master_pid = m_data.master_pid;
pack_sub.exp = m_data.exp;
pack_sub.level = m_data.level;
strncpy(pack_sub.name, m_data.name, sizeof(pack_sub.name));
strlcpy(pack_sub.name, m_data.name, sizeof(pack_sub.name));
pack_sub.gold = m_data.gold;
pack_sub.has_land = HasLand();
@ -1079,8 +1079,8 @@ void CGuild::RefreshCommentForce(DWORD player_id)
MYSQL_ROW row = mysql_fetch_row(pmsg->Get()->pSQLResult);
DWORD id = strtoul(row[0], NULL, 10);
strncpy(szName, row[1], sizeof(szName));
strncpy(szContent, row[2], sizeof(szContent));
strlcpy(szName, row[1], sizeof(szName));
strlcpy(szContent, row[2], sizeof(szContent));
d->RawPacket(&id, sizeof(id));
d->RawPacket(szName, sizeof(szName));
@ -1679,7 +1679,7 @@ void CGuild::Chat(const char* c_pszText)
p1.bHeader = HEADER_GG_GUILD;
p1.bSubHeader = GUILD_SUBHEADER_GG_CHAT;
p1.dwGuild = GetID();
strncpy(p2.szText, c_pszText, sizeof(p2.szText));
strlcpy(p2.szText, c_pszText, sizeof(p2.szText));
P2P_MANAGER::instance().Send(&p1, sizeof(TPacketGGGuild));
P2P_MANAGER::instance().Send(&p2, sizeof(TPacketGGGuildChat));

View File

@ -50,7 +50,7 @@ void CHorseNameManager::BroadcastHorseName(DWORD dwPlayerID, const char* szHorse
{
TPacketUpdateHorseName packet;
packet.dwPlayerID = dwPlayerID;
strncpy(packet.szHorseName, szHorseName, sizeof(packet.szHorseName));
strlcpy(packet.szHorseName, szHorseName, sizeof(packet.szHorseName));
db_clientdesc->DBPacket(HEADER_GD_UPDATE_HORSE_NAME, 0, &packet, sizeof(TPacketUpdateHorseName));
}

View File

@ -220,7 +220,7 @@ void LoginFailure(LPDESC d, const char * c_pszStatus)
TPacketGCLoginFailure failurePacket;
failurePacket.header = HEADER_GC_LOGIN_FAILURE;
strncpy(failurePacket.szStatus, c_pszStatus, sizeof(failurePacket.szStatus));
strlcpy(failurePacket.szStatus, c_pszStatus, sizeof(failurePacket.szStatus));
d->Packet(&failurePacket, sizeof(failurePacket));
}
@ -367,7 +367,7 @@ int CInputHandshake::Analyze(LPDESC d, BYTE bHeader, const char * c_pData)
p.dwID = (DWORD)(atoi(msg.c_str()));
snprintf(szTmp,sizeof(szTmp),"Sent to DB cache to delete ItemAward, id: %d",p.dwID);
//sys_log(0,"%d",p.dwID);
// strncpy(p.login, msg.c_str(), sizeof(p.login));
// strlcpy(p.login, msg.c_str(), sizeof(p.login));
db_clientdesc->DBPacket(HEADER_GD_DELETE_AWARDID, 0, &p, sizeof(p));
stResult += szTmp;
}
@ -408,14 +408,14 @@ dev_log(LOG_DEB0, "DC : '%s'", msg.c_str());
TPacketGGDisconnect pgg;
pgg.bHeader = HEADER_GG_DISCONNECT;
strncpy(pgg.szLogin, msg.c_str(), sizeof(pgg.szLogin));
strlcpy(pgg.szLogin, msg.c_str(), sizeof(pgg.szLogin));
P2P_MANAGER::instance().Send(&pgg, sizeof(TPacketGGDisconnect));
// delete login key
{
TPacketDC p;
strncpy(p.login, msg.c_str(), sizeof(p.login));
strlcpy(p.login, msg.c_str(), sizeof(p.login));
db_clientdesc->DBPacket(HEADER_GD_DC, 0, &p, sizeof(p));
}
}

View File

@ -116,7 +116,7 @@ void CInputAuth::Login(LPDESC d, const char * c_pData)
trim_and_lower(pinfo->login, login, sizeof(login));
char passwd[PASSWD_MAX_LEN + 1];
strncpy(passwd, pinfo->passwd, sizeof(passwd));
strlcpy(passwd, pinfo->passwd, sizeof(passwd));
sys_log(0, "InputAuth::Login : %s(%d) desc %p",
login, strlen(login), get_pointer(d));
@ -135,7 +135,7 @@ void CInputAuth::Login(LPDESC d, const char * c_pData)
TPacketGCLoginFailure failurePacket;
failurePacket.header = HEADER_GC_LOGIN_FAILURE;
strncpy(failurePacket.szStatus, "SHUTDOWN", sizeof(failurePacket.szStatus));
strlcpy(failurePacket.szStatus, "SHUTDOWN", sizeof(failurePacket.szStatus));
d->Packet(&failurePacket, sizeof(failurePacket));
return;

View File

@ -131,7 +131,7 @@ void CInputDB::LoginSuccess(DWORD dwHandle, const char *data)
TLogoutPacket pack;
strncpy(pack.login, pTab->login, sizeof(pack.login));
strlcpy(pack.login, pTab->login, sizeof(pack.login));
db_clientdesc->DBPacket(HEADER_GD_LOGOUT, dwHandle, &pack, sizeof(pack));
return;
}
@ -142,7 +142,7 @@ void CInputDB::LoginSuccess(DWORD dwHandle, const char *data)
TLogoutPacket pack;
strncpy(pack.login, pTab->login, sizeof(pack.login));
strlcpy(pack.login, pTab->login, sizeof(pack.login));
db_clientdesc->DBPacket(HEADER_GD_LOGOUT, dwHandle, &pack, sizeof(pack));
LoginFailure(d, pTab->status);
@ -320,14 +320,14 @@ void CInputDB::ChangeName(LPDESC d, const char * data)
for (size_t i = 0; i < PLAYER_PER_ACCOUNT; ++i)
if (r.players[i].dwID == p->pid)
{
strncpy(r.players[i].szName, p->name, sizeof(r.players[i].szName));
strlcpy(r.players[i].szName, p->name, sizeof(r.players[i].szName));
r.players[i].bChangeName = 0;
TPacketGCChangeName pgc;
pgc.header = HEADER_GC_CHANGE_NAME;
pgc.pid = p->pid;
strncpy(pgc.name, p->name, sizeof(pgc.name));
strlcpy(pgc.name, p->name, sizeof(pgc.name));
d->Packet(&pgc, sizeof(TPacketGCChangeName));
break;
@ -405,7 +405,7 @@ void CInputDB::PlayerLoad(LPDESC d, const char * data)
TPacketGGLogin p;
p.bHeader = HEADER_GG_LOGIN;
strncpy(p.szName, ch->GetName(), sizeof(p.szName));
strlcpy(p.szName, ch->GetName(), sizeof(p.szName));
p.dwPID = ch->GetPlayerID();
p.bEmpire = ch->GetEmpire();
p.lMapIndex = SECTREE_MANAGER::instance().GetMapIndex(ch->GetX(), ch->GetY());
@ -1265,7 +1265,7 @@ void CInputDB::LoginAlready(LPDESC d, const char * c_pData)
TPacketGGDisconnect pgg;
pgg.bHeader = HEADER_GG_DISCONNECT;
strncpy(pgg.szLogin, p->szLogin, sizeof(pgg.szLogin));
strlcpy(pgg.szLogin, p->szLogin, sizeof(pgg.szLogin));
P2P_MANAGER::instance().Send(&pgg, sizeof(TPacketGGDisconnect));
}
@ -1929,7 +1929,7 @@ void CInputDB::Notice(const char * c_pData)
extern void SendNotice(const char * c_pszBuf);
char szBuf[256+1];
strncpy(szBuf, c_pData, sizeof(szBuf));
strlcpy(szBuf, c_pData, sizeof(szBuf));
sys_log(0, "InputDB:: Notice: %s", szBuf);

View File

@ -96,7 +96,7 @@ void CInputLogin::Login(LPDESC d, const char * data)
if (g_iUseLocale && !test_server)
{
failurePacket.header = HEADER_GC_LOGIN_FAILURE;
strncpy(failurePacket.szStatus, "VERSION", sizeof(failurePacket.szStatus));
strlcpy(failurePacket.szStatus, "VERSION", sizeof(failurePacket.szStatus));
d->Packet(&failurePacket, sizeof(TPacketGCLoginFailure));
return;
}
@ -104,7 +104,7 @@ void CInputLogin::Login(LPDESC d, const char * data)
if (g_bNoMoreClient)
{
failurePacket.header = HEADER_GC_LOGIN_FAILURE;
strncpy(failurePacket.szStatus, "SHUTDOWN", sizeof(failurePacket.szStatus));
strlcpy(failurePacket.szStatus, "SHUTDOWN", sizeof(failurePacket.szStatus));
d->Packet(&failurePacket, sizeof(TPacketGCLoginFailure));
return;
}
@ -120,7 +120,7 @@ void CInputLogin::Login(LPDESC d, const char * data)
if (g_iUserLimit <= iTotal)
{
failurePacket.header = HEADER_GC_LOGIN_FAILURE;
strncpy(failurePacket.szStatus, "FULL", sizeof(failurePacket.szStatus));
strlcpy(failurePacket.szStatus, "FULL", sizeof(failurePacket.szStatus));
d->Packet(&failurePacket, sizeof(TPacketGCLoginFailure));
return;
}
@ -128,8 +128,8 @@ void CInputLogin::Login(LPDESC d, const char * data)
TLoginPacket login_packet;
strncpy(login_packet.login, login, sizeof(login_packet.login));
strncpy(login_packet.passwd, pinfo->passwd, sizeof(login_packet.passwd));
strlcpy(login_packet.login, login, sizeof(login_packet.login));
strlcpy(login_packet.passwd, pinfo->passwd, sizeof(login_packet.passwd));
db_clientdesc->DBPacket(HEADER_GD_LOGIN, d->GetHandle(), &login_packet, sizeof(TLoginPacket));
}
@ -160,7 +160,7 @@ void CInputLogin::LoginByKey(LPDESC d, const char * data)
TPacketGCLoginFailure failurePacket;
failurePacket.header = HEADER_GC_LOGIN_FAILURE;
strncpy(failurePacket.szStatus, "SHUTDOWN", sizeof(failurePacket.szStatus));
strlcpy(failurePacket.szStatus, "SHUTDOWN", sizeof(failurePacket.szStatus));
d->Packet(&failurePacket, sizeof(TPacketGCLoginFailure));
return;
}
@ -178,7 +178,7 @@ void CInputLogin::LoginByKey(LPDESC d, const char * data)
TPacketGCLoginFailure failurePacket;
failurePacket.header = HEADER_GC_LOGIN_FAILURE;
strncpy(failurePacket.szStatus, "FULL", sizeof(failurePacket.szStatus));
strlcpy(failurePacket.szStatus, "FULL", sizeof(failurePacket.szStatus));
d->Packet(&failurePacket, sizeof(TPacketGCLoginFailure));
return;
@ -191,10 +191,10 @@ void CInputLogin::LoginByKey(LPDESC d, const char * data)
TPacketGDLoginByKey ptod;
strncpy(ptod.szLogin, login, sizeof(ptod.szLogin));
strlcpy(ptod.szLogin, login, sizeof(ptod.szLogin));
ptod.dwLoginKey = pinfo->dwLoginKey;
memcpy(ptod.adwClientKey, pinfo->adwClientKey, sizeof(DWORD) * 4);
strncpy(ptod.szIP, d->GetHostName(), sizeof(ptod.szIP));
strlcpy(ptod.szIP, d->GetHostName(), sizeof(ptod.szIP));
db_clientdesc->DBPacket(HEADER_GD_LOGIN_BY_KEY, d->GetHandle(), &ptod, sizeof(TPacketGDLoginByKey));
}
@ -225,7 +225,7 @@ void CInputLogin::ChangeName(LPDESC d, const char * data)
TPacketGDChangeName pdb;
pdb.pid = c_r.players[p->index].dwID;
strncpy(pdb.name, p->name, sizeof(pdb.name));
strlcpy(pdb.name, p->name, sizeof(pdb.name));
db_clientdesc->DBPacket(HEADER_GD_CHANGE_NAME, d->GetHandle(), &pdb, sizeof(TPacketGDChangeName));
}
@ -279,7 +279,7 @@ bool NewPlayerTable(TPlayerTable * table,
memset(table, 0, sizeof(TPlayerTable));
strncpy(table->name, name, sizeof(table->name));
strlcpy(table->name, name, sizeof(table->name));
table->level = 1;
table->job = job;
@ -395,7 +395,7 @@ bool NewPlayerTable2(TPlayerTable * table, const char * name, BYTE race, BYTE sh
memset(table, 0, sizeof(TPlayerTable));
strncpy(table->name, name, sizeof(table->name));
strlcpy(table->name, name, sizeof(table->name));
table->level = 1;
table->job = race; // Á÷¾÷´ë½Å Á¾Á·À» ³Ö´Â´Ù
@ -488,7 +488,7 @@ void CInputLogin::CharacterCreate(LPDESC d, const char * data)
const TAccountTable & c_rAccountTable = d->GetAccountTable();
trim_and_lower(c_rAccountTable.login, player_create_packet.login, sizeof(player_create_packet.login));
strncpy(player_create_packet.passwd, c_rAccountTable.passwd, sizeof(player_create_packet.passwd));
strlcpy(player_create_packet.passwd, c_rAccountTable.passwd, sizeof(player_create_packet.passwd));
player_create_packet.account_id = c_rAccountTable.id;
player_create_packet.account_index = pinfo->index;
@ -533,7 +533,7 @@ void CInputLogin::CharacterDelete(LPDESC d, const char * data)
trim_and_lower(c_rAccountTable.login, player_delete_packet.login, sizeof(player_delete_packet.login));
player_delete_packet.player_id = c_rAccountTable.players[pinfo->index].dwID;
player_delete_packet.account_index = pinfo->index;
strncpy(player_delete_packet.private_code, pinfo->private_code, sizeof(player_delete_packet.private_code));
strlcpy(player_delete_packet.private_code, pinfo->private_code, sizeof(player_delete_packet.private_code));
db_clientdesc->DBPacket(HEADER_GD_PLAYER_DELETE, d->GetHandle(), &player_delete_packet, sizeof(TPlayerDeletePacket));
}

View File

@ -146,7 +146,7 @@ bool SpamBlockCheck(LPCHARACTER ch, const char* const buf, const size_t buflen)
if (it->second.first >= g_uiSpamBlockScore)
{
spam_event_info* info = AllocEventInfo<spam_event_info>();
strncpy(info->host, ch->GetDesc()->GetHostName(), sizeof(info->host));
strlcpy(info->host, ch->GetDesc()->GetHostName(), sizeof(info->host));
it->second.second = event_create(block_chat_by_ip_event, info, PASSES_PER_SEC(g_uiSpamBlockDuration));
sys_log(0, "SPAM_IP: %s for %u seconds", info->host, g_uiSpamBlockDuration);
@ -324,7 +324,7 @@ int CInputMain::Whisper(LPCHARACTER ch, const char * data, size_t uiBytes)
pack.bHeader = HEADER_GC_WHISPER;
pack.bType = WHISPER_TYPE_SENDER_BLOCKED;
pack.wSize = sizeof(TPacketGCWhisper);
strncpy(pack.szNameFrom, pinfo->szNameTo, sizeof(pack.szNameFrom));
strlcpy(pack.szNameFrom, pinfo->szNameTo, sizeof(pack.szNameFrom));
ch->GetDesc()->Packet(&pack, sizeof(pack));
}
return iExtraLen;
@ -359,7 +359,7 @@ int CInputMain::Whisper(LPCHARACTER ch, const char * data, size_t uiBytes)
pack.bHeader = HEADER_GC_WHISPER;
pack.bType = WHISPER_TYPE_NOT_EXIST;
pack.wSize = sizeof(TPacketGCWhisper);
strncpy(pack.szNameFrom, pinfo->szNameTo, sizeof(pack.szNameFrom));
strlcpy(pack.szNameFrom, pinfo->szNameTo, sizeof(pack.szNameFrom));
ch->GetDesc()->Packet(&pack, sizeof(TPacketGCWhisper));
sys_log(0, "WHISPER: no player");
}
@ -374,7 +374,7 @@ int CInputMain::Whisper(LPCHARACTER ch, const char * data, size_t uiBytes)
pack.bHeader = HEADER_GC_WHISPER;
pack.bType = WHISPER_TYPE_SENDER_BLOCKED;
pack.wSize = sizeof(TPacketGCWhisper);
strncpy(pack.szNameFrom, pinfo->szNameTo, sizeof(pack.szNameFrom));
strlcpy(pack.szNameFrom, pinfo->szNameTo, sizeof(pack.szNameFrom));
ch->GetDesc()->Packet(&pack, sizeof(pack));
}
}
@ -386,7 +386,7 @@ int CInputMain::Whisper(LPCHARACTER ch, const char * data, size_t uiBytes)
pack.bHeader = HEADER_GC_WHISPER;
pack.bType = WHISPER_TYPE_TARGET_BLOCKED;
pack.wSize = sizeof(TPacketGCWhisper);
strncpy(pack.szNameFrom, pinfo->szNameTo, sizeof(pack.szNameFrom));
strlcpy(pack.szNameFrom, pinfo->szNameTo, sizeof(pack.szNameFrom));
ch->GetDesc()->Packet(&pack, sizeof(pack));
}
}
@ -395,7 +395,7 @@ int CInputMain::Whisper(LPCHARACTER ch, const char * data, size_t uiBytes)
BYTE bType = WHISPER_TYPE_NORMAL;
char buf[CHAT_MAX_LEN + 1];
strncpy(buf, data + sizeof(TPacketCGWhisper), std::min<size_t>(iExtraLen + 1, sizeof(buf)));
strlcpy(buf, data + sizeof(TPacketCGWhisper), std::min<size_t>(iExtraLen + 1, sizeof(buf)));
const size_t buflen = strlen(buf);
if (true == SpamBlockCheck(ch, buf, buflen))
@ -462,7 +462,7 @@ int CInputMain::Whisper(LPCHARACTER ch, const char * data, size_t uiBytes)
pack.bHeader = HEADER_GC_WHISPER;
pack.bType = WHISPER_TYPE_ERROR;
pack.wSize = sizeof(TPacketGCWhisper) + len;
strncpy(pack.szNameFrom, pinfo->szNameTo, sizeof(pack.szNameFrom));
strlcpy(pack.szNameFrom, pinfo->szNameTo, sizeof(pack.szNameFrom));
ch->GetDesc()->RawPacket(&pack, sizeof(pack));
ch->GetDesc()->Packet(buf, len);
@ -486,7 +486,7 @@ int CInputMain::Whisper(LPCHARACTER ch, const char * data, size_t uiBytes)
pack.bHeader = HEADER_GC_WHISPER;
pack.wSize = sizeof(TPacketGCWhisper) + buflen;
pack.bType = bType;
strncpy(pack.szNameFrom, ch->GetName(), sizeof(pack.szNameFrom));
strlcpy(pack.szNameFrom, ch->GetName(), sizeof(pack.szNameFrom));
// desc->BufferedPacket을 하지 않고 버퍼에 써야하는 이유는
// P2P relay되어 패킷이 캡슐화 될 수 있기 때문이다.
@ -565,7 +565,7 @@ struct FEmpireChatPacket
else
{
// 사람마다 스킬레벨이 다르니 매번 해야합니다
strncpy(converted_msg, orig_msg, sizeof(converted_msg));
strlcpy(converted_msg, orig_msg, sizeof(converted_msg));
ConvertEmpireText(bEmpire, converted_msg + namelen, sizeof(converted_msg) - namelen, 10 + 2 * d->GetCharacter()->GetSkillPower(SKILL_LANGUAGE1 + bEmpire - 1));
d->Packet(converted_msg, orig_len);
@ -654,7 +654,7 @@ int CInputMain::Chat(LPCHARACTER ch, const char * data, size_t uiBytes)
}
char buf[CHAT_MAX_LEN - (CHARACTER_NAME_MAX_LEN + 3) + 1];
strncpy(buf, data + sizeof(TPacketCGChat), std::min<size_t>(iExtraLen + 1, sizeof(buf)));
strlcpy(buf, data + sizeof(TPacketCGChat), std::min<size_t>(iExtraLen + 1, sizeof(buf)));
const size_t buflen = strlen(buf);
if (buflen > 1 && *buf == '/')
@ -740,7 +740,7 @@ int CInputMain::Chat(LPCHARACTER ch, const char * data, size_t uiBytes)
p.bHeader = HEADER_GG_SHOUT;
p.bEmpire = ch->GetEmpire();
strncpy(p.szText, chatbuf, sizeof(p.szText));
strlcpy(p.szText, chatbuf, sizeof(p.szText));
P2P_MANAGER::instance().Send(&p, sizeof(TPacketGGShout));
@ -960,7 +960,7 @@ int CInputMain::Messenger(LPCHARACTER ch, const char* c_pData, size_t uiBytes)
return -1;
char name[CHARACTER_NAME_MAX_LEN + 1];
strncpy(name, c_pData, sizeof(name));
strlcpy(name, c_pData, sizeof(name));
if (ch->GetGMLevel() == GM_PLAYER && gm_get_level(name) != GM_PLAYER)
{
@ -997,7 +997,7 @@ int CInputMain::Messenger(LPCHARACTER ch, const char* c_pData, size_t uiBytes)
return -1;
char char_name[CHARACTER_NAME_MAX_LEN + 1];
strncpy(char_name, c_pData, sizeof(char_name));
strlcpy(char_name, c_pData, sizeof(char_name));
MessengerManager::instance().RemoveFromList(ch->GetName(), char_name);
}
return CHARACTER_NAME_MAX_LEN;
@ -1997,7 +1997,7 @@ void CInputMain::QuestInputString(LPCHARACTER ch, const void* c_pData)
TPacketCGQuestInputString * p = (TPacketCGQuestInputString*) c_pData;
char msg[65];
strncpy(msg, p->msg, sizeof(msg));
strlcpy(msg, p->msg, sizeof(msg));
sys_log(0, "QUEST InputString pid %u msg %s", ch->GetPlayerID(), msg);
quest::CQuestManager::Instance().Input(ch->GetPlayerID(), msg);
@ -2424,7 +2424,7 @@ void CInputMain::AnswerMakeGuild(LPCHARACTER ch, const char* c_pData)
memset(&cp, 0, sizeof(cp));
cp.master = ch;
strncpy(cp.name, p->guild_name, sizeof(cp.name));
strlcpy(cp.name, p->guild_name, sizeof(cp.name));
if (cp.name[0] == 0 || !check_name(cp.name))
{
@ -2680,7 +2680,7 @@ int CInputMain::Guild(LPCHARACTER ch, const char * data, size_t uiBytes)
case GUILD_SUBHEADER_CG_CHANGE_GRADE_NAME:
{
char gradename[GUILD_GRADE_NAME_MAX_LEN + 1];
strncpy(gradename, c_pData + 1, sizeof(gradename));
strlcpy(gradename, c_pData + 1, sizeof(gradename));
const TGuildMember * m = pGuild->GetMember(ch->GetPlayerID());

View File

@ -117,7 +117,7 @@ int CInputP2P::Notice(LPDESC d, const char * c_pData, size_t uiBytes)
}
char szBuf[256+1];
strncpy(szBuf, c_pData + sizeof(TPacketGGNotice), std::min<size_t>(p->lSize + 1, sizeof(szBuf)));
strlcpy(szBuf, c_pData + sizeof(TPacketGGNotice), std::min<size_t>(p->lSize + 1, sizeof(szBuf)));
SendNotice(szBuf);
return (p->lSize);
}
@ -137,7 +137,7 @@ int CInputP2P::MonarchNotice(LPDESC d, const char * c_pData, size_t uiBytes)
}
char szBuf[256+1];
strncpy(szBuf, c_pData + sizeof(TPacketGGMonarchNotice), std::min<size_t>(p->lSize + 1, sizeof(szBuf)));
strlcpy(szBuf, c_pData + sizeof(TPacketGGMonarchNotice), std::min<size_t>(p->lSize + 1, sizeof(szBuf)));
SendMonarchNotice(p->bEmpire, szBuf);
return (p->lSize);
}

View File

@ -151,7 +151,7 @@ void CItem::EncodeInsertPacket(LPENTITY ent)
p.bHeader = HEADER_GC_ITEM_OWNERSHIP;
p.dwVID = m_dwVID;
strncpy(p.szName, info->szOwnerName, sizeof(p.szName));
strlcpy(p.szName, info->szOwnerName, sizeof(p.szName));
d->Packet(&p, sizeof(TPacketGCItemOwnership));
}
@ -1095,7 +1095,7 @@ void CItem::SetOwnership(LPCHARACTER ch, int iSec)
m_dwOwnershipPID = ch->GetPlayerID();
item_event_info* info = AllocEventInfo<item_event_info>();
strncpy(info->szOwnerName, ch->GetName(), sizeof(info->szOwnerName));
strlcpy(info->szOwnerName, ch->GetName(), sizeof(info->szOwnerName));
info->item = this;
SetOwnershipEvent(event_create(ownership_event, info, PASSES_PER_SEC(iSec)));
@ -1104,7 +1104,7 @@ void CItem::SetOwnership(LPCHARACTER ch, int iSec)
p.bHeader = HEADER_GC_ITEM_OWNERSHIP;
p.dwVID = m_dwVID;
strncpy(p.szName, ch->GetName(), sizeof(p.szName));
strlcpy(p.szName, ch->GetName(), sizeof(p.szName));
PacketAround(&p, sizeof(p));
}

View File

@ -60,7 +60,7 @@ bool ITEM_MANAGER::ReadCommonDropItemFile(const char * c_pszFileName)
if (!p2)
break;
strncpy(szTemp, p, std::min<size_t>(sizeof(szTemp), (p2 - p) + 1));
strlcpy(szTemp, p, std::min<size_t>(sizeof(szTemp), (p2 - p) + 1));
p = p2 + 1;
switch (j)
@ -69,7 +69,7 @@ bool ITEM_MANAGER::ReadCommonDropItemFile(const char * c_pszFileName)
case 1: str_to_number(d[i].iLvStart, szTemp); break;
case 2: str_to_number(d[i].iLvEnd, szTemp); break;
case 3: d[i].fPercent = atof(szTemp); break;
case 4: strncpy(d[i].szItemName, szTemp, sizeof(d[i].szItemName)); break;
case 4: strlcpy(d[i].szItemName, szTemp, sizeof(d[i].szItemName)); break;
case 5: str_to_number(d[i].iCount, szTemp); break;
}
}
@ -451,7 +451,7 @@ bool ITEM_MANAGER::ReadEtcDropItemFile(const char * c_pszFileName)
char szItemName[256];
float fProb = 0.0f;
strncpy(szItemName, buf, sizeof(szItemName));
strlcpy(szItemName, buf, sizeof(szItemName));
char * cpTab = strrchr(szItemName, '\t');
if (!cpTab)

View File

@ -30,7 +30,7 @@ const char * locale_find(const char *string)
if( iter == localeString.end() )
{
static char s_line[1024] = "@0949";
strncpy(s_line + 5, string, sizeof(s_line) - 5);
strlcpy(s_line + 5, string, sizeof(s_line) - 5);
sys_err("LOCALE_ERROR: \"%s\";", string);
return s_line;

View File

@ -427,14 +427,14 @@ static void __LocaleService_Init_JAPAN()
static void __LocaleService_Init_English()
{
g_stLocale = "";
g_stLocale = "latin1";
g_stServiceBasePath = "locale/english";
g_stQuestDir = "locale/english/quest";
g_stServiceMapPath = "locale/english/map";
g_setQuestObjectDir.clear();
g_setQuestObjectDir.insert("locale/english/quest/object");
g_stLocaleFilename = "locale/english/eng_string.txt";
g_stLocaleFilename = "locale/english/locale_string.txt";
g_iUseLocale = true;
check_name = check_name_alphabet;
@ -1300,6 +1300,7 @@ bool LC_IsEurope()
switch ((int) val)
{
case LC_ENGLISH:
case LC_GERMANY:
case LC_FRANCE:
case LC_ITALY:

View File

@ -81,7 +81,7 @@ DWORD CLoginData::GetLogonTime()
void CLoginData::SetIP(const char * c_pszIP)
{
strncpy(m_szIP, c_pszIP, sizeof(m_szIP));
strlcpy(m_szIP, c_pszIP, sizeof(m_szIP));
}
const char * CLoginData::GetIP()

View File

@ -166,11 +166,11 @@ void ShutdownOnFatalError()
{
char buf[256];
strncpy(buf, LC_TEXT("서버에 치명적인 오류가 발생하여 자동으로 재부팅됩니다."), sizeof(buf));
strlcpy(buf, LC_TEXT("서버에 치명적인 오류가 발생하여 자동으로 재부팅됩니다."), sizeof(buf));
SendNotice(buf);
strncpy(buf, LC_TEXT("10초후 자동으로 접속이 종료되며,"), sizeof(buf));
strlcpy(buf, LC_TEXT("10초후 자동으로 접속이 종료되며,"), sizeof(buf));
SendNotice(buf);
strncpy(buf, LC_TEXT("5분 후에 정상적으로 접속하실수 있습니다."), sizeof(buf));
strlcpy(buf, LC_TEXT("5분 후에 정상적으로 접속하실수 있습니다."), sizeof(buf));
SendNotice(buf);
}
@ -523,7 +523,7 @@ int start(int argc, char **argv)
switch (ch)
{
case 'I': // IP
strncpy(g_szPublicIP, optarg, sizeof(g_szPublicIP));
strlcpy(g_szPublicIP, optarg, sizeof(g_szPublicIP));
printf("IP %s\n", g_szPublicIP);

View File

@ -45,7 +45,7 @@ namespace marriage
TPacketGCLoverInfo p;
p.header = HEADER_GC_LOVER_INFO;
strncpy(p.name, lover_name.c_str(), sizeof(p.name));
strlcpy(p.name, lover_name.c_str(), sizeof(p.name));
p.love_point = love_point;
ch->GetDesc()->Packet(&p, sizeof(p));
}
@ -552,8 +552,8 @@ namespace marriage
p.dwPID1 = dwPID1;
p.dwPID2 = dwPID2;
strncpy(p.szName1, szName1, sizeof(p.szName1));
strncpy(p.szName2, szName2, sizeof(p.szName2));
strlcpy(p.szName1, szName1, sizeof(p.szName1));
strlcpy(p.szName2, szName2, sizeof(p.szName2));
db_clientdesc->DBPacket(HEADER_GD_MARRIAGE_ADD, 0, &p, sizeof(p));
}

View File

@ -41,7 +41,7 @@ bool EncodeMatrix(const char* szsrc, const char* szpwd, char* lpdes, const unsig
char dc = sc ^ pc;
char szhex[3];
snprintf(szhex, sizeof(szhex), "%02X", dc);
strncat(lpdes, szhex, usize);
strlcat(lpdes, szhex, usize);
}
return (i == nlen) ? true : false;
@ -147,7 +147,7 @@ void GetRightAnswer(const unsigned int rows, const unsigned int cols, const char
{
char sztemp[3] = { 0, 0, 0 };
memcpy(sztemp, (char*)(pmatrix + (ROW(rows, i) * MAX_COLS + COL(cols, i))), 2);
strncat(answer, sztemp, nsize);
strlcat(answer, sztemp, nsize);
}
}

View File

@ -200,8 +200,8 @@ void MessengerManager::AddToList(MessengerManager::keyA account, MessengerManage
TPacketGGMessenger p2ppck;
p2ppck.bHeader = HEADER_GG_MESSENGER_ADD;
strncpy(p2ppck.szAccount, account.c_str(), sizeof(p2ppck.szAccount));
strncpy(p2ppck.szCompanion, companion.c_str(), sizeof(p2ppck.szCompanion));
strlcpy(p2ppck.szAccount, account.c_str(), sizeof(p2ppck.szAccount));
strlcpy(p2ppck.szCompanion, companion.c_str(), sizeof(p2ppck.szCompanion));
P2P_MANAGER::instance().Send(&p2ppck, sizeof(TPacketGGMessenger));
}
@ -231,8 +231,8 @@ void MessengerManager::RemoveFromList(MessengerManager::keyA account, MessengerM
TPacketGGMessenger p2ppck;
p2ppck.bHeader = HEADER_GG_MESSENGER_REMOVE;
strncpy(p2ppck.szAccount, account.c_str(), sizeof(p2ppck.szAccount));
strncpy(p2ppck.szCompanion, companion.c_str(), sizeof(p2ppck.szCompanion));
strlcpy(p2ppck.szAccount, account.c_str(), sizeof(p2ppck.szAccount));
strlcpy(p2ppck.szCompanion, companion.c_str(), sizeof(p2ppck.szCompanion));
P2P_MANAGER::instance().Send(&p2ppck, sizeof(TPacketGGMessenger));
}

View File

@ -41,7 +41,7 @@ void P2P_MANAGER::Boot(LPDESC d)
it++;
p.bHeader = HEADER_GG_LOGIN;
strncpy(p.szName, ch->GetName(), sizeof(p.szName));
strlcpy(p.szName, ch->GetName(), sizeof(p.szName));
p.dwPID = ch->GetPlayerID();
p.bEmpire = ch->GetEmpire();
p.lMapIndex = SECTREE_MANAGER::instance().GetMapIndex(ch->GetX(), ch->GetY());
@ -142,7 +142,7 @@ void P2P_MANAGER::Login(LPDESC d, const TPacketGGLogin * p)
pkCCI = M2_NEW CCI;
if (false == LC_IsBrazil())
strncpy(pkCCI->szName, p->szName, sizeof(pkCCI->szName));
strlcpy(pkCCI->szName, p->szName, sizeof(pkCCI->szName));
else
trim_and_lower(p->szName, pkCCI->szName, sizeof(pkCCI->szName));

View File

@ -77,7 +77,7 @@ void SendPanamaList(LPDESC d)
while (it != s_panamaVector.end())
{
strncpy(pack.szPackName, it->first.c_str(), sizeof(pack.szPackName));
strlcpy(pack.szPackName, it->first.c_str(), sizeof(pack.szPackName));
memcpy(pack.abIV, it->second, sizeof(pack.abIV));

View File

@ -689,7 +689,7 @@ void CParty::SendPartyJoinOneToAll(DWORD pid)
p.header = HEADER_GC_PARTY_ADD;
p.pid = pid;
strncpy(p.name, r.strName.c_str(), sizeof(p.name));
strlcpy(p.name, r.strName.c_str(), sizeof(p.name));
for (TMemberMap::iterator it = m_memberMap.begin(); it != m_memberMap.end(); ++it)
{
@ -711,7 +711,7 @@ void CParty::SendPartyJoinAllToOne(LPCHARACTER ch)
for (TMemberMap::iterator it = m_memberMap.begin();it!= m_memberMap.end(); ++it)
{
p.pid = it->first;
strncpy(p.name, it->second.strName.c_str(), sizeof(p.name));
strlcpy(p.name, it->second.strName.c_str(), sizeof(p.name));
ch->GetDesc()->Packet(&p, sizeof(p));
}
}
@ -1441,7 +1441,7 @@ void CParty::UpdateOnlineState(DWORD dwPID, const char* name)
p.header = HEADER_GC_PARTY_ADD;
p.pid = dwPID;
r.strName = name;
strncpy(p.name, name, sizeof(p.name));
strlcpy(p.name, name, sizeof(p.name));
for (TMemberMap::iterator it = m_memberMap.begin(); it != m_memberMap.end(); ++it)
{

View File

@ -218,7 +218,7 @@ void CPVPManager::Insert(LPCHARACTER pkChr, LPCHARACTER pkVictim)
pack.bHeader = HEADER_GC_WHISPER;
pack.wSize = sizeof(TPacketGCWhisper) + len;
pack.bType = WHISPER_TYPE_SYSTEM;
strncpy(pack.szNameFrom, pkChr->GetName(), sizeof(pack.szNameFrom));
strlcpy(pack.szNameFrom, pkChr->GetName(), sizeof(pack.szNameFrom));
TEMP_BUFFER buf;

View File

@ -97,7 +97,7 @@ END_OF_TIMER_EVENT:
info->name = M2_NEW char[nameCapacity];
if (info->name)
strncpy(info->name, name, nameCapacity);
strlcpy(info->name, name, nameCapacity);
return event_create(quest_server_timer_event, info, ltime_cycle);
}
@ -115,7 +115,7 @@ END_OF_TIMER_EVENT:
info->name = M2_NEW char[nameCapacity];
if (info->name)
strncpy(info->name, name, nameCapacity);
strlcpy(info->name, name, nameCapacity);
sys_log(0, "QUEST timer name %s cycle %d pc %u npc %u loop? %d", name ? name : "<noname>", ltime_cycle, player_id, npc_id, loop ? 1 : 0);

View File

@ -226,7 +226,7 @@ namespace quest
THighscoreRegisterQueryInfo * qi = M2_NEW THighscoreRegisterQueryInfo;
strncpy(qi->szBoard, lua_tostring(L, 1), sizeof(qi->szBoard));
strlcpy(qi->szBoard, lua_tostring(L, 1), sizeof(qi->szBoard));
qi->dwPID = q.GetCurrentCharacterPtr()->GetPlayerID();
qi->iValue = (int) lua_tonumber(L, 2);
qi->bOrder = (int) lua_tonumber(L, 3);

View File

@ -191,7 +191,7 @@ namespace quest
TPacketGDGuildWarBet p;
p.dwWarID = (DWORD) lua_tonumber(L, 1);
strncpy(p.szLogin, ch->GetDesc()->GetAccountTable().login, sizeof(p.szLogin));
strlcpy(p.szLogin, ch->GetDesc()->GetAccountTable().login, sizeof(p.szLogin));
p.dwGuild = (DWORD) lua_tonumber(L, 2);
p.dwGold = (DWORD) lua_tonumber(L, 3);

View File

@ -706,7 +706,7 @@ namespace quest
TPacketGGTransfer pgg;
pgg.bHeader = HEADER_GG_TRANSFER;
strncpy(pgg.szName, name.c_str(), sizeof(pgg.szName));
strlcpy(pgg.szName, name.c_str(), sizeof(pgg.szName));
pgg.lX = ch->GetX();
pgg.lY = ch->GetY();
@ -793,7 +793,7 @@ namespace quest
return 0;
char vnum[256];
strncpy(vnum, lua_tostring(L, 1), sizeof(vnum));
strlcpy(vnum, lua_tostring(L, 1), sizeof(vnum));
do_monarch_mob(ch, vnum, 0, 0);
return 0;
}

View File

@ -1155,7 +1155,7 @@ namespace quest
void CQuestManager::RequestSetEventFlag(const string& name, int value)
{
TPacketSetEventFlag p;
strncpy(p.szFlagName, name.c_str(), sizeof(p.szFlagName));
strlcpy(p.szFlagName, name.c_str(), sizeof(p.szFlagName));
p.lValue = value;
db_clientdesc->DBPacket(HEADER_GD_SET_EVENT_FLAG, 0, &p, sizeof(TPacketSetEventFlag));
}

View File

@ -61,7 +61,7 @@ namespace quest
continue;
sys_log(1, "QUEST reading %s", pde->d_name);
strncpy(buf + is, pde->d_name, sizeof(buf) - is);
strlcpy(buf + is, pde->d_name, sizeof(buf) - is);
LoadStateScript(event_index, buf, pde->d_name);
}

View File

@ -571,8 +571,8 @@ namespace quest
TQuestTable & r = s_table[i++];
r.dwPID = m_dwID;
strncpy(r.szName, stName.c_str(), sizeof(r.szName));
strncpy(r.szState, stState.c_str(), sizeof(r.szState));
strlcpy(r.szName, stName.c_str(), sizeof(r.szName));
strlcpy(r.szState, stState.c_str(), sizeof(r.szState));
r.lValue = lValue;
}

View File

@ -1141,7 +1141,7 @@ void SECTREE_MANAGER::SendNPCPosition(LPCHARACTER ch)
for (it = m_mapNPCPosition[lMapIndex].begin(); it != m_mapNPCPosition[lMapIndex].end(); ++it)
{
np.bType = it->bType;
strncpy(np.name, it->name, sizeof(np.name));
strlcpy(np.name, it->name, sizeof(np.name));
np.x = it->x;
np.y = it->y;
buf.write(&np, sizeof(np));

View File

@ -101,7 +101,7 @@ bool CSkillManager::Initialize(TSkillTable * pTab, int iSize)
CSkillProto * pkProto = M2_NEW CSkillProto;
pkProto->dwVnum = t->dwVnum;
strncpy(pkProto->szName, t->szName, sizeof(pkProto->szName));
strlcpy(pkProto->szName, t->szName, sizeof(pkProto->szName));
pkProto->dwType = t->bType;
pkProto->bMaxLevel = t->bMaxLevel;
pkProto->dwFlag = t->dwFlag;

View File

@ -8,6 +8,8 @@
#include <libthecore/include/stdafx.h>
#include <bsd/string.h>
#include <common/singleton.h>
#include <common/utils.h>
#include <common/service.h>

View File

@ -23,7 +23,7 @@ pck.bHeader = HEADER_GC_TARGET_CREATE;
pck.lID = info->iID;
pck.bType = info->iType;
pck.dwVID = info->iArg1;
strncpy(pck.szName, info->szTargetDesc, sizeof(pck.szName));
strlcpy(pck.szName, info->szTargetDesc, sizeof(pck.szName));
d->Packet(&pck, sizeof(TPacketGCTargetCreate));
}
@ -181,7 +181,7 @@ void CTargetManager::CreateTarget(DWORD dwPID,
if (c_pszTargetDesc)
{
strncpy(existInfo->szTargetDesc, c_pszTargetDesc, sizeof(existInfo->szTargetDesc));
strlcpy(existInfo->szTargetDesc, c_pszTargetDesc, sizeof(existInfo->szTargetDesc));
}
else
{
@ -206,7 +206,7 @@ void CTargetManager::CreateTarget(DWORD dwPID,
if (c_pszTargetDesc)
{
strncpy(newInfo->szTargetDesc, c_pszTargetDesc, sizeof(newInfo->szTargetDesc));
strlcpy(newInfo->szTargetDesc, c_pszTargetDesc, sizeof(newInfo->szTargetDesc));
}
else
{
@ -218,7 +218,7 @@ void CTargetManager::CreateTarget(DWORD dwPID,
//newInfo->pkChr = pkChr;
newInfo->dwPID = dwPID;
newInfo->dwQuestIndex = dwQuestIndex;
strncpy(newInfo->szTargetName, c_pszTargetName, sizeof(newInfo->szTargetName));
strlcpy(newInfo->szTargetName, c_pszTargetName, sizeof(newInfo->szTargetName));
newInfo->iType = iType;
newInfo->iArg1 = iArg1;
newInfo->iArg2 = iArg2;

View File

@ -696,7 +696,7 @@ size_t CAsyncSQL::EscapeString(char* dst, size_t dstSize, const char *src, size_
// \0이 안붙어있을 때를 대비해서 256 바이트만 복사해서 로그로 출력
char tmp[256];
size_t tmpLen = sizeof(tmp) > srcSize ? srcSize : sizeof(tmp); // 둘 중에 작은 크기
strncpy(tmp, src, tmpLen);
strlcpy(tmp, src, tmpLen);
sys_err("FATAL ERROR!! not enough buffer size (dstSize %u srcSize %u src%s: %s)",
dstSize, srcSize, tmpLen != srcSize ? "(trimmed to 255 characters)" : "", tmp);

View File

@ -26,6 +26,8 @@
#include <sys/signal.h>
#include <sys/wait.h>
#include <bsd/string.h>
#include <pthread.h>
#include <semaphore.h>