Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions sp/src/game/shared/mapbase/vscript_singletons.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5146,6 +5146,11 @@ bool CScriptConvarAccessor::Init()
AddBlockedConVar( "cl_allowdownload" );
AddBlockedConVar( "cl_allowupload" );
AddBlockedConVar( "cl_downloadfilter" );
#ifdef GAME_DLL
AddBlockedConVar( "script_connect_debugger_on_mapspawn" );
#else
AddBlockedConVar( "script_connect_debugger_on_mapspawn_client" );
#endif

return true;
}
Expand Down
4 changes: 4 additions & 0 deletions sp/src/vscript/sqdbg/sqdbg/debug.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,19 +106,23 @@
} while(0)
#endif
#define Verify( x ) Assert(x)
#define STATIC_ASSERT( x ) static_assert( x, #x )
#else
#define DebuggerBreak() ((void)0)
#define Assert( x ) ((void)0)
#define AssertMsg( x, msg ) ((void)0)
#define AssertMsg1( x, msg, a1 ) ((void)0)
#define AssertMsg2( x, msg, a1, a2 ) ((void)0)
#define Verify( x ) x
#define STATIC_ASSERT( x )
#endif // _DEBUG

#endif

#include <tier0/dbg.h>

#define STATIC_ASSERT COMPILE_TIME_ASSERT

// Misdefined for GCC in platform.h
#undef UNREACHABLE

Expand Down
41 changes: 32 additions & 9 deletions sp/src/vscript/sqdbg/sqdbg/json.h
Original file line number Diff line number Diff line change
Expand Up @@ -275,9 +275,13 @@ static inline void PutStr( CBuffer *buffer, const string_t &str )
#ifdef SQDBG_VALIDATE_SENT_MSG
for ( unsigned int i = 0; i < str.len; i++ )
{
AssertMsg( IN_RANGE_CHAR( str.ptr[i], 0x20, 0x7E ) &&
( ( str.ptr[i] != '\\' && str.ptr[i] != '\"' ) || ( i && str.ptr[i-1] == '\\' ) ),
"control char in json string" );
if ( str.ptr[i] == '\\' && ( str.ptr[i+1] == '\\' || str.ptr[i+1] == '\"' ) )
{
i++;
continue;
}

AssertMsg( str.ptr[i] != '\\' && IN_RANGE_CHAR( str.ptr[i], 0x20, 0x7E ), "control char in json string" );
}
#endif
}
Expand Down Expand Up @@ -433,7 +437,7 @@ static inline void PutStr( CBuffer *buffer, const string_t &str, bool quote )
idx += printhex< true, false >(
mem + idx,
buffer->Capacity() - idx,
(SQChar)*(unsigned char*)c );
(SQUnsignedChar)*(unsigned char*)c );
}
}
}
Expand Down Expand Up @@ -503,6 +507,7 @@ static inline void PutInt( CBuffer *buffer, I val )
template < bool padding, typename I >
static inline void PutHex( CBuffer *buffer, I val )
{
STATIC_ASSERT( IS_UNSIGNED( I ) );
buffer->base.Ensure( buffer->Size() + countdigits<16>( val ) + 1 );
int len = printhex< padding >( buffer->Base() + buffer->Size(), buffer->Capacity() - buffer->Size(), val );
buffer->size += len;
Expand Down Expand Up @@ -699,7 +704,7 @@ class wjson_table_t : public wjson_t
}
else
{
PutHex< false >( m_pBuffer, val );
PutHex< false >( m_pBuffer, cast_unsigned( I, val ) );
}
PutChar( m_pBuffer, ']' );
PutChar( m_pBuffer, '\"' );
Expand Down Expand Up @@ -850,7 +855,7 @@ class JSONParser
else
{
buf = m_Allocator->Alloc(5);
int i = printhex< true, true, false >( buf, 5, token );
int i = printhex< true, true, false >( buf, 5, (unsigned char)token );
Assert( i == 4 );
buf[i] = 0;
}
Expand All @@ -877,6 +882,24 @@ class JSONParser
m_error[len] = 0;
}

bool IsValue( char token )
{
switch ( token )
{
case Token_String:
case Token_Integer:
case Token_Float:
case Token_False:
case Token_True:
case Token_Null:
case Token_Table:
case Token_Array:
return true;
default:
return false;
}
}

char NextToken( string_t &token )
{
while ( m_cur < m_end )
Expand Down Expand Up @@ -1206,7 +1229,7 @@ class JSONParser
type = NextToken( token );
type = ParseValue( type, token, &kv->val );

if ( type == Token_Error )
if ( !IsValue( type ) )
{
SetError( "invalid token %s @ %i", Char(type), Index() );
return Token_Error;
Expand Down Expand Up @@ -1239,7 +1262,7 @@ class JSONParser

for (;;)
{
if ( type == Token_Error )
if ( !IsValue( type ) )
{
SetError( "expected '%c', got %s @ %i", ']', Char(type), Index() );
return Token_Error;
Expand Down Expand Up @@ -1315,7 +1338,7 @@ class JSONParser
value->type = JSON_NULL;
return type;
default:
return type;
return Token_Error;
}
}
};
Expand Down
2 changes: 1 addition & 1 deletion sp/src/vscript/sqdbg/sqdbg/net.h
Original file line number Diff line number Diff line change
Expand Up @@ -842,7 +842,7 @@ class CServerSocket
m_pRecvBufPtr( m_pRecvBuf ),
m_bWSAInit( false )
{
Assert( sizeof(m_pRecvBuf) <= ( 1 << ( sizeof(CMessagePool::message_t::len) * 8 ) ) );
STATIC_ASSERT( sizeof(m_pRecvBuf) <= ( 1 << ( sizeof(CMessagePool::message_t::len) * 8 ) ) );
}
};

Expand Down
Loading