Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
R
rd-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
苍蓝
rd-ygopro
Commits
5485940f
Commit
5485940f
authored
May 21, 2024
by
Chen Bill
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
DuelClient: discard too large packet
parent
9a55d543
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
4 deletions
+12
-4
gframe/duelclient.cpp
gframe/duelclient.cpp
+10
-3
gframe/duelclient.h
gframe/duelclient.h
+2
-1
No files found.
gframe/duelclient.cpp
View file @
5485940f
...
...
@@ -20,6 +20,7 @@ bool DuelClient::is_host = false;
event_base
*
DuelClient
::
client_base
=
0
;
bufferevent
*
DuelClient
::
client_bev
=
0
;
unsigned
char
DuelClient
::
duel_client_read
[
SIZE_NETWORK_BUFFER
];
int
DuelClient
::
read_len
=
0
;
unsigned
char
DuelClient
::
duel_client_write
[
SIZE_NETWORK_BUFFER
];
bool
DuelClient
::
is_closing
=
false
;
bool
DuelClient
::
is_swapping
=
false
;
...
...
@@ -106,9 +107,15 @@ void DuelClient::ClientRead(bufferevent* bev, void* ctx) {
evbuffer_copyout
(
input
,
&
packet_len
,
2
);
if
(
len
<
(
size_t
)
packet_len
+
2
)
return
;
evbuffer_remove
(
input
,
duel_client_read
,
packet_len
+
2
);
if
(
packet_len
)
HandleSTOCPacketLan
(
&
duel_client_read
[
2
],
packet_len
);
if
(
packet_len
+
2
>
SIZE_NETWORK_BUFFER
)
{
evbuffer_drain
(
input
,
packet_len
+
2
);
read_len
=
0
;
}
else
{
read_len
=
evbuffer_remove
(
input
,
duel_client_read
,
packet_len
+
2
);
}
if
(
read_len
>
0
)
HandleSTOCPacketLan
(
&
duel_client_read
[
2
],
read_len
-
2
);
len
-=
packet_len
+
2
;
}
}
...
...
gframe/duelclient.h
View file @
5485940f
...
...
@@ -27,6 +27,7 @@ private:
static
event_base
*
client_base
;
static
bufferevent
*
client_bev
;
static
unsigned
char
duel_client_read
[
SIZE_NETWORK_BUFFER
];
static
int
read_len
;
static
unsigned
char
duel_client_write
[
SIZE_NETWORK_BUFFER
];
static
bool
is_closing
;
static
bool
is_swapping
;
...
...
@@ -62,7 +63,7 @@ public:
auto
p
=
duel_client_write
;
int
blen
=
sizeof
(
ST
);
if
(
blen
>
MAX_DATA_SIZE
)
blen
=
MAX_DATA_SIZE
;
return
;
BufferIO
::
WriteInt16
(
p
,
(
short
)(
1
+
blen
));
BufferIO
::
WriteInt8
(
p
,
proto
);
memcpy
(
p
,
&
st
,
blen
);
...
...
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