Permalink
Browse files

Info string validation

  • Loading branch information...
mbasaglia committed Feb 17, 2016
1 parent 3a8297d commit 16977b851eed8cc1a22818f5cac83e279e92bee0
@@ -1909,7 +1909,7 @@ InfoMap InfoStringToMap( const std::string& string )
std::getline( input, key, INFO_SEPARATOR );
std::string value;
std::getline( input, value, INFO_SEPARATOR );
if ( !key.empty() )
if ( !key.empty() && InfoValidItem(key) && InfoValidItem(value) )
{
map[key] = value;
}
@@ -1918,6 +1918,11 @@ InfoMap InfoStringToMap( const std::string& string )
return map;
}
bool InfoValidItem( const std::string& string )
{
return string.find(INFO_SEPARATOR) == std::string::npos;
}
/*
===============
Info_ValueForKey
@@ -1545,6 +1545,11 @@ enum class tokenType_t {
*/
InfoMap InfoStringToMap( const std::string& string );
/*
* Whether string is a valid info key or value
*/
bool InfoValidItem(const std::string& string);
// DEPRECATED: Use InfoMap
const char *Info_ValueForKey( const char *s, const char *key );
// DEPRECATED: Use InfoMap
@@ -530,7 +530,7 @@ void SVC_Status( netadr_t from, const Cmd::Args& args )
InfoMap info_map;
Cvar::PopulateInfoMap(CVAR_SERVERINFO, info_map);
if ( args.Argc() > 1 && Challenge::ValidString(args.Argv(1)) )
if ( args.Argc() > 1 && InfoValidItem(args.Argv(1)) )
{
// echo back the parameter to status. so master servers can use it as a challenge
// to prevent timed spoofed reply packets that add ghost servers
@@ -591,7 +591,7 @@ void SVC_Info( netadr_t from, const Cmd::Args& args )
InfoMap info_map;
if ( args.Argc() > 1 && Challenge::ValidString(args.Argv(1)) )
if ( args.Argc() > 1 && InfoValidItem(args.Argv(1)) )
{
std::string challenge = args.Argv(1);
// echo back the parameter to status. so master servers can use it as a challenge

0 comments on commit 16977b8

Please sign in to comment.