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
List
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
baichixing
ygopro
Commits
8d542df6
Commit
8d542df6
authored
May 24, 2024
by
Chen Bill
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
check len in HandleCTOSPacket()
parent
9570e838
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
36 additions
and
18 deletions
+36
-18
gframe/netserver.cpp
gframe/netserver.cpp
+35
-17
gframe/netserver.h
gframe/netserver.h
+1
-1
No files found.
gframe/netserver.cpp
View file @
8d542df6
...
...
@@ -186,7 +186,7 @@ void NetServer::DisconnectPlayer(DuelPlayer* dp) {
users
.
erase
(
bit
);
}
}
void
NetServer
::
HandleCTOSPacket
(
DuelPlayer
*
dp
,
unsigned
char
*
data
,
unsigned
int
len
)
{
void
NetServer
::
HandleCTOSPacket
(
DuelPlayer
*
dp
,
unsigned
char
*
data
,
int
len
)
{
auto
pdata
=
data
;
unsigned
char
pktType
=
BufferIO
::
ReadUInt8
(
pdata
);
if
((
pktType
!=
CTOS_SURRENDER
)
&&
(
pktType
!=
CTOS_CHAT
)
&&
(
dp
->
state
==
0xff
||
(
dp
->
state
&&
dp
->
state
!=
pktType
)))
...
...
@@ -195,6 +195,8 @@ void NetServer::HandleCTOSPacket(DuelPlayer* dp, unsigned char* data, unsigned i
case
CTOS_RESPONSE
:
{
if
(
!
dp
->
game
||
!
duel_mode
->
pduel
)
return
;
if
(
len
<
1
+
(
int
)
sizeof
(
unsigned
char
))
return
;
duel_mode
->
GetResponse
(
dp
,
pdata
,
len
-
1
);
break
;
}
...
...
@@ -207,18 +209,24 @@ void NetServer::HandleCTOSPacket(DuelPlayer* dp, unsigned char* data, unsigned i
case
CTOS_CHAT
:
{
if
(
!
dp
->
game
)
return
;
if
(
len
<
1
+
(
int
)
sizeof
(
unsigned
char
))
return
;
duel_mode
->
Chat
(
dp
,
pdata
,
len
-
1
);
break
;
}
case
CTOS_UPDATE_DECK
:
{
if
(
!
dp
->
game
)
return
;
if
(
len
<
1
+
(
int
)
sizeof
(
unsigned
char
))
return
;
duel_mode
->
UpdateDeck
(
dp
,
pdata
,
len
-
1
);
break
;
}
case
CTOS_HAND_RESULT
:
{
if
(
!
dp
->
game
)
return
;
if
(
len
<
1
+
(
int
)
sizeof
(
CTOS_HandResult
))
return
;
CTOS_HandResult
packet
;
std
::
memcpy
(
&
packet
,
pdata
,
sizeof
packet
);
const
auto
*
pkt
=
&
packet
;
...
...
@@ -228,6 +236,8 @@ void NetServer::HandleCTOSPacket(DuelPlayer* dp, unsigned char* data, unsigned i
case
CTOS_TP_RESULT
:
{
if
(
!
dp
->
game
)
return
;
if
(
len
<
1
+
(
int
)
sizeof
(
CTOS_TPResult
))
return
;
CTOS_TPResult
packet
;
std
::
memcpy
(
&
packet
,
pdata
,
sizeof
packet
);
const
auto
*
pkt
=
&
packet
;
...
...
@@ -235,6 +245,8 @@ void NetServer::HandleCTOSPacket(DuelPlayer* dp, unsigned char* data, unsigned i
break
;
}
case
CTOS_PLAYER_INFO
:
{
if
(
len
<
1
+
(
int
)
sizeof
(
CTOS_PlayerInfo
))
return
;
CTOS_PlayerInfo
packet
;
std
::
memcpy
(
&
packet
,
pdata
,
sizeof
packet
);
const
auto
*
pkt
=
&
packet
;
...
...
@@ -244,6 +256,8 @@ void NetServer::HandleCTOSPacket(DuelPlayer* dp, unsigned char* data, unsigned i
case
CTOS_CREATE_GAME
:
{
if
(
dp
->
game
||
duel_mode
)
return
;
if
(
len
<
1
+
(
int
)
sizeof
(
CTOS_CreateGame
))
return
;
CTOS_CreateGame
packet
;
std
::
memcpy
(
&
packet
,
pdata
,
sizeof
packet
);
auto
pkt
=
&
packet
;
...
...
@@ -279,45 +293,49 @@ void NetServer::HandleCTOSPacket(DuelPlayer* dp, unsigned char* data, unsigned i
break
;
}
case
CTOS_JOIN_GAME
:
{
if
(
!
duel_mode
)
break
;
if
(
!
duel_mode
)
return
;
if
(
len
<
1
+
(
int
)
sizeof
(
CTOS_JoinGame
))
return
;
duel_mode
->
JoinGame
(
dp
,
pdata
,
false
);
break
;
}
case
CTOS_LEAVE_GAME
:
{
if
(
!
duel_mode
)
break
;
if
(
!
duel_mode
)
return
;
duel_mode
->
LeaveGame
(
dp
);
break
;
}
case
CTOS_SURRENDER
:
{
if
(
!
duel_mode
)
break
;
if
(
!
duel_mode
)
return
;
duel_mode
->
Surrender
(
dp
);
break
;
}
case
CTOS_HS_TODUELIST
:
{
if
(
!
duel_mode
||
duel_mode
->
pduel
)
break
;
if
(
!
duel_mode
||
duel_mode
->
pduel
)
return
;
duel_mode
->
ToDuelist
(
dp
);
break
;
}
case
CTOS_HS_TOOBSERVER
:
{
if
(
!
duel_mode
||
duel_mode
->
pduel
)
break
;
if
(
!
duel_mode
||
duel_mode
->
pduel
)
return
;
duel_mode
->
ToObserver
(
dp
);
break
;
}
case
CTOS_HS_READY
:
case
CTOS_HS_NOTREADY
:
{
if
(
!
duel_mode
||
duel_mode
->
pduel
)
break
;
if
(
!
duel_mode
||
duel_mode
->
pduel
)
return
;
duel_mode
->
PlayerReady
(
dp
,
(
CTOS_HS_NOTREADY
-
pktType
)
!=
0
);
break
;
}
case
CTOS_HS_KICK
:
{
if
(
!
duel_mode
||
duel_mode
->
pduel
)
break
;
if
(
!
duel_mode
||
duel_mode
->
pduel
)
return
;
if
(
len
<
1
+
(
int
)
sizeof
(
CTOS_Kick
))
return
;
CTOS_Kick
packet
;
std
::
memcpy
(
&
packet
,
pdata
,
sizeof
packet
);
const
auto
*
pkt
=
&
packet
;
...
...
@@ -325,8 +343,8 @@ void NetServer::HandleCTOSPacket(DuelPlayer* dp, unsigned char* data, unsigned i
break
;
}
case
CTOS_HS_START
:
{
if
(
!
duel_mode
||
duel_mode
->
pduel
)
break
;
if
(
!
duel_mode
||
duel_mode
->
pduel
)
return
;
duel_mode
->
StartDuel
(
dp
);
break
;
}
...
...
gframe/netserver.h
View file @
8d542df6
...
...
@@ -36,7 +36,7 @@ public:
static
void
ServerEchoEvent
(
bufferevent
*
bev
,
short
events
,
void
*
ctx
);
static
int
ServerThread
();
static
void
DisconnectPlayer
(
DuelPlayer
*
dp
);
static
void
HandleCTOSPacket
(
DuelPlayer
*
dp
,
unsigned
char
*
data
,
unsigned
int
len
);
static
void
HandleCTOSPacket
(
DuelPlayer
*
dp
,
unsigned
char
*
data
,
int
len
);
static
void
SendPacketToPlayer
(
DuelPlayer
*
dp
,
unsigned
char
proto
)
{
auto
p
=
net_server_write
;
BufferIO
::
WriteInt16
(
p
,
1
);
...
...
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