ref: vk: use safe string functions, as unsafe versions were removed from libpublic

This commit is contained in:
Alibek Omarov 2023-04-28 17:43:50 +03:00
parent e5e2a63ba2
commit 62590dd2a9
5 changed files with 12 additions and 10 deletions

View File

@ -88,7 +88,7 @@ static void speedsPrintf( const char *msg, ... ) {
char text[MAX_SPEEDS_MESSAGE]; char text[MAX_SPEEDS_MESSAGE];
va_start( argptr, msg ); va_start( argptr, msg );
Q_vsprintf( text, msg, argptr ); Q_vsnprintf( text, sizeof( text ), msg, argptr );
va_end( argptr ); va_end( argptr );
speedsStrcat(text); speedsStrcat(text);

View File

@ -209,7 +209,7 @@ static void fillLightFromProps( vk_light_entity_t *le, const entity_props_t *pro
} }
if (have_fields & Field_target) if (have_fields & Field_target)
Q_strcpy(le->target_entity, props->target); Q_strncpy( le->target_entity, props->target, sizeof( le->target_entity ));
if (have_fields & Field_origin) if (have_fields & Field_origin)
VectorCopy(props->origin, le->origin); VectorCopy(props->origin, le->origin);
@ -317,7 +317,7 @@ static void addTargetEntity( const entity_props_t *props ) {
return; return;
} }
Q_strcpy(target->targetname, props->targetname); Q_strncpy( target->targetname, props->targetname, sizeof( target->targetname ));
VectorCopy(props->origin, target->origin); VectorCopy(props->origin, target->origin);
g_map_entities.refs[g_map_entities.entity_count] = (xvk_mapent_ref_t){ g_map_entities.refs[g_map_entities.entity_count] = (xvk_mapent_ref_t){
@ -329,7 +329,7 @@ static void addTargetEntity( const entity_props_t *props ) {
} }
static void readWorldspawn( const entity_props_t *props ) { static void readWorldspawn( const entity_props_t *props ) {
Q_strcpy(g_map_entities.wadlist, props->wad); Q_strncpy( g_map_entities.wadlist, props->wad, sizeof( g_map_entities.wadlist ));
g_map_entities.refs[g_map_entities.entity_count] = (xvk_mapent_ref_t){ g_map_entities.refs[g_map_entities.entity_count] = (xvk_mapent_ref_t){
.class = Worldspawn, .class = Worldspawn,
.index = -1, .index = -1,
@ -348,7 +348,7 @@ static void readFuncWall( const entity_props_t *const props, uint32_t have_field
*e = (xvk_mapent_func_wall_t){0}; *e = (xvk_mapent_func_wall_t){0};
Q_strcpy(e->model, props->model); Q_strncpy( e->model, props->model, sizeof( e->model ));
/* NOTE: not used /* NOTE: not used
e->rendercolor.r = 255; e->rendercolor.r = 255;

View File

@ -295,6 +295,7 @@ void Mod_LoadMapSprite( model_t *mod, const void *buffer, size_t size, qboolean
byte *src, *dst; byte *src, *dst;
rgbdata_t *pix, temp; rgbdata_t *pix, temp;
char texname[128]; char texname[128];
char poolname[MAX_VA_STRING];
int i, j, x, y, w, h; int i, j, x, y, w, h;
int xl, yl, xh, yh; int xl, yl, xh, yh;
int linedelta, numframes; int linedelta, numframes;
@ -334,7 +335,8 @@ void Mod_LoadMapSprite( model_t *mod, const void *buffer, size_t size, qboolean
// determine how many frames we needs // determine how many frames we needs
numframes = (pix->width * pix->height) / (w * h); numframes = (pix->width * pix->height) / (w * h);
mod->mempool = Mem_AllocPool( va( "^2%s^7", mod->name )); Q_snprintf( poolname, sizeof( poolname ), "^2%s^7", mod->name );
mod->mempool = Mem_AllocPool( poolname );
psprite = Mem_Calloc( mod->mempool, sizeof( msprite_t ) + ( numframes - 1 ) * sizeof( psprite->frames )); psprite = Mem_Calloc( mod->mempool, sizeof( msprite_t ) + ( numframes - 1 ) * sizeof( psprite->frames ));
mod->cache.data = psprite; // make link to extradata mod->cache.data = psprite; // make link to extradata

View File

@ -3320,7 +3320,7 @@ static void R_StudioLoadTexture( model_t *mod, studiohdr_t *phdr, mstudiotexture
} }
Q_strncpy( mdlname, mod->name, sizeof( mdlname )); Q_strncpy( mdlname, mod->name, sizeof( mdlname ));
COM_FileBase( ptexture->name, name ); COM_FileBase( ptexture->name, name, sizeof( name ));
COM_StripExtension( mdlname ); COM_StripExtension( mdlname );
if( FBitSet( ptexture->flags, STUDIO_NF_NOMIPS )) if( FBitSet( ptexture->flags, STUDIO_NF_NOMIPS ))

View File

@ -977,7 +977,7 @@ static int CheckSkybox( const char *name )
{ {
const char *skybox_ext[] = { "png", "dds", "tga", "bmp" }; const char *skybox_ext[] = { "png", "dds", "tga", "bmp" };
int i, j, num_checked_sides; int i, j, num_checked_sides;
const char *sidename; char sidename[MAX_VA_STRING];
// search for skybox images // search for skybox images
for( i = 0; i < ARRAYSIZE(skybox_ext); i++ ) for( i = 0; i < ARRAYSIZE(skybox_ext); i++ )
@ -986,7 +986,7 @@ static int CheckSkybox( const char *name )
for( j = 0; j < 6; j++ ) for( j = 0; j < 6; j++ )
{ {
// build side name // build side name
sidename = va( "%s%s.%s", name, g_skybox_info[j].suffix, skybox_ext[i] ); Q_snprintf( sidename, sizeof( sidename ), "%s%s.%s", name, g_skybox_info[j].suffix, skybox_ext[i] );
if( gEngine.fsapi->FileExists( sidename, false )) if( gEngine.fsapi->FileExists( sidename, false ))
num_checked_sides++; num_checked_sides++;
@ -998,7 +998,7 @@ static int CheckSkybox( const char *name )
for( j = 0; j < 6; j++ ) for( j = 0; j < 6; j++ )
{ {
// build side name // build side name
sidename = va( "%s_%s.%s", name, g_skybox_info[j].suffix, skybox_ext[i] ); Q_snprintf( sidename, sizeof( sidename ), "%s_%s.%s", name, g_skybox_info[j].suffix, skybox_ext[i] );
if( gEngine.fsapi->FileExists( sidename, false )) if( gEngine.fsapi->FileExists( sidename, false ))
num_checked_sides++; num_checked_sides++;
} }