From 40ab7fa26cca4e544a5941bdb6937c2bca294cb2 Mon Sep 17 00:00:00 2001 From: Garux Date: Fri, 29 Jan 2021 05:14:33 +0300 Subject: [PATCH] remove excess string overflow checks, fix warnings --- tools/quake3/q3map2/bspfile_abstract.cpp | 3 ++- tools/quake3/q3map2/writebsp.cpp | 8 ++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/tools/quake3/q3map2/bspfile_abstract.cpp b/tools/quake3/q3map2/bspfile_abstract.cpp index 1d8f206d..0d569d91 100644 --- a/tools/quake3/q3map2/bspfile_abstract.cpp +++ b/tools/quake3/q3map2/bspfile_abstract.cpp @@ -161,7 +161,8 @@ void SwapBSPFile( void ){ si = ShaderInfoForShader( bspShaders[ i ].shader ); if ( !strEmptyOrNull( si->remapShader ) ) { // copy and clear the rest of memory // check for overflow by String64 - strncpy( bspShaders[ i ].shader, String64()( si->remapShader ), sizeof( bspShaders[ i ].shader ) ); + const auto remap = String64()( si->remapShader ); + strncpy( bspShaders[ i ].shader, remap, sizeof( bspShaders[ i ].shader ) ); } } bspShaders[ i ].contentFlags = LittleLong( bspShaders[ i ].contentFlags ); diff --git a/tools/quake3/q3map2/writebsp.cpp b/tools/quake3/q3map2/writebsp.cpp index 4be049bf..0f983656 100644 --- a/tools/quake3/q3map2/writebsp.cpp +++ b/tools/quake3/q3map2/writebsp.cpp @@ -79,8 +79,8 @@ int EmitShader( const char *shader, int *contentFlags, int *surfaceFlags ){ AUTOEXPAND_BY_REALLOC_BSP( Shaders, 1024 ); numBSPShaders++; - // copy and clear the rest of memory // check for overflow by String64 - strncpy( bspShaders[ i ].shader, String64()( shader ), sizeof( bspShaders[ i ].shader ) ); + // copy and clear the rest of memory + strncpy( bspShaders[ i ].shader, si->shader, sizeof( bspShaders[ i ].shader ) ); bspShaders[ i ].surfaceFlags = si->surfaceFlags; bspShaders[ i ].contentFlags = si->contentFlags; @@ -497,8 +497,8 @@ void EmitFogs( void ){ for ( i = 0; i < numMapFogs; i++ ) { /* set shader */ - // copy and clear the rest of memory // check for overflow by String64 - strncpy( bspFogs[ i ].shader, String64()( mapFogs[ i ].si->shader ), sizeof( bspFogs[ i ].shader ) ); + // copy and clear the rest of memory + strncpy( bspFogs[ i ].shader, mapFogs[ i ].si->shader, sizeof( bspFogs[ i ].shader ) ); /* global fog doesn't have an associated brush */ if ( mapFogs[ i ].brush == NULL ) {