From 3f8d708bc4979fbdb848af92cd0991c3d3c68d04 Mon Sep 17 00:00:00 2001 From: Garux Date: Mon, 20 Jan 2020 19:46:19 +0300 Subject: [PATCH] repackBSPMain(): do Error on bspList overflow --- tools/quake3/q3map2/autopk3.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tools/quake3/q3map2/autopk3.c b/tools/quake3/q3map2/autopk3.c index 32b2c38a..ac95fad8 100644 --- a/tools/quake3/q3map2/autopk3.c +++ b/tools/quake3/q3map2/autopk3.c @@ -898,7 +898,8 @@ int repackBSPMain( int argc, char **argv ){ int bspListN = 0; - char (*bspList)[1024] = safe_malloc( 8192 * sizeof( bspList[0] ) ); + const int bspListSize = 8192; + char (*bspList)[1024] = safe_malloc( bspListSize * sizeof( bspList[0] ) ); /* do some path mangling */ strcpy( source, ExpandArg( argv[ argc - 1 ] ) ); @@ -925,6 +926,8 @@ int repackBSPMain( int argc, char **argv ){ if ( !GetToken( qtrue ) ) { break; } + if( bspListSize == bspListN ) + Error( "bspList overflow" ); strcpy( bspList[bspListN], token ); bspListN++; }