[iortcw] 277/497: All: Fix off-by-one range checks in ui_main
Simon McVittie
smcv at debian.org
Fri Sep 8 10:37:07 UTC 2017
This is an automated email from the git hooks/post-receive script.
smcv pushed a commit to annotated tag 1.42d
in repository iortcw.
commit 6bb9ffd7a70ff04c6e06e51917d76efc106e1119
Author: M4N4T4RMS at gmail.com <M4N4T4RMS at gmail.com@e65d2741-a53d-b2dc-ae96-bb75fa5e4c4a>
Date: Tue Jan 13 23:49:24 2015 +0000
All: Fix off-by-one range checks in ui_main
---
MP/code/ui/ui_main.c | 12 ++++++------
SP/code/ui/ui_main.c | 12 ++++++------
2 files changed, 12 insertions(+), 12 deletions(-)
diff --git a/MP/code/ui/ui_main.c b/MP/code/ui/ui_main.c
index 9d9f09c..f229666 100644
--- a/MP/code/ui/ui_main.c
+++ b/MP/code/ui/ui_main.c
@@ -1849,7 +1849,7 @@ static void UI_DrawPlayerModel( rectDef_t *rect ) {
}
static void UI_DrawNetSource( rectDef_t *rect, float scale, vec4_t color, int textStyle ) {
- if ( ui_netSource.integer < 0 || ui_netSource.integer > numNetSources /*uiInfo.numGameTypes*/ ) { // NERVE - SMF - possible bug
+ if ( ui_netSource.integer < 0 || ui_netSource.integer >= numNetSources /*uiInfo.numGameTypes*/ ) { // NERVE - SMF - possible bug
ui_netSource.integer = 0;
}
Text_Paint( rect->x, rect->y, scale, color, UI_TranslateString( va( "Source: %s", netSources[ui_netSource.integer] ) ), 0, 0, textStyle );
@@ -1882,7 +1882,7 @@ static void UI_DrawNetMapCinematic( rectDef_t *rect, float scale, vec4_t color )
static void UI_DrawNetFilter( rectDef_t *rect, float scale, vec4_t color, int textStyle ) {
- if ( ui_serverFilterType.integer < 0 || ui_serverFilterType.integer > numServerFilters ) {
+ if ( ui_serverFilterType.integer < 0 || ui_serverFilterType.integer >= numServerFilters ) {
ui_serverFilterType.integer = 0;
}
Text_Paint( rect->x, rect->y, scale, color, va( "Filter: %s", serverFilters[ui_serverFilterType.integer].description ), 0, 0, textStyle );
@@ -1929,7 +1929,7 @@ static void UI_DrawTierMapName( rectDef_t *rect, float scale, vec4_t color, int
i = 0;
}
j = trap_Cvar_VariableValue( "ui_currentMap" );
- if ( j < 0 || j > MAPS_PER_TIER ) {
+ if ( j < 0 || j >= MAPS_PER_TIER ) {
j = 0;
}
@@ -1943,7 +1943,7 @@ static void UI_DrawTierGameType( rectDef_t *rect, float scale, vec4_t color, int
i = 0;
}
j = trap_Cvar_VariableValue( "ui_currentMap" );
- if ( j < 0 || j > MAPS_PER_TIER ) {
+ if ( j < 0 || j >= MAPS_PER_TIER ) {
j = 0;
}
@@ -2258,13 +2258,13 @@ static int UI_OwnerDrawWidth( int ownerDraw, float scale ) {
s = va( "%i. %s", ownerDraw - UI_REDTEAM1 + 1, text );
break;
case UI_NETSOURCE:
- if (ui_netSource.integer < 0 || ui_netSource.integer > numNetSources) {
+ if (ui_netSource.integer < 0 || ui_netSource.integer >= numNetSources) {
ui_netSource.integer = 0;
}
s = va( "Source: %s", netSources[ui_netSource.integer] );
break;
case UI_NETFILTER:
- if ( ui_serverFilterType.integer < 0 || ui_serverFilterType.integer > numServerFilters ) {
+ if ( ui_serverFilterType.integer < 0 || ui_serverFilterType.integer >= numServerFilters ) {
ui_serverFilterType.integer = 0;
}
s = va( "Filter: %s", serverFilters[ui_serverFilterType.integer].description );
diff --git a/SP/code/ui/ui_main.c b/SP/code/ui/ui_main.c
index 80ef130..4546af0 100644
--- a/SP/code/ui/ui_main.c
+++ b/SP/code/ui/ui_main.c
@@ -1796,7 +1796,7 @@ static void UI_DrawPlayerModel( rectDef_t *rect ) {
}
static void UI_DrawNetSource( rectDef_t *rect, int font, float scale, vec4_t color, int textStyle ) {
- if ( ui_netSource.integer < 0 || ui_netSource.integer > uiInfo.numGameTypes ) {
+ if ( ui_netSource.integer < 0 || ui_netSource.integer >= numNetSources /*uiInfo.numGameTypes*/ ) {
ui_netSource.integer = 0;
}
Text_Paint( rect->x, rect->y, font, scale, color, va( "Source: %s", netSources[ui_netSource.integer] ), 0, 0, textStyle );
@@ -1829,7 +1829,7 @@ static void UI_DrawNetMapCinematic( rectDef_t *rect, float scale, vec4_t color )
static void UI_DrawNetFilter( rectDef_t *rect, int font, float scale, vec4_t color, int textStyle ) {
- if ( ui_serverFilterType.integer < 0 || ui_serverFilterType.integer > numServerFilters ) {
+ if ( ui_serverFilterType.integer < 0 || ui_serverFilterType.integer >= numServerFilters ) {
ui_serverFilterType.integer = 0;
}
Text_Paint( rect->x, rect->y, font, scale, color, va( "Filter: %s", serverFilters[ui_serverFilterType.integer].description ), 0, 0, textStyle );
@@ -1876,7 +1876,7 @@ static void UI_DrawTierMapName( rectDef_t *rect, int font, float scale, vec4_t c
i = 0;
}
j = trap_Cvar_VariableValue( "ui_currentMap" );
- if ( j < 0 || j > MAPS_PER_TIER ) {
+ if ( j < 0 || j >= MAPS_PER_TIER ) {
j = 0;
}
@@ -1890,7 +1890,7 @@ static void UI_DrawTierGameType( rectDef_t *rect, int font, float scale, vec4_t
i = 0;
}
j = trap_Cvar_VariableValue( "ui_currentMap" );
- if ( j < 0 || j > MAPS_PER_TIER ) {
+ if ( j < 0 || j >= MAPS_PER_TIER ) {
j = 0;
}
@@ -2199,13 +2199,13 @@ static int UI_OwnerDrawWidth( int ownerDraw, int font, float scale ) {
s = va( "%i. %s", ownerDraw - UI_REDTEAM1 + 1, text );
break;
case UI_NETSOURCE:
- if (ui_netSource.integer < 0 || ui_netSource.integer > numNetSources) {
+ if (ui_netSource.integer < 0 || ui_netSource.integer >= numNetSources) {
ui_netSource.integer = 0;
}
s = va( "Source: %s", netSources[ui_netSource.integer] );
break;
case UI_NETFILTER:
- if ( ui_serverFilterType.integer < 0 || ui_serverFilterType.integer > numServerFilters ) {
+ if ( ui_serverFilterType.integer < 0 || ui_serverFilterType.integer >= numServerFilters ) {
ui_serverFilterType.integer = 0;
}
s = va( "Filter: %s", serverFilters[ui_serverFilterType.integer].description );
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-games/iortcw.git
More information about the Pkg-games-commits
mailing list