Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Y
ygopro
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
MyCard
ygopro
Commits
e8209d5d
Commit
e8209d5d
authored
May 25, 2024
by
Chen Bill
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
check len in HandleSTOCPacketLan()
parent
8d542df6
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
3 deletions
+28
-3
gframe/duelclient.cpp
gframe/duelclient.cpp
+27
-2
gframe/duelclient.h
gframe/duelclient.h
+1
-1
No files found.
gframe/duelclient.cpp
View file @
e8209d5d
...
...
@@ -242,15 +242,19 @@ int DuelClient::ClientThread() {
connect_state
=
0
;
return
0
;
}
void
DuelClient
::
HandleSTOCPacketLan
(
unsigned
char
*
data
,
unsigned
int
len
)
{
void
DuelClient
::
HandleSTOCPacketLan
(
unsigned
char
*
data
,
int
len
)
{
unsigned
char
*
pdata
=
data
;
unsigned
char
pktType
=
BufferIO
::
ReadUInt8
(
pdata
);
switch
(
pktType
)
{
case
STOC_GAME_MSG
:
{
if
(
len
<
1
+
(
int
)
sizeof
(
unsigned
char
))
return
;
ClientAnalyze
(
pdata
,
len
-
1
);
break
;
}
case
STOC_ERROR_MSG
:
{
if
(
len
<
1
+
(
int
)
sizeof
(
STOC_ErrorMsg
))
return
;
STOC_ErrorMsg
packet
;
std
::
memcpy
(
&
packet
,
pdata
,
sizeof
packet
);
const
auto
*
pkt
=
&
packet
;
...
...
@@ -367,6 +371,8 @@ void DuelClient::HandleSTOCPacketLan(unsigned char* data, unsigned int len) {
break
;
}
case
STOC_HAND_RESULT
:
{
if
(
len
<
1
+
(
int
)
sizeof
(
STOC_HandResult
))
return
;
STOC_HandResult
packet
;
std
::
memcpy
(
&
packet
,
pdata
,
sizeof
packet
);
const
auto
*
pkt
=
&
packet
;
...
...
@@ -424,6 +430,8 @@ void DuelClient::HandleSTOCPacketLan(unsigned char* data, unsigned int len) {
break
;
}
case
STOC_DECK_COUNT
:
{
if
(
len
<
1
+
(
int
)
sizeof
(
int16_t
)
*
6
)
return
;
mainGame
->
gMutex
.
lock
();
int
deckc
=
BufferIO
::
ReadInt16
(
pdata
);
int
extrac
=
BufferIO
::
ReadInt16
(
pdata
);
...
...
@@ -437,6 +445,8 @@ void DuelClient::HandleSTOCPacketLan(unsigned char* data, unsigned int len) {
break
;
}
case
STOC_JOIN_GAME
:
{
if
(
len
<
1
+
(
int
)
sizeof
(
STOC_JoinGame
))
return
;
STOC_JoinGame
packet
;
std
::
memcpy
(
&
packet
,
pdata
,
sizeof
packet
);
const
auto
*
pkt
=
&
packet
;
...
...
@@ -518,6 +528,8 @@ void DuelClient::HandleSTOCPacketLan(unsigned char* data, unsigned int len) {
break
;
}
case
STOC_TYPE_CHANGE
:
{
if
(
len
<
1
+
(
int
)
sizeof
(
STOC_TypeChange
))
return
;
STOC_TypeChange
packet
;
std
::
memcpy
(
&
packet
,
pdata
,
sizeof
packet
);
const
auto
*
pkt
=
&
packet
;
...
...
@@ -707,6 +719,8 @@ void DuelClient::HandleSTOCPacketLan(unsigned char* data, unsigned int len) {
break
;
}
case
STOC_REPLAY
:
{
if
(
len
<
1
+
(
int
)
sizeof
(
ReplayHeader
))
return
;
mainGame
->
gMutex
.
lock
();
mainGame
->
wPhase
->
setVisible
(
false
);
if
(
mainGame
->
dInfo
.
player_type
<
7
)
...
...
@@ -714,7 +728,7 @@ void DuelClient::HandleSTOCPacketLan(unsigned char* data, unsigned int len) {
mainGame
->
CloseGameButtons
();
auto
prep
=
pdata
;
Replay
new_replay
;
std
::
memcpy
(
&
new_replay
.
pheader
,
prep
,
sizeof
(
ReplayH
eader
));
std
::
memcpy
(
&
new_replay
.
pheader
,
prep
,
sizeof
(
new_replay
.
ph
eader
));
time_t
starttime
;
if
(
new_replay
.
pheader
.
flag
&
REPLAY_UNIFORM
)
starttime
=
new_replay
.
pheader
.
start_time
;
...
...
@@ -753,6 +767,8 @@ void DuelClient::HandleSTOCPacketLan(unsigned char* data, unsigned int len) {
break
;
}
case
STOC_TIME_LIMIT
:
{
if
(
len
<
1
+
(
int
)
sizeof
(
STOC_TimeLimit
))
return
;
STOC_TimeLimit
packet
;
std
::
memcpy
(
&
packet
,
pdata
,
sizeof
packet
);
const
auto
*
pkt
=
&
packet
;
...
...
@@ -764,6 +780,8 @@ void DuelClient::HandleSTOCPacketLan(unsigned char* data, unsigned int len) {
break
;
}
case
STOC_CHAT
:
{
if
(
len
<
1
+
(
int
)
sizeof
(
STOC_Chat
))
return
;
STOC_Chat
packet
;
std
::
memcpy
(
&
packet
,
pdata
,
sizeof
packet
);
const
auto
*
pkt
=
&
packet
;
...
...
@@ -795,6 +813,8 @@ void DuelClient::HandleSTOCPacketLan(unsigned char* data, unsigned int len) {
break
;
}
case
STOC_HS_PLAYER_ENTER
:
{
if
(
len
<
1
+
(
int
)
sizeof
(
STOC_HS_PlayerEnter
))
return
;
soundManager
.
PlaySoundEffect
(
SOUND_PLAYER_ENTER
);
STOC_HS_PlayerEnter
packet
;
std
::
memcpy
(
&
packet
,
pdata
,
sizeof
packet
);
...
...
@@ -829,6 +849,8 @@ void DuelClient::HandleSTOCPacketLan(unsigned char* data, unsigned int len) {
break
;
}
case
STOC_HS_PLAYER_CHANGE
:
{
if
(
len
<
1
+
(
int
)
sizeof
(
STOC_HS_PlayerChange
))
return
;
STOC_HS_PlayerChange
packet
;
std
::
memcpy
(
&
packet
,
pdata
,
sizeof
packet
);
const
auto
*
pkt
=
&
packet
;
...
...
@@ -891,6 +913,8 @@ void DuelClient::HandleSTOCPacketLan(unsigned char* data, unsigned int len) {
break
;
}
case
STOC_HS_WATCH_CHANGE
:
{
if
(
len
<
1
+
(
int
)
sizeof
(
STOC_HS_WatchChange
))
return
;
STOC_HS_WatchChange
packet
;
std
::
memcpy
(
&
packet
,
pdata
,
sizeof
packet
);
const
auto
*
pkt
=
&
packet
;
...
...
@@ -906,6 +930,7 @@ void DuelClient::HandleSTOCPacketLan(unsigned char* data, unsigned int len) {
if
(
!
mainGame
->
dField
.
tag_surrender
)
mainGame
->
dField
.
tag_teammate_surrender
=
true
;
mainGame
->
btnLeaveGame
->
setText
(
dataManager
.
GetSysString
(
1355
));
break
;
}
}
}
...
...
gframe/duelclient.h
View file @
e8209d5d
...
...
@@ -46,7 +46,7 @@ public:
static
void
ClientRead
(
bufferevent
*
bev
,
void
*
ctx
);
static
void
ClientEvent
(
bufferevent
*
bev
,
short
events
,
void
*
ctx
);
static
int
ClientThread
();
static
void
HandleSTOCPacketLan
(
unsigned
char
*
data
,
unsigned
int
len
);
static
void
HandleSTOCPacketLan
(
unsigned
char
*
data
,
int
len
);
static
int
ClientAnalyze
(
unsigned
char
*
msg
,
unsigned
int
len
);
static
void
SwapField
();
static
void
SetResponseI
(
int
respI
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment