Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
SRB2
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
STJr
SRB2
Commits
457b761d
Commit
457b761d
authored
5 months ago
by
Hanicef
Browse files
Options
Downloads
Patches
Plain Diff
Fix segfault when sending excessively large netcmds
parent
1ae07f83
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!2568
Lift NetXCmd limits
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/netcode/net_command.c
+20
-8
20 additions, 8 deletions
src/netcode/net_command.c
with
20 additions
and
8 deletions
src/netcode/net_command.c
+
20
−
8
View file @
457b761d
...
@@ -64,6 +64,12 @@ void SendNetXCmd(netxcmd_t id, const void *param, size_t nparam)
...
@@ -64,6 +64,12 @@ void SendNetXCmd(netxcmd_t id, const void *param, size_t nparam)
{
{
textcmdbuf_t
*
buf
=
textcmdbuf
;
textcmdbuf_t
*
buf
=
textcmdbuf
;
if
(
2
+
nparam
>
MAXTEXTCMD
)
{
CONS_Alert
(
CONS_ERROR
,
M_GetText
(
"packet too large to fit NetXCmd, cannot add netcmd %d! (size: %s, max: %d)
\n
"
),
id
,
sizeu1
(
2
+
nparam
),
MAXTEXTCMD
);
return
;
}
// for future reference: if (cv_debug) != debug disabled.
// for future reference: if (cv_debug) != debug disabled.
CONS_Alert
(
CONS_NOTICE
,
M_GetText
(
"NetXCmd buffer full, delaying netcmd %d... (size: %d, needed: %s)
\n
"
),
id
,
localtextcmd
[
0
],
sizeu1
(
nparam
));
CONS_Alert
(
CONS_NOTICE
,
M_GetText
(
"NetXCmd buffer full, delaying netcmd %d... (size: %d, needed: %s)
\n
"
),
id
,
localtextcmd
[
0
],
sizeu1
(
nparam
));
if
(
buf
==
NULL
)
if
(
buf
==
NULL
)
...
@@ -79,16 +85,16 @@ void SendNetXCmd(netxcmd_t id, const void *param, size_t nparam)
...
@@ -79,16 +85,16 @@ void SendNetXCmd(netxcmd_t id, const void *param, size_t nparam)
buf
=
buf
->
next
;
buf
=
buf
->
next
;
if
(
buf
->
cmd
[
0
]
+
2
+
nparam
>
MAXTEXTCMD
)
if
(
buf
->
cmd
[
0
]
+
2
+
nparam
>
MAXTEXTCMD
)
{
WriteNetXCmd
(
buf
->
cmd
,
id
,
param
,
nparam
);
}
else
{
{
buf
->
next
=
Z_Malloc
(
sizeof
(
textcmdbuf_t
),
PU_STATIC
,
NULL
);
buf
->
next
=
Z_Malloc
(
sizeof
(
textcmdbuf_t
),
PU_STATIC
,
NULL
);
buf
->
next
->
cmd
[
0
]
=
0
;
buf
->
next
->
cmd
[
0
]
=
0
;
buf
->
next
->
next
=
NULL
;
buf
->
next
->
next
=
NULL
;
WriteNetXCmd
(
buf
->
next
->
cmd
,
id
,
param
,
nparam
);
WriteNetXCmd
(
buf
->
next
->
cmd
,
id
,
param
,
nparam
);
}
}
else
{
WriteNetXCmd
(
buf
->
cmd
,
id
,
param
,
nparam
);
}
return
;
return
;
}
}
WriteNetXCmd
(
localtextcmd
,
id
,
param
,
nparam
);
WriteNetXCmd
(
localtextcmd
,
id
,
param
,
nparam
);
...
@@ -101,6 +107,12 @@ void SendNetXCmd2(netxcmd_t id, const void *param, size_t nparam)
...
@@ -101,6 +107,12 @@ void SendNetXCmd2(netxcmd_t id, const void *param, size_t nparam)
{
{
textcmdbuf_t
*
buf
=
textcmdbuf2
;
textcmdbuf_t
*
buf
=
textcmdbuf2
;
if
(
2
+
nparam
>
MAXTEXTCMD
)
{
CONS_Alert
(
CONS_ERROR
,
M_GetText
(
"packet too large to fit NetXCmd, cannot add netcmd %d! (size: %s, max: %d)
\n
"
),
id
,
sizeu1
(
2
+
nparam
),
MAXTEXTCMD
);
return
;
}
// for future reference: if (cv_debug) != debug disabled.
// for future reference: if (cv_debug) != debug disabled.
CONS_Alert
(
CONS_NOTICE
,
M_GetText
(
"NetXCmd buffer full, delaying netcmd %d... (size: %d, needed: %s)
\n
"
),
id
,
localtextcmd2
[
0
],
sizeu1
(
nparam
));
CONS_Alert
(
CONS_NOTICE
,
M_GetText
(
"NetXCmd buffer full, delaying netcmd %d... (size: %d, needed: %s)
\n
"
),
id
,
localtextcmd2
[
0
],
sizeu1
(
nparam
));
if
(
buf
==
NULL
)
if
(
buf
==
NULL
)
...
@@ -116,16 +128,16 @@ void SendNetXCmd2(netxcmd_t id, const void *param, size_t nparam)
...
@@ -116,16 +128,16 @@ void SendNetXCmd2(netxcmd_t id, const void *param, size_t nparam)
buf
=
buf
->
next
;
buf
=
buf
->
next
;
if
(
buf
->
cmd
[
0
]
+
2
+
nparam
>
MAXTEXTCMD
)
if
(
buf
->
cmd
[
0
]
+
2
+
nparam
>
MAXTEXTCMD
)
{
WriteNetXCmd
(
buf
->
cmd
,
id
,
param
,
nparam
);
}
else
{
{
buf
->
next
=
Z_Malloc
(
sizeof
(
textcmdbuf_t
),
PU_STATIC
,
NULL
);
buf
->
next
=
Z_Malloc
(
sizeof
(
textcmdbuf_t
),
PU_STATIC
,
NULL
);
buf
->
next
->
cmd
[
0
]
=
0
;
buf
->
next
->
cmd
[
0
]
=
0
;
buf
->
next
->
next
=
NULL
;
buf
->
next
->
next
=
NULL
;
WriteNetXCmd
(
buf
->
next
->
cmd
,
id
,
param
,
nparam
);
WriteNetXCmd
(
buf
->
next
->
cmd
,
id
,
param
,
nparam
);
}
}
else
{
WriteNetXCmd
(
buf
->
cmd
,
id
,
param
,
nparam
);
}
return
;
return
;
}
}
WriteNetXCmd
(
localtextcmd2
,
id
,
param
,
nparam
);
WriteNetXCmd
(
localtextcmd2
,
id
,
param
,
nparam
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment