Commit 57741bb6 authored by Chen Bill's avatar Chen Bill

Revert "check len in packet handling"

This reverts commit 2b5c12f3.
parent ca6e5664
......@@ -253,7 +253,7 @@ void DuelClient::HandleSTOCPacketLan(unsigned char* data, int len) {
break;
}
case STOC_ERROR_MSG: {
if (len != 1 + (int)sizeof(STOC_ErrorMsg))
if (len < 1 + (int)sizeof(STOC_ErrorMsg))
return;
STOC_ErrorMsg packet;
std::memcpy(&packet, pdata, sizeof packet);
......@@ -371,7 +371,7 @@ void DuelClient::HandleSTOCPacketLan(unsigned char* data, int len) {
break;
}
case STOC_HAND_RESULT: {
if (len != 1 + (int)sizeof(STOC_HandResult))
if (len < 1 + (int)sizeof(STOC_HandResult))
return;
STOC_HandResult packet;
std::memcpy(&packet, pdata, sizeof packet);
......@@ -430,7 +430,7 @@ void DuelClient::HandleSTOCPacketLan(unsigned char* data, int len) {
break;
}
case STOC_DECK_COUNT: {
if (len != 1 + (int)sizeof(int16_t) * 6)
if (len < 1 + (int)sizeof(int16_t) * 6)
return;
mainGame->gMutex.lock();
int deckc = BufferIO::ReadInt16(pdata);
......@@ -445,7 +445,7 @@ void DuelClient::HandleSTOCPacketLan(unsigned char* data, int len) {
break;
}
case STOC_JOIN_GAME: {
if (len != 1 + (int)sizeof(STOC_JoinGame))
if (len < 1 + (int)sizeof(STOC_JoinGame))
return;
STOC_JoinGame packet;
std::memcpy(&packet, pdata, sizeof packet);
......@@ -528,7 +528,7 @@ void DuelClient::HandleSTOCPacketLan(unsigned char* data, int len) {
break;
}
case STOC_TYPE_CHANGE: {
if (len != 1 + (int)sizeof(STOC_TypeChange))
if (len < 1 + (int)sizeof(STOC_TypeChange))
return;
STOC_TypeChange packet;
std::memcpy(&packet, pdata, sizeof packet);
......@@ -767,7 +767,7 @@ void DuelClient::HandleSTOCPacketLan(unsigned char* data, int len) {
break;
}
case STOC_TIME_LIMIT: {
if (len != 1 + (int)sizeof(STOC_TimeLimit))
if (len < 1 + (int)sizeof(STOC_TimeLimit))
return;
STOC_TimeLimit packet;
std::memcpy(&packet, pdata, sizeof packet);
......@@ -818,7 +818,7 @@ void DuelClient::HandleSTOCPacketLan(unsigned char* data, int len) {
break;
}
case STOC_HS_PLAYER_ENTER: {
if (len != 1 + (int)sizeof(STOC_HS_PlayerEnter))
if (len < 1 + (int)sizeof(STOC_HS_PlayerEnter))
return;
soundManager.PlaySoundEffect(SOUND_PLAYER_ENTER);
STOC_HS_PlayerEnter packet;
......@@ -854,7 +854,7 @@ void DuelClient::HandleSTOCPacketLan(unsigned char* data, int len) {
break;
}
case STOC_HS_PLAYER_CHANGE: {
if (len != 1 + (int)sizeof(STOC_HS_PlayerChange))
if (len < 1 + (int)sizeof(STOC_HS_PlayerChange))
return;
STOC_HS_PlayerChange packet;
std::memcpy(&packet, pdata, sizeof packet);
......@@ -918,7 +918,7 @@ void DuelClient::HandleSTOCPacketLan(unsigned char* data, int len) {
break;
}
case STOC_HS_WATCH_CHANGE: {
if (len != 1 + (int)sizeof(STOC_HS_WatchChange))
if (len < 1 + (int)sizeof(STOC_HS_WatchChange))
return;
STOC_HS_WatchChange packet;
std::memcpy(&packet, pdata, sizeof packet);
......
......@@ -225,7 +225,7 @@ void NetServer::HandleCTOSPacket(DuelPlayer* dp, unsigned char* data, int len) {
case CTOS_HAND_RESULT: {
if(!dp->game)
return;
if (len != 1 + (int)sizeof(CTOS_HandResult))
if (len < 1 + (int)sizeof(CTOS_HandResult))
return;
CTOS_HandResult packet;
std::memcpy(&packet, pdata, sizeof packet);
......@@ -236,7 +236,7 @@ void NetServer::HandleCTOSPacket(DuelPlayer* dp, unsigned char* data, int len) {
case CTOS_TP_RESULT: {
if(!dp->game)
return;
if (len != 1 + (int)sizeof(CTOS_TPResult))
if (len < 1 + (int)sizeof(CTOS_TPResult))
return;
CTOS_TPResult packet;
std::memcpy(&packet, pdata, sizeof packet);
......@@ -245,7 +245,7 @@ void NetServer::HandleCTOSPacket(DuelPlayer* dp, unsigned char* data, int len) {
break;
}
case CTOS_PLAYER_INFO: {
if (len != 1 + (int)sizeof(CTOS_PlayerInfo))
if (len < 1 + (int)sizeof(CTOS_PlayerInfo))
return;
CTOS_PlayerInfo packet;
std::memcpy(&packet, pdata, sizeof packet);
......@@ -256,7 +256,7 @@ void NetServer::HandleCTOSPacket(DuelPlayer* dp, unsigned char* data, int len) {
case CTOS_CREATE_GAME: {
if(dp->game || duel_mode)
return;
if (len != 1 + (int)sizeof(CTOS_CreateGame))
if (len < 1 + (int)sizeof(CTOS_CreateGame))
return;
CTOS_CreateGame packet;
std::memcpy(&packet, pdata, sizeof packet);
......@@ -295,7 +295,7 @@ void NetServer::HandleCTOSPacket(DuelPlayer* dp, unsigned char* data, int len) {
case CTOS_JOIN_GAME: {
if (!duel_mode)
return;
if (len != 1 + (int)sizeof(CTOS_JoinGame))
if (len < 1 + (int)sizeof(CTOS_JoinGame))
return;
duel_mode->JoinGame(dp, pdata, false);
break;
......@@ -334,7 +334,7 @@ void NetServer::HandleCTOSPacket(DuelPlayer* dp, unsigned char* data, int len) {
case CTOS_HS_KICK: {
if (!duel_mode || duel_mode->pduel)
return;
if (len != 1 + (int)sizeof(CTOS_Kick))
if (len < 1 + (int)sizeof(CTOS_Kick))
return;
CTOS_Kick packet;
std::memcpy(&packet, pdata, sizeof packet);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment