summaryrefslogtreecommitdiff
path: root/source/cvar.c
diff options
context:
space:
mode:
authorAndrey Nazarov <skuller@skuller.net>2009-09-05 12:34:05 +0000
committerAndrey Nazarov <skuller@skuller.net>2009-09-05 12:34:05 +0000
commitc1df6019baf94cdec6b1404de69fafce12aa26a4 (patch)
tree340ff19edbd6c30e76f70c13303e6859833f3bb7 /source/cvar.c
parentf1d3a7ffd40a0e6768b220cf76d05db3c57c3e89 (diff)
Changed return type of Info_SubValidate to size_t.
Print more informative warnings when attempting to set an invalid info cvar value.
Diffstat (limited to 'source/cvar.c')
-rw-r--r--source/cvar.c24
1 files changed, 18 insertions, 6 deletions
diff --git a/source/cvar.c b/source/cvar.c
index 966a0c4..e009e33 100644
--- a/source/cvar.c
+++ b/source/cvar.c
@@ -208,6 +208,21 @@ static void Cvar_EngineGet( cvar_t *var, const char *var_value, int flags ) {
var->flags |= flags;
}
+static qboolean validate_info_cvar( const char *s ) {
+ size_t len = Info_SubValidate( s );
+
+ if( len == SIZE_MAX ) {
+ Com_WPrintf( "Info cvars should not contain '\\', ';' or '\"' characters.\n" );
+ return qfalse;
+ }
+
+ if( len >= MAX_QPATH ) {
+ Com_WPrintf( "Info cvars should be less than 64 characters long.\n" );
+ return qfalse;
+ }
+
+ return qtrue;
+}
/*
============
@@ -230,12 +245,10 @@ cvar_t *Cvar_Get( const char *var_name, const char *var_value, int flags ) {
}
if( flags & CVAR_INFOMASK ) {
- if( Info_SubValidate( var_name ) == -1 ) {
- Com_WPrintf( "Invalid info cvar name '%s'.\n", var_name );
+ if( !validate_info_cvar( var_name ) ) {
return NULL;
}
- if( Info_SubValidate( var_value ) == -1 ) {
- Com_WPrintf( "Invalid info cvar value '%s' for '%s'.\n", var_value, var_name );
+ if( !validate_info_cvar( var_value ) ) {
return NULL;
}
}
@@ -303,8 +316,7 @@ void Cvar_SetByVar( cvar_t *var, const char *value, from_t from ) {
}
if( var->flags & CVAR_INFOMASK ) {
- if( Info_SubValidate( value ) == -1 ) {
- Com_WPrintf( "Invalid info cvar value '%s' for '%s'.\n", value, var->name );
+ if( !validate_info_cvar( value ) ) {
return;
}
}