Permalink
Browse files

Port some changes to SVC_RemoteCommand present in ioq3

  • Loading branch information...
mbasaglia committed Oct 30, 2015
1 parent 93d3084 commit c6f99e5dfc92dcfbc7bd44bcd800434dee18fabe
Showing with 18 additions and 13 deletions.
  1. +18 −13 daemon/src/engine/server/sv_main.cpp
@@ -832,42 +832,47 @@ void SVC_RemoteCommand( netadr_t from, const Cmd::Args& args )
bool valid;
unsigned int time;
// show_bug.cgi?id=376
// if we send an OOB print message this size, 1.31 clients die in a Com_Printf buffer overflow
// the buffer overflow will be fixed in > 1.31 clients
// but we want a server side fix
// we must NEVER send an OOB message that will be > 1.31 MAXPRINTMSG (4096)
#define SV_OUTPUTBUF_LENGTH ( 256 - 16 )
static unsigned int lasttime = 0;
// TTimo - show_bug.cgi?id=534
time = Com_Milliseconds();
if ( time < ( lasttime + 500 ) || args.Argc() < 3 )
if ( args.Argc() < 3 )
{
return;
}
lasttime = time;
static int lasttime = 0;
time = Com_Milliseconds();

This comment has been minimized.

Show comment
Hide comment
@Kangz

Kangz Nov 2, 2015

Member

better to use time functions present in common/System.h

@Kangz

Kangz Nov 2, 2015

Member

better to use time functions present in common/System.h

if ( !strlen( sv_rconPassword->string ) || args.Argv(1) != sv_rconPassword->string )
{
// If the rconpassword is bad and one just happned recently, don't spam the log file, just die.
if ( time < lasttime + 600 )
{
return;
}
valid = false;
Com_Printf( "Bad rcon from %s:\n%s\n", NET_AdrToString( from ), args.ConcatArgs(2).c_str() );
}
else
{
// If the rconpassword is good, allow it much sooner than a bad one.
if ( time < lasttime + 180 )
{
return;
}
valid = true;
Com_Printf( "Rcon from %s:\n%s\n", NET_AdrToString( from ), args.ConcatArgs(2).c_str() );
}
lasttime = time;
// start redirecting all print outputs to the packet
// FIXME TTimo our rcon redirection could be improved
// big rcon commands such as status lead to sending
// out of band packets on every single call to Com_Printf
// which leads to client overflows
// see show_bug.cgi?id=51
// (also a Q3 issue)
auto env = RconEnvironment(from, SV_OUTPUTBUF_LENGTH);
auto env = RconEnvironment(from, 1024 - 16);

This comment has been minimized.

Show comment
Hide comment
@Kangz

Kangz Nov 2, 2015

Member

Can you explicit the hardcoded value?

@Kangz

Kangz Nov 2, 2015

Member

Can you explicit the hardcoded value?

This comment has been minimized.

Show comment
Hide comment
@mbasaglia

mbasaglia Nov 2, 2015

Member

btw is there a reason for such low values?
(The comments looks outdated)

@mbasaglia

mbasaglia Nov 2, 2015

Member

btw is there a reason for such low values?
(The comments looks outdated)

This comment has been minimized.

Show comment
Hide comment
@Kangz

Kangz Nov 3, 2015

Member

it is, if you can figure out a better value, go for it!

@Kangz

Kangz Nov 3, 2015

Member

it is, if you can figure out a better value, go for it!

if ( !strlen( sv_rconPassword->string ) )
{

0 comments on commit c6f99e5

Please sign in to comment.