strcpy, strcat, vsprintf -> strncpy, strncat, vsnprintf

This commit is contained in:
Pan7 2015-09-06 03:29:46 +02:00
parent 6c759f1e0a
commit 252d4fe6b4
98 changed files with 642 additions and 570 deletions

View file

@ -122,17 +122,17 @@ void CBackgroundDialogPage::Browse(){
return;
}
strcpy( browsedir,ct );
Q_strncpyz( browsedir, ct, sizeof( browsedir ) );
// make sure we have a trailing /
if ( browsedir[strlen( browsedir ) - 1] != '/' ) {
strcat( browsedir,"/" );
strncat( browsedir, "/", sizeof( browsedir ) );
}
//if we dont have a file yet, don't try to use it for default dir
if ( m_bValidFile ) {
// filename should always be a nice clean unix style relative path
ct = gtk_label_get_text( GTK_LABEL( m_pFileLabel ) );
strcat( browsedir,ct );
strncat( browsedir, ct, sizeof( browsedir ) );
Syn_Printf( MSG_PREFIX "full path: %s\n",browsedir );
// lop off the file part

View file

@ -191,7 +191,7 @@ void DTrainDrawer::Draw2D( VIEWTYPE vt ) {
void AddSplineControl( const char* control, splinePoint_t* pSP ) {
controlPoint_t cp;
strncpy( cp.strName, control, 64 );
Q_strncpyz( cp.strName, control, sizeof( cp.strName ) );
pSP->m_pointList.push_front( cp );
}
@ -324,7 +324,7 @@ void DTrainDrawer::BuildPaths() {
void DTrainDrawer::AddControlPoint( const char* name, vec_t* origin ){
controlPoint_t* pCP = new controlPoint_t;
strncpy( pCP->strName, name, 64 );
Q_strncpyz( pCP->strName, name, sizeof( pCP->strName ) );
VectorCopy( origin, pCP->vOrigin );
m_pointList.push_back( pCP );
@ -333,8 +333,8 @@ void DTrainDrawer::AddControlPoint( const char* name, vec_t* origin ){
splinePoint_t* DTrainDrawer::AddSplinePoint( const char* name, const char* target, vec_t* origin ){
splinePoint_t* pSP = new splinePoint_t;
strncpy( pSP->point.strName, name, 64 );
strncpy( pSP->strTarget, target, 64 );
Q_strncpyz( pSP->point.strName, name, sizeof( pSP->point.strName ) );
Q_strncpyz( pSP->strTarget, target, sizeof( pSP->strTarget ) );
VectorCopy( origin, pSP->point.vOrigin );
m_splineList.push_back( pSP );

View file

@ -66,7 +66,7 @@ DTreePlanter() {
m_world.LoadSelectedBrushes();
char buffer[256];
GetFilename( buffer, "bt/tp_ent.txt" );
GetFilename( buffer, "bt/tp_ent.txt", sizeof( buffer ) );
FILE* file = fopen( buffer, "rb" );
if ( file ) {

View file

@ -278,11 +278,11 @@ const char* CSynapseClientBobtoolz::GetInfo(){
return "bobToolz module built " __DATE__ " " RADIANT_VERSION;
}
char* GetFilename( char* buffer, const char* filename ) {
strcpy( buffer, g_pSynapseServer->GetModuleFilename( &g_SynapseClient ) );
char* GetFilename( char* buffer, const char* filename, size_t length ) {
Q_strncpyz( buffer, g_pSynapseServer->GetModuleFilename( &g_SynapseClient ), length );
StripFilename( buffer );
strcat( buffer, "/" );
strcat( buffer, filename );
strncat( buffer, "/", length );
strncat( buffer, filename, length );
buffer = UnixToDosPath( buffer );
return buffer;
}

View file

@ -829,8 +829,8 @@ int DoDoorsBox( DoorRS* rs ){
char buffer[256];
GList *listMainTextures = NULL;
GList *listTrimTextures = NULL;
LoadGList( GetFilename( buffer, "plugins/bt/door-tex.txt" ), &listMainTextures );
LoadGList( GetFilename( buffer, "plugins/bt/door-tex-trim.txt" ), &listTrimTextures );
LoadGList( GetFilename( buffer, "plugins/bt/door-tex.txt", sizeof( buffer ) ), &listMainTextures );
LoadGList( GetFilename( buffer, "plugins/bt/door-tex-trim.txt", sizeof( buffer ) ), &listTrimTextures );
vbox = gtk_box_new( GTK_ORIENTATION_VERTICAL, 10 );
gtk_container_add( GTK_CONTAINER( window ), vbox );

View file

@ -55,13 +55,13 @@ DTreePlanter* g_TreePlanter = NULL;
//========================//
void LoadLists(){
char buffer[256];
char buffer[PATH_MAX];
if ( !el1Loaded ) {
el1Loaded = LoadExclusionList( GetFilename( buffer, "bt/bt-el1.txt" ), &exclusionList );
el1Loaded = LoadExclusionList( GetFilename( buffer, "bt/bt-el1.txt", sizeof( buffer ) ), &exclusionList );
}
if ( !el2Loaded ) {
el2Loaded = LoadExclusionList( GetFilename( buffer, "bt/bt-el2.txt" ), &exclusionList_Face );
el2Loaded = LoadExclusionList( GetFilename( buffer, "bt/bt-el2.txt", sizeof( buffer ) ), &exclusionList_Face );
}
}

View file

@ -140,7 +140,7 @@ void Sys_ERROR( const char* text, ... ){
char buf[32768];
va_start( argptr,text );
vsprintf( buf, text,argptr );
vsnprintf( buf, sizeof( buf ), text, argptr );
va_end( argptr );
Sys_Printf( "BobToolz::ERROR->%s", buf );
@ -152,7 +152,7 @@ void Sys_ERROR( const char* text, ... ){
char buf[32768];
va_start (argptr,text);
vsprintf (buf, text,argptr);
vsnprintf (buf, sizeof( buf ), text, argptr);
va_end (argptr);
g_FuncTable.m_pfnSysMsg ( buf );
@ -248,19 +248,19 @@ bool Q_Exec( const char *pCmd, bool bCreateConsole ){
#endif
void StartBSP(){
char exename[256];
GetFilename( exename, "q3map" );
char exename[PATH_MAX];
GetFilename( exename, "q3map", sizeof( exename ) );
UnixToDosPath( exename ); // do we want this done in linux version?
char mapname[256];
const char *pn = g_FuncTable.m_pfnReadProjectKey( "mapspath" );
strcpy( mapname, pn );
strcat( mapname, "/ac_prt.map" );
Q_strncpyz( mapname, pn, sizeof( mapname ) );
strncat( mapname, "/ac_prt.map", sizeof( mapname ) );
UnixToDosPath( mapname );
char command[1024];
sprintf( command, "%s -nowater -fulldetail %s", exename, mapname );
snprintf( command, sizeof( command ), "%s -nowater -fulldetail %s", exename, mapname );
Q_Exec( command, TRUE );
}
@ -272,11 +272,11 @@ void BuildMiniPrt( list<Str>* exclusionList ){
DEntity world;
char buffer[128];
char buffer[PATH_MAX];
const char *pn = g_FuncTable.m_pfnReadProjectKey( "mapspath" );
strcpy( buffer, pn );
strcat( buffer, "/ac_prt.map" );
Q_strncpyz( buffer, pn, sizeof( buffer ) );
strncat( buffer, "/ac_prt.map", sizeof( buffer ) );
FILE* pFile = fopen( buffer, "w" );
// ahem, thx rr2

View file

@ -37,7 +37,7 @@ entity_s* FindEntityFromTargetname( const char* targetname, int* entNum );
char* UnixToDosPath( char* path );
char* GetFilename( char* buffer, const char* filename );
char* GetFilename( char* buffer, const char* filename, size_t length );
char* GetGameFilename( char* buffer, const char* filename );
float Determinant3x3( float a1, float a2, float a3,

View file

@ -317,9 +317,9 @@ static void RefreshEventList( void ){
for ( i = 0; i < GetCurrentCam()->GetCam()->numEvents(); i++ ) {
char rowbuf[3][128], *row[3];
// FIXME: sort by time?
sprintf( rowbuf[0], "%li", GetCurrentCam()->GetCam()->getEvent( i )->getTime() ); row[0] = rowbuf[0];
strncpy( rowbuf[1], GetCurrentCam()->GetCam()->getEvent( i )->typeStr(), sizeof( rowbuf[0] ) ); row[1] = rowbuf[1];
strncpy( rowbuf[2], GetCurrentCam()->GetCam()->getEvent( i )->getParam(), sizeof( rowbuf[1] ) ); row[2] = rowbuf[2];
snprintf( rowbuf[0], sizeof( rowbuf[0] ), "%li", GetCurrentCam()->GetCam()->getEvent( i )->getTime() ); row[0] = rowbuf[0];
Q_strncpyz( rowbuf[1], GetCurrentCam()->GetCam()->getEvent( i )->typeStr(), sizeof( rowbuf[0] ) ); row[1] = rowbuf[1];
Q_strncpyz( rowbuf[2], GetCurrentCam()->GetCam()->getEvent( i )->getParam(), sizeof( rowbuf[1] ) ); row[2] = rowbuf[2];
gtk_list_store_append( store, &iter );
gtk_list_store_set( store, &iter, EVENT_TEXT_COLUMN, row, EVENT_INDEX_COLUMN, i, -1 );

View file

@ -99,7 +99,7 @@ void DoLoadCamera(){
CAMERA_ExtractFilePath( firstCam->GetFileName(), basepath );
}
else{
strcpy( basepath, g_FuncTable.m_pfnGetGamePath() );
Q_strncpyz( basepath, g_FuncTable.m_pfnGetGamePath(), sizeof( basepath ) );
}
const gchar *filename = g_FuncTable.m_pfnFileDialog( (GtkWidget *)g_pRadiantWnd, TRUE, "Open Camera File", basepath, "camera", NULL );
@ -158,7 +158,7 @@ void DoSaveCamera() {
CAMERA_ExtractFilePath( GetCurrentCam()->GetFileName(), basepath );
}
else{
strcpy( basepath, g_FuncTable.m_pfnGetGamePath() );
Q_strncpyz( basepath, g_FuncTable.m_pfnGetGamePath(), sizeof( basepath ) );
}
const gchar *filename = g_FuncTable.m_pfnFileDialog( (void *)g_pRadiantWnd, FALSE, "Save Camera File", basepath, "camera", NULL );
@ -171,7 +171,7 @@ void DoSaveCamera() {
// File dialog from windows (and maybe the gtk one from radiant) doesn't handle default extensions properly.
// Add extension and check again if file exists
if ( strcmp( fullpathtofile + ( strlen( fullpathtofile ) - 7 ), ".camera" ) ) {
strcat( fullpathtofile, ".camera" );
strncat( fullpathtofile, ".camera", sizeof( fullpathtofile ) );
if ( FileExists( fullpathtofile ) ) {
if ( g_FuncTable.m_pfnMessageBox( (GtkWidget *)g_pRadiantWnd, "File already exists.\nOverwrite?", "Save Camera File", MB_YESNO, NULL ) == IDNO ) {

View file

@ -31,7 +31,7 @@ void Sys_ERROR( char* text, ... ){
char buf[32768];
va_start( argptr,text );
vsprintf( buf, text,argptr );
vsnprintf( buf, sizeof( buf ), text, argptr );
va_end( argptr );
Sys_Printf( "Camera::ERROR->%s", buf );
@ -114,7 +114,7 @@ void CDECL Com_Error( int level, const char *error, ... ){
char buf[32768];
va_start( argptr,error );
vsprintf( buf, error,argptr );
vsnprintf( buf, sizeof( buf ), error, argptr );
va_end( argptr );
Sys_Printf( "Camera::ERROR->%s", buf );
@ -125,7 +125,7 @@ void CDECL Com_Printf( const char* msg, ... ){
char buf[32768];
va_start( argptr,msg );
vsprintf( buf, msg,argptr );
vsnprintf( buf, sizeof( buf ), msg, argptr );
va_end( argptr );
Sys_Printf( "Camera::%s", buf );
@ -137,7 +137,7 @@ void CDECL Com_DPrintf( const char* msg, ... ){
char buf[32768];
va_start( argptr,msg );
vsprintf( buf, msg,argptr );
vsnprintf( buf, sizeof( buf ), msg, argptr );
va_end( argptr );
Sys_Printf( "Camera::%s", buf );

View file

@ -353,7 +353,7 @@ char *va( const char *format, ... ){
static char string[1024];
va_start( argptr, format );
vsprintf( string, format,argptr );
vsnprintf( string, sizeof( string ), format, argptr );
va_end( argptr );
return string;

View file

@ -199,7 +199,7 @@ void UpdateWadKeyPair( void ){
for ( pEpair = pEntity->epairs; pEpair != NULL; pEpair = pEpair->next )
{
if ( stricmp( pEpair->key,"wad" ) == 0 ) {
strcpy( wads,pEpair->value );
Q_strncpyz( wads, pEpair->value, sizeof( wads ) );
HYDRA_ConvertDOSToUnixName( wads,wads );
Sys_Printf( "HydraToolz: Current wad key is \"%s\"!\n",wads );
@ -295,18 +295,18 @@ void UpdateWadKeyPair( void ){
else
{
if ( wads[0] ) {
strcat( wads,";" );
strncat( wads, ";", sizeof( wads ) );
}
actualwad = vfsGetFullPath( (char *)wadlist->data, 0, 0 );
if ( actualwad ) {
strcat( wads, actualwad );
strncat( wads, actualwad, sizeof( wads ) );
}
else
{
Sys_Printf( "HydraToolz: WARNING: could not locate wad file %s\n",(char *)wadlist->data );
strcat( wads, (char *)wadlist->data );
strncat( wads, (char *)wadlist->data, sizeof( wads ) );
}
}

View file

@ -63,7 +63,7 @@ static void file_sel_callback( GtkWidget *widget, gpointer data ){
*loop = 0;
if ( (intptr_t)data == IDOK ) {
*filename = g_strdup( gtk_file_chooser_get_filename( GTK_FILE_CHOOSER( parent ) ) );
*filename = gtk_file_chooser_get_filename( GTK_FILE_CHOOSER( parent ) );
}
}
@ -85,10 +85,10 @@ static void change_clicked( GtkWidget *widget, gpointer data ){
chooser = GTK_FILE_CHOOSER( file_sel );
filename = gtk_file_chooser_get_filename( chooser );
strcpy( portals.fn, filename );
Q_strncpyz( portals.fn, filename, sizeof( portals.fn ) );
gtk_entry_set_text( GTK_ENTRY( data ), filename );
g_free (filename);
g_free( filename );
}
gtk_widget_destroy( file_sel );
@ -147,11 +147,11 @@ int DoLoadPortalFileDialog(){
gtk_widget_show( hbox );
char *fn = g_FuncTable.m_pfnGetMapName();
strcpy( portals.fn, fn );
Q_strncpyz( portals.fn, fn, sizeof( portals.fn ) );
fn = strrchr( portals.fn, '.' );
if ( fn != NULL ) {
*fn = '\0';
strcat( portals.fn, ".prt" );
strncat( portals.fn, ".prt", sizeof( portals.fn ) );
}
gtk_entry_set_text( GTK_ENTRY( entry ), portals.fn );

View file

@ -67,15 +67,15 @@ void InitInstance(){
_splitpath( fn, fn_drive, fn_dir, fn_name, fn_ext );
strcpy( INIfn, fn_drive );
strcat( INIfn, fn_dir );
strcat( INIfn, fn_name );
strcat( INIfn, ".ini" );
Q_strncpyz( INIfn, fn_drive, sizeof( INIfn ) );
strncat( INIfn, fn_dir, sizeof( INIfn ) );
strncat( INIfn, fn_name, sizeof( INIfn ) );
strncat( INIfn, ".ini", sizeof( INIfn ) );
#else // if def __linux__
strcpy( INIfn, g_get_home_dir() );
strcat( INIfn, "/.radiant/" );
strcat( INIfn, RADIANT_VERSION );
strcat( INIfn, "/prtview.ini" );
Q_strncpyz( INIfn, g_get_home_dir(), sizeof( INIfn ) );
strncat( INIfn, "/.radiant/", sizeof( INIfn ) );
strncat( INIfn, RADIANT_VERSION, sizeof( INIfn ) );
strncat( INIfn, "/prtview.ini", sizeof( INIfn ) );
#endif
portals.show_2d = INIGetInt( RENDER_2D, FALSE ) ? true : false;
@ -183,7 +183,7 @@ _QERQglTable g_QglTable;
#if defined( __linux__ ) || defined( __APPLE__ )
static bool read_var( const char *filename, const char *section, const char *key, char *value ){
static bool read_var( const char *filename, const char *section, const char *key, char *value, size_t length ){
char line[1024], *ptr;
FILE *rc;
@ -216,7 +216,7 @@ static bool read_var( const char *filename, const char *section, const char *key
*ptr = '\0';
if ( strcmp( line, key ) == 0 ) {
strcpy( value, ptr + 1 );
Q_strncpyz( value, ptr + 1, length );
fclose( rc );
while ( value[strlen( value ) - 1] == 10 ||
@ -334,7 +334,7 @@ int INIGetInt( const char *key, int def ){
#if defined( __linux__ ) || defined( __APPLE__ )
char value[1024];
if ( read_var( INIfn, CONFIG_SECTION, key, value ) ) {
if ( read_var( INIfn, CONFIG_SECTION, key, value, sizeof( value ) ) ) {
return atoi( value );
}
else{
@ -404,7 +404,7 @@ extern "C" const char* QERPlug_GetCommandList(){
char buf[32768];
va_start (argptr,text);
vsprintf (buf, text, argptr);
vsnprintf (buf, sizeof( buf ), text, argptr);
va_end (argptr);
g_FuncTable.m_pfnSysMsg (buf);

View file

@ -33,6 +33,12 @@
#include <stdio.h>
#include <string.h>
#if defined(_MSC_VER) && _MSC_VER<1900 && !(defined snprintf)
#define snprintf _snprintf
#endif
#ifndef Q_strncpyz
#define Q_strncpyz(_dst, _source, _len) do { strncpy((_dst), (_source), (_len) - 1); (_dst)[(_len) - 1] = 0; } while( 0 )
#endif
// TTimo
// ideally the plugin API would be UI toolkit independent, but removing the dependency with GLib seems tricky right now..
#include <glib.h>

View file

@ -54,14 +54,21 @@ void *safe_malloc( size_t size );
void *safe_malloc_info( size_t size, char* info );
#endif
void DefaultExtension( char *path, char *extension );
void DefaultPath( char *path, char *basepath );
#if defined(_MSC_VER) && _MSC_VER<1900 && !(defined snprintf)
#define snprintf _snprintf
#endif
#ifndef Q_strncpyz
#define Q_strncpyz(_dst, _source, _len) do { strncpy((_dst), (_source), (_len) - 1); (_dst)[(_len) - 1] = 0; } while( 0 )
#endif
void DefaultExtension( char *path, char *extension, size_t length );
void DefaultPath( char *path, const char *basepath, size_t length );
void StripFilename( char *path );
void StripExtension( char *path );
void ExtractFilePath( const char *path, char *dest );
void ExtractFileName( const char *path, char *dest );
void ExtractFileBase( const char *path, char *dest );
void ExtractFileExtension( const char *path, char *dest );
void ExtractFileExtension( const char *path, char *dest, size_t length );
/*!
\brief create all directories leading to a file path. if you pass a directory, terminate it with a '/'
*/

View file

@ -51,14 +51,14 @@ bool Q_Exec( const char *cmd, char *cmdline, const char *execdir, bool bCreateCo
case 0:
// always concat the command on linux
if ( cmd ) {
strcpy( fullcmd, cmd );
Q_strncpyz( fullcmd, cmd, sizeof( fullcmd ) );
}
else{
fullcmd[0] = '\0';
}
if ( cmdline ) {
strcat( fullcmd, " " );
strcat( fullcmd, cmdline );
strncat( fullcmd, " ", sizeof( fullcmd ) );
strncat( fullcmd, cmdline, sizeof( fullcmd ) );
}
pCmd = fullcmd;
while ( *pCmd == ' ' )
@ -159,7 +159,7 @@ int Q_filelength( FILE *f ){
return end;
}
void DefaultExtension( char *path, char *extension ){
void DefaultExtension( char *path, char *extension, size_t length ){
char *src;
//
// if path doesn't have a .EXT, append extension
@ -175,18 +175,18 @@ void DefaultExtension( char *path, char *extension ){
src--;
}
strcat( path, extension );
strncat( path, extension, length );
}
void DefaultPath( char *path, char *basepath ){
char temp[128];
void DefaultPath( char *path, const char *basepath, size_t length ){
char temp[PATH_MAX];
if ( path[0] == PATHSEPERATOR ) {
return; // absolute path location
}
strcpy( temp,path );
strcpy( path,basepath );
strcat( path,temp );
Q_strncpyz( temp, path, sizeof( temp ) );
Q_strncpyz( path, basepath, length );
strncat( path, temp, length );
}
@ -285,7 +285,7 @@ void ExtractFileBase( const char *path, char *dest ){
dest[length] = '\0';
}
void ExtractFileExtension( const char *path, char *dest ){
void ExtractFileExtension( const char *path, char *dest, size_t length ){
const char *src;
src = path + strlen( path ) - 1;
@ -300,7 +300,7 @@ void ExtractFileExtension( const char *path, char *dest ){
return;
}
strcpy( dest,src );
Q_strncpyz( dest, src, length );
}

View file

@ -48,7 +48,7 @@ void WinPrint( char *str, ... ){
char text[4096];
va_start( argptr,str );
vsprintf( text, str, argptr );
vsnprintf( text, sizeof( text ), str, argptr );
va_end( argptr );
printf("%s", text );

View file

@ -395,7 +395,8 @@ int lwResolvePolySurfaces( lwPolygonList *polygon, lwTagList *tlist,
if ( !s[ index ]->name ) {
return 0;
}
strcpy( s[ index ]->name, tlist->tag[ index ] );
strncpy( s[ index ]->name, tlist->tag[ index ], sizeof( s[ index ]->name ) - 1 );
s[ index ]->name[sizeof( s[ index ]->name ) - 1] = 0;
lwListAdd( (void **) surf, s[ index ] );
*nsurfs = *nsurfs + 1;
}

View file

@ -263,7 +263,7 @@ void _pico_printf( int level, const char *format, ... ){
/* format string */
va_start( argptr,format );
vsprintf( str,format,argptr );
vsnprintf( str, sizeof( str ), format, argptr );
va_end( argptr );
/* remove linefeeds */
@ -629,7 +629,7 @@ char *_pico_nopath( const char *path ){
* or filepath's filename portion. the given 'path' *is*
* altered. leave 'ext' empty to remove extension. -sea
*/
char *_pico_setfext( char *path, const char *ext ){
char *_pico_setfext( char *path, const char *ext, size_t length ){
char *src;
int remfext = 0;
@ -660,7 +660,7 @@ char *_pico_setfext( char *path, const char *ext ){
break;
}
}
strcat( path,ext );
strncat( path, ext, length );
return path;
}

View file

@ -132,7 +132,7 @@ char *_pico_stristr( char *str, const char *substr );
void _pico_unixify( char *path );
int _pico_nofname( const char *path, char *dest, int destSize );
char *_pico_nopath( const char *path );
char *_pico_setfext( char *path, const char *ext );
char *_pico_setfext( char *path, const char *ext, size_t length );
int _pico_getline( char *buf, int bufsize, char *dest, int destsize );
char *_pico_strlwr( char *str );

View file

@ -212,11 +212,13 @@ picoModel_t *PicoLoadModel( char *fileName, int frameNum ){
/* apply model remappings from <model>.remap */
if ( strlen( modelFileName ) ) {
/* alloc copy of model file name */
remapFileName = _pico_alloc( strlen( modelFileName ) + 20 );
size_t length = strlen( modelFileName ) + 20;
remapFileName = _pico_alloc( length );
if ( remapFileName != NULL ) {
/* copy model file name and change extension */
strcpy( remapFileName, modelFileName );
_pico_setfext( remapFileName, "remap" );
strncpy( remapFileName, modelFileName, length );
remapFileName[length - 1] = 0;
_pico_setfext( remapFileName, "remap", length );
/* try to remap model; we don't handle the result */
PicoRemapModel( model, remapFileName );

View file

@ -421,18 +421,21 @@ static int GetMeshShader( T3dsLoaderPers *pers ){
char *name;
/* copy map name to local buffer */
strcpy( mapName,mapNamePtr );
strncpy( mapName, mapNamePtr, sizeof( mapName ) - 1 );
mapName[sizeof( mapName ) - 1] = 0;
/* extract file name */
name = _pico_nopath( mapName );
strncpy( temp, name, sizeof( temp ) );
strncpy( temp, name, sizeof( temp ) - 1 );
temp[sizeof( temp ) - 1] = 0;
/* remove file extension */
/* name = _pico_setfext( name,"" ); */
/* assign default name if no name available */
if ( strlen( temp ) < 1 ) {
strcpy( temp,pers->basename );
strncpy( temp, pers->basename, sizeof( temp ) - 1 );
temp[sizeof( temp ) - 1] = 0;
}
/* build shader name */
@ -730,9 +733,9 @@ static picoModel_t *_3ds_load( PM_PARAMS_LOAD ){
return NULL;
}
/* get model's base name (eg. jeep from c:\models\jeep.3ds) */
memset( basename,0,sizeof( basename ) );
strncpy( basename,_pico_nopath( fileName ),sizeof( basename ) );
_pico_setfext( basename,"" );
strncpy( basename, _pico_nopath( fileName ), sizeof( basename ) - 1 );
basename[sizeof( basename ) - 1] = 0;
_pico_setfext( basename, "", sizeof( basename ) );
/* initialize persistant vars (formerly static) */
pers.model = model;

View file

@ -400,7 +400,7 @@ static picoModel_t *_ase_load( PM_PARAMS_LOAD ){
continue;
}
/* remember node name */
if ( !_pico_stricmp( p->token,"*node_name" ) ) {
if ( !_pico_stricmp( p->token, "*node_name" ) ) {
/* read node name */
char *ptr = _pico_parse( p,0 );
if ( ptr == NULL ) {
@ -408,10 +408,11 @@ static picoModel_t *_ase_load( PM_PARAMS_LOAD ){
}
/* remember node name */
strncpy( lastNodeName,ptr,sizeof( lastNodeName ) );
strncpy( lastNodeName, ptr, sizeof( lastNodeName ) - 1 );
lastNodeName[sizeof( lastNodeName ) - 1] = 0;
}
/* model mesh (originally contained within geomobject) */
else if ( !_pico_stricmp( p->token,"*mesh" ) ) {
else if ( !_pico_stricmp( p->token, "*mesh" ) ) {
/* finish existing surface */
//_ase_make_surface( model, &surface );
_ase_submit_triangles( surface, model,materials,faces );
@ -796,12 +797,13 @@ static picoModel_t *_ase_load( PM_PARAMS_LOAD ){
}
/* parse material name */
else if ( !_pico_stricmp( p->token,"*material_name" ) ) {
char* name = _pico_parse( p,0 );
char* name = _pico_parse( p, 0 );
if ( name == NULL ) {
_ase_error_return( "Missing material name" );
}
strcpy( materialName, name );
strncpy( materialName, name, sizeof( materialName ) - 1 );
materialName[sizeof( materialName ) - 1] = 0;
/* skip rest and continue with next token */
_pico_parse_skip_rest( p );
continue;

View file

@ -350,7 +350,8 @@ static picoModel_t *_fm_load( PM_PARAMS_LOAD ){
texCoord->t = _pico_little_short( texCoord[i].t );
}
// set Skin Name
strncpy( skinname, (char *) fm.fm_skin, FM_SKINPATHSIZE );
strncpy( skinname, (char *) fm.fm_skin, FM_SKINPATHSIZE - 1 );
skinname[FM_SKINPATHSIZE - 1] = 0;
#ifdef FM_VERBOSE_DBG
// Print out md2 values
@ -358,7 +359,7 @@ static picoModel_t *_fm_load( PM_PARAMS_LOAD ){
#endif
// detox Skin name
_pico_setfext( skinname, "" );
_pico_setfext( skinname, "", sizeof( skinname ) );
_pico_unixify( skinname );
/* create new pico model */

View file

@ -234,8 +234,9 @@ static picoModel_t *_lwo_load( PM_PARAMS_LOAD ){
}
/* detox and set shader name */
strncpy( name, surface->name, sizeof( name ) );
_pico_setfext( name, "" );
strncpy( name, surface->name, sizeof( name ) - 1 );
name[sizeof( name ) - 1] = 0;
_pico_setfext( name, "", sizeof( name ) );
_pico_unixify( name );
PicoSetShaderName( picoShader, name );

View file

@ -431,7 +431,8 @@ static picoModel_t *_md2_load( PM_PARAMS_LOAD ){
}
// set Skin Name
strncpy( skinname, (char *) ( bb + md2->ofsSkins ), MD2_MAX_SKINNAME );
strncpy( skinname, (char *) ( bb + md2->ofsSkins ), MD2_MAX_SKINNAME - 1 );
skinname[MD2_MAX_SKINNAME - 1] = 0;
// Print out md2 values
_pico_printf( PICO_VERBOSE,"Skins: %d Verts: %d STs: %d Triangles: %d Frames: %d\nSkin Name \"%s\"\n", md2->numSkins, md2->numXYZ, md2->numST, md2->numTris, md2->numFrames, skinname );
@ -439,7 +440,8 @@ static picoModel_t *_md2_load( PM_PARAMS_LOAD ){
// relative texture path - allows moving of models in game dir structure without changing the skinpath
// e.g. used in ufo:ai
if ( skinname[0] == '.' ) {
strncpy( path, fileName, MD2_MAX_SKINNAME );
strncpy( path, fileName, MD2_MAX_SKINNAME - 1 );
path[MD2_MAX_SKINNAME - 1] = 0;
for ( i = MD2_MAX_SKINNAME; i--; ) {
// skip filename
if ( path[i] == '/' || path[i] == '\\' ) {
@ -448,14 +450,15 @@ static picoModel_t *_md2_load( PM_PARAMS_LOAD ){
path[i] = '\0';
}
strncat( path, &skinname[1], MD2_MAX_SKINNAME );
strncpy( skinname, path, MD2_MAX_SKINNAME );
strncpy( skinname, path, MD2_MAX_SKINNAME - 1 );
skinname[MD2_MAX_SKINNAME - 1] = 0;
// Print out md2 values
_pico_printf( PICO_VERBOSE,"Relative skin path converted to: \"%s\" (%s)\n", skinname, fileName );
}
// detox Skin name
_pico_setfext( skinname, "" );
_pico_setfext( skinname, "", sizeof( skinname ) );
_pico_unixify( skinname );
/* create new pico model */

View file

@ -344,7 +344,7 @@ static picoModel_t *_md3_load( PM_PARAMS_LOAD ){
/* detox and set shader name */
shader = (md3Shader_t*) ( (picoByte_t*) surface + surface->ofsShaders );
_pico_setfext( shader->name, "" );
_pico_setfext( shader->name, "", sizeof( shader->name ) );
_pico_unixify( shader->name );
PicoSetShaderName( picoShader, shader->name );

View file

@ -644,7 +644,7 @@ static picoModel_t *_mdc_load( PM_PARAMS_LOAD ){
/* detox and set shader name */
shader = (mdcShader_t*) ( (picoByte_t*) surface + surface->ofsShaders );
_pico_setfext( shader->name, "" );
_pico_setfext( shader->name, "", sizeof( shader->name ) );
_pico_unixify( shader->name );
PicoSetShaderName( picoShader, shader->name );

View file

@ -641,7 +641,7 @@ static picoModel_t *_obj_load( PM_PARAMS_LOAD ){
/* some obj exporters feel like they don't need to */
/* supply a group name. so we gotta handle it here */
#if 1
strcpy( p->token,"default" );
strcpy( p->token, "default" );
groupName = p->token;
#else
_obj_error_return( "Invalid or missing group name" );

View file

@ -100,7 +100,7 @@ void Com_ScriptError( const char *msg, ... ) {
char string[32000];
va_start( argptr, msg );
vsprintf( string, msg,argptr );
vsnprintf( string, sizeof( string ), msg, argptr );
va_end( argptr );
Com_Error( ERR_DROP, "File %s, line %i: %s", pi->parseFile, pi->lines, string );
@ -111,7 +111,7 @@ void Com_ScriptWarning( const char *msg, ... ) {
char string[32000];
va_start( argptr, msg );
vsprintf( string, msg,argptr );
vsnprintf( string, sizeof( string ), msg, argptr );
va_end( argptr );
Com_Printf( "File %s, line %i: %s", pi->parseFile, pi->lines, string );

View file

@ -472,7 +472,7 @@ int Com_ParseInfos( const char *buf, int max, char infos[][MAX_INFO_STRING] ) {
if ( !token[0] ) {
token = "<NULL>";
}
Info_SetValueForKey( infos[count], key, token );
Info_SetValueForKey( infos[count], key, token, sizeof( infos[count] ) );
}
count++;
}
@ -695,7 +695,7 @@ void QDECL Com_sprintf( char *dest, int size, const char *fmt, ... ) {
char bigbuffer[32000]; // big, but small enough to fit in PPC stack
va_start( argptr,fmt );
len = vsprintf( bigbuffer,fmt,argptr );
len = vsnprintf( bigbuffer, sizeof( bigbuffer ), fmt, argptr );
va_end( argptr );
if ( len < 0 ) {
Com_Error( ERR_FATAL, "Com_sprintf: failed to write bigbuffer" );
@ -729,7 +729,7 @@ char * QDECL va( const char *format, ... ) {
index++;
va_start( argptr, format );
vsprintf( buf, format,argptr );
vsnprintf( buf, sizeof( string[index & 1] ), format, argptr );
va_end( argptr );
return buf;
@ -932,7 +932,7 @@ qboolean Info_Validate( const char *s ) {
Changes or adds a key/value pair
==================
*/
void Info_SetValueForKey( char *s, const char *key, const char *value ) {
void Info_SetValueForKey( char *s, const char *key, const char *value, size_t length ) {
char newi[MAX_INFO_STRING];
if ( strlen( s ) >= MAX_INFO_STRING ) {
@ -966,7 +966,7 @@ void Info_SetValueForKey( char *s, const char *key, const char *value ) {
return;
}
strcat( s, newi );
Q_strcat( s, length, newi );
}
//====================================================================

View file

@ -771,7 +771,7 @@ int Com_IndexForGrowListElement( const growList_t *list, const void *ele
//
char *Info_ValueForKey( const char *s, const char *key );
void Info_RemoveKey( char *s, const char *key );
void Info_SetValueForKey( char *s, const char *key, const char *value );
void Info_SetValueForKey( char *s, const char *key, const char *value, size_t length );
qboolean Info_Validate( const char *s );
void Info_NextPair( const char *( *s ), char key[MAX_INFO_KEY], char value[MAX_INFO_VALUE] );

View file

@ -553,8 +553,8 @@ bool idCameraDef::getCameraInfo( long time, idVec3 &origin, idVec3 &direction, f
//}
}
else if ( events[i]->getType() == idCameraEvent::EVENT_FOV ) {
memset( buff, 0, sizeof( buff ) );
strcpy( buff, events[i]->getParam() );
strncpy( buff, events[i]->getParam(), sizeof( buff ) - 1 );
buff[sizeof( buff ) - 1] = 0;
const char *param1 = strtok( buff, " \t,\0" );
const char *param2 = strtok( NULL, " \t,\0" );
float len = ( param2 ) ? atof( param2 ) : 0;
@ -574,7 +574,8 @@ bool idCameraDef::getCameraInfo( long time, idVec3 &origin, idVec3 &direction, f
}
else if ( events[i]->getType() == idCameraEvent::EVENT_CAMERA ) {
memset( buff, 0, sizeof( buff ) );
strcpy( buff, events[i]->getParam() );
strncpy( buff, events[i]->getParam(), sizeof( buff ) - 1 );
buff[sizeof( buff ) - 1] = 0;
const char *param1 = strtok( buff, " \t,\0" );
const char *param2 = strtok( NULL, " \t,\0" );

View file

@ -371,6 +371,7 @@ void idStr::EnsureDataWritable
EnsureAlloced( len + 1, false );
strncpy( m_data->data, olddata->data, len + 1 );
m_data->data[len] = 0;
m_data->len = len;
olddata->DelRef();
@ -447,12 +448,13 @@ void idStr::snprintf
va_list argptr;
va_start( argptr,fmt );
len = vsprintf( buffer,fmt,argptr );
len = vsnprintf( buffer, sizeof( buffer ), fmt, argptr );
va_end( argptr );
assert( len < size );
strncpy( dst, buffer, size - 1 );
dst[size - 1] = NULL;
}
#ifdef _WIN32

View file

@ -52,6 +52,15 @@
#define strcasecmp strcmpi
#endif
#if defined(_MSC_VER) && _MSC_VER<1900 && !(defined snprintf)
#define snprintf _snprintf
#endif
#ifndef Q_strncpyz
#define Q_strncpyz(_dst, _source, _len) do { strncpy((_dst), (_source), (_len) - 1); (_dst)[(_len) - 1] = 0; } while( 0 )
#endif
// NOTE TTimo __StrDup was initially implemented in pakstuff.cpp
// causing a bunch of issues for broader targets that use Str.h (such as plugins and modules)
// Q_StrDup should be used now, using a #define __StrDup for easy transition

View file

@ -857,9 +857,9 @@ bool CSynapseClient::AddAPI( const char *major, const char *minor, int size, EAP
}
APIDescriptor_t *pAPI = new APIDescriptor_t;
memset( pAPI, 0, sizeof( APIDescriptor_t ) );
strncpy( pAPI->major_name, major, MAX_APINAME );
Q_strncpyz( pAPI->major_name, major, sizeof( pAPI->major_name ) );
if ( minor ) {
strncpy( pAPI->minor_name, minor, MAX_APINAME );
Q_strncpyz( pAPI->minor_name, minor, sizeof( pAPI->minor_name ) );
}
pAPI->mType = type;
pAPI->mpTable = pTable;
@ -1020,8 +1020,8 @@ void CSynapseAPIManager::SetMatchAPI( const char *major, const char *minor ){
Syn_Printf( "ERROR: MAX_TOKEN_STRING exceeded in CSynapseAPIManager::SetMatchAPI: '%s'\n", minor );
return;
}
strcpy( major_pattern, major );
strcpy( minor_pattern, minor );
Q_strncpyz( major_pattern, major, sizeof( major_pattern ) );
Q_strncpyz( minor_pattern, minor, sizeof( minor_pattern ) );
if ( strcmp( minor, "*" ) ) {
mType = API_LIST;
}
@ -1071,15 +1071,16 @@ void CSynapseAPIManager::InitializeAPIList(){
return;
}
strncpy( minor_tok, minor_pattern, MAX_PATTERN_STRING );
Q_strncpyz( minor_tok, minor_pattern, sizeof( minor_tok ) );
token = strtok( minor_tok, " " );
while ( token )
{
/* ask the child to build from scratch */
APIDescriptor_t *pAPI = new APIDescriptor_t;
memset( pAPI, 0, sizeof( APIDescriptor_t ) );
strncpy( pAPI->major_name, major_pattern, MAX_APINAME );
strncpy( pAPI->minor_name, token, MAX_APINAME );
Q_strncpyz( pAPI->major_name, major_pattern, sizeof( pAPI->major_name ) );
Q_strncpyz( pAPI->minor_name, token, sizeof( pAPI->minor_name ) );
pAPI->mType = SYN_REQUIRE_ANY;
FillAPITable( pAPI );
mAPIs.push_back( pAPI );

View file

@ -99,7 +99,7 @@
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<AdditionalIncludeDirectories>$(SolutionDir)\include;$(SolutionDir)\libs;$(SolutionDir)\..\GtkRadiant-libs\jpeg-9a;$(SolutionDir)\..\GtkRadiant-libs\glib-2.34.3\lib\glib-2.0\include;$(SolutionDir)\..\GtkRadiant-libs\glib-2.34.3\include\glib-2.0;$(SolutionDir)\..\GtkRadiant-libs\gtk-3.6.4\include\gtk-3.0;$(SolutionDir)\..\GtkRadiant-libs\pango-1.30.1\include\pango-1.0;$(SolutionDir)\..\GtkRadiant-libs\cairo-1.10.2\include\cairo;$(SolutionDir)\..\GtkRadiant-libs\gdk-pixbuf-2.26.5\include\gdk-pixbuf-2.0;$(SolutionDir)\..\GtkRadiant-libs\atk-2.6.0\include\atk-1.0;$(SolutionDir)\..\GtkRadiant-libs\STLport-5.2.1\stlport;$(SolutionDir)\..\GtkRadiant-libs\gtkglext-1.3\include;$(SolutionDir)\..\GtkRadiant-libs\libxml2-2.9.2\include;$(SolutionDir)\..\GtkRadiant-libs\lpng1618;$(SolutionDir)\..\GtkRadiant-libs\libiconv-1.14\woe32dll\libiconv;$(SolutionDir)\..\GtkRadiant-libs\gettext-0.19.5.1\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;NDEBUG;_LIB;_STLP_DONT_USE_EXCEPTIONS;_STLP_NO_NAMESPACES;_STLP_NO_IOSTREAMS;_WIN32;%(PreprocessorDefinitions);_STLP_DONT_USE_EXCEPTIONS;_STLP_NO_NAMESPACES;_STLP_NO_IOSTREAMS;_WIN32</PreprocessorDefinitions>
<PreprocessorDefinitions>WIN32;NDEBUG;_LIB;_STLP_DONT_USE_EXCEPTIONS;_STLP_NO_NAMESPACES;_STLP_NO_IOSTREAMS;_WIN32;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<PrecompiledHeader />
<WarningLevel>Level3</WarningLevel>

View file

@ -244,13 +244,13 @@ char *strlower( char *start ){
return start;
}
char *addstr( char *dest,const char *source ){
char *addstr( char *dest, const char *source ){
if ( dest ) {
char *ptr;
int len = strlen( dest );
ptr = (char *) malloc( len + strlen( source ) + 1 );
strcpy( ptr,dest );
strcpy( ptr + len,source );
strcpy( ptr, dest );
strcpy( ptr + len, source );
free( dest );
dest = ptr;
}
@ -382,8 +382,8 @@ void EClass_ImportFromClass( eclass_t *e, GSList *l_classes, class_t *bc ){
//represent the final values.
if ( bc->description ) {
sprintf( newcomments,"%s\n",bc->description );
e->comments = addstr( e->comments,newcomments );
snprintf( newcomments, sizeof( newcomments ), "%s\n", bc->description );
e->comments = addstr( e->comments, newcomments );
newcomments[0] = 0; // so we don't add them twice.
}
@ -420,8 +420,8 @@ void EClass_ImportFromClass( eclass_t *e, GSList *l_classes, class_t *bc ){
// SIZE
if ( bc->gotsize ) {
e->fixedsize = true;
memcpy( e->mins,bc->boundingbox[0],sizeof( vec3_t ) );
memcpy( e->maxs,bc->boundingbox[1],sizeof( vec3_t ) );
memcpy( e->mins, bc->boundingbox[0], sizeof( vec3_t ) );
memcpy( e->maxs, bc->boundingbox[1], sizeof( vec3_t ) );
}
/*
// Hydra: apparently, this would be bad.
@ -449,7 +449,7 @@ void EClass_ImportFromClass( eclass_t *e, GSList *l_classes, class_t *bc ){
// COLOR
if ( bc->gotcolor ) {
memcpy( e->color,bc->color,sizeof( vec3_t ) );
memcpy( e->color, bc->color, sizeof( vec3_t ) );
sprintf( color, "(%f %f %f)", e->color[0], e->color[1], e->color[2] );
e->texdef.SetName( color );
}
@ -463,18 +463,22 @@ void EClass_ImportFromClass( eclass_t *e, GSList *l_classes, class_t *bc ){
if ( opt->optiontype != OPTION_FLAGS ) {
// add some info to the comments.
if ( opt->optioninfo ) {
sprintf( newcomments + strlen( newcomments ),"%s '%s' %s%s\n",
opt->epairname,
opt->optioninfo ? opt->optioninfo : "",
opt->optiondefault ? ", Default: " : "",
opt->optiondefault ? opt->optiondefault : "" );
snprintf( newcomments + strlen( newcomments ),
sizeof( newcomments ) - strlen( newcomments ),
"%s '%s' %s%s\n",
opt->epairname,
opt->optioninfo ? opt->optioninfo : "",
opt->optiondefault ? ", Default: " : "",
opt->optiondefault ? opt->optiondefault : "" );
}
else
{
sprintf( newcomments + strlen( newcomments ),"%s %s%s\n",
opt->epairname,
opt->optiondefault ? ", Default: " : "",
opt->optiondefault ? opt->optiondefault : "" );
snprintf( newcomments + strlen( newcomments ),
sizeof( newcomments ) - strlen( newcomments ),
"%s %s%s\n",
opt->epairname,
opt->optiondefault ? ", Default: " : "",
opt->optiondefault ? opt->optiondefault : "" );
}
}
@ -490,7 +494,7 @@ void EClass_ImportFromClass( eclass_t *e, GSList *l_classes, class_t *bc ){
int index = getindex( choice->value );
index--;
if ( index < MAX_FLAGS ) {
strcpy( e->flagnames[index],choice->name );
Q_strncpyz( e->flagnames[index], choice->name, sizeof( e->flagnames[index] ) );
}
else
{
@ -499,11 +503,14 @@ void EClass_ImportFromClass( eclass_t *e, GSList *l_classes, class_t *bc ){
}
break;
case OPTION_CHOICES:
strcat( newcomments," Choices:\n" );
strncat( newcomments, " Choices:\n", sizeof( newcomments ) );
for ( choicelst = opt->choices; choicelst != NULL; choicelst = choicelst->next )
{
choice_t *choice = (choice_t*) choicelst->data;
sprintf( newcomments + strlen( newcomments )," %5d - %s\n",choice->value,choice->name );
snprintf( newcomments + strlen( newcomments ),
sizeof( newcomments ) - strlen( newcomments ),
" %5d - %s\n",
choice->value,choice->name );
}
break;
}
@ -547,7 +554,7 @@ void EClass_ImportFromClass( eclass_t *e, GSList *l_classes, class_t *bc ){
// COMMENTS
if ( newcomments[0] ) {
e->comments = addstr( e->comments,newcomments );
e->comments = addstr( e->comments, newcomments );
}
}
@ -649,7 +656,7 @@ void Eclass_ScanFile( char *filename ){
}
} while ( token[0] != '@' );
strcpy( temp,token + 1 ); // skip the @
Q_strncpyz( temp, token + 1, sizeof( temp ) );// skip the @
classtype = CLASS_NOCLASS;
if ( !stricmp( temp,"BaseClass" ) ) {
@ -669,37 +676,37 @@ void Eclass_ScanFile( char *filename ){
while ( 1 )
{
GetTokenExtra( false,"(",false ); // option or =
strcpy( token_debug,token );
GetTokenExtra( false, "(", false ); // option or =
Q_strncpyz( token_debug, token, sizeof( token_debug ) );
if ( !strcmp( token,"=" ) ) {
if ( !strcmp( token, "=" ) ) {
UnGetToken();
break;
}
else
{
strlower( token );
if ( !strcmp( token,"base" ) ) {
GetTokenExtra( false,"(",true ); // (
if ( !strcmp( token, "base" ) ) {
GetTokenExtra( false, "(", true ); // (
if ( !strcmp( token,"(" ) ) {
while ( GetTokenExtra( false,",)",false ) ) // option) or option,
if ( !strcmp( token, "(" ) ) {
while ( GetTokenExtra( false, ",)", false ) ) // option) or option,
{
newclass->l_baselist = g_slist_append( newclass->l_baselist, strdup( token ) );
GetTokenExtra( false,",)",true ); // , or )
if ( !strcmp( token,")" ) ) {
GetTokenExtra( false, ",)", true ); // , or )
if ( !strcmp( token, ")" ) ) {
break;
}
}
}
}
else if ( !strcmp( token,"size" ) ) {
else if ( !strcmp( token, "size" ) ) {
// parse (w h d) or (x y z, x y z)
GetTokenExtra( false,"(",true ); // (
if ( !strcmp( token,"(" ) ) {
GetTokenExtra( false, "(", true ); // (
if ( !strcmp( token, "(" ) ) {
int sizedone = false;
float w,h,d;
GetToken( false );
@ -707,7 +714,7 @@ void Eclass_ScanFile( char *filename ){
GetToken( false );
h = atof( token );
GetToken( false ); // number) or number ,
strcpy( temp,token );
Q_strncpyz( temp, token, sizeof( temp ) );
len = strlen( temp );
if ( temp[len - 1] == ')' ) {
sizedone = true;
@ -743,16 +750,16 @@ void Eclass_ScanFile( char *filename ){
GetToken(false); // )
newclass->boundingbox[1][2] = atof(temp);
*/
GetTokenExtra( false,")",false ); // number
GetTokenExtra( false, ")", false ); // number
newclass->boundingbox[1][2] = atof( token );
newclass->gotsize = true;
GetTokenExtra( false,")",true ); // )
GetTokenExtra( false, ")", true ); // )
}
}
}
else if ( !strcmp( token,"color" ) ) {
GetTokenExtra( false,"(",true ); // (
if ( !strcmp( token,"(" ) ) {
else if ( !strcmp( token, "color" ) ) {
GetTokenExtra( false, "(", true ); // (
if ( !strcmp( token, "(" ) ) {
// get the color values (0-255) and normalize them if required.
GetToken( false );
newclass->color[0] = atof( token );
@ -765,7 +772,7 @@ void Eclass_ScanFile( char *filename ){
newclass->color[1] /= 255;
}
GetToken( false );
strcpy( temp,token );
Q_strncpyz( temp, token, sizeof( temp ) );
len = strlen( temp );
if ( temp[len - 1] == ')' ) {
temp[len - 1] = 0;
@ -777,22 +784,22 @@ void Eclass_ScanFile( char *filename ){
newclass->gotcolor = true;
}
}
else if ( !strcmp( token,"iconsprite" ) ) {
GetTokenExtra( false,"(",true ); // (
if ( !strcmp( token,"(" ) ) {
GetTokenExtra( false,")",false ); // filename)
else if ( !strcmp( token, "iconsprite" ) ) {
GetTokenExtra( false, "(", true ); // (
if ( !strcmp( token, "(" ) ) {
GetTokenExtra( false, ")", false ); // filename)
// the model plugins will handle sprites too.
// newclass->sprite = strdup(token);
newclass->model = strdup( token );
GetTokenExtra( false,")",true ); // )
GetTokenExtra( false, ")", true ); // )
}
}
else if ( !strcmp( token,"model" ) ) {
GetTokenExtra( false,"(",true ); // (
if ( !strcmp( token,"(" ) ) {
GetTokenExtra( false,")",false ); // filename)
else if ( !strcmp( token, "model" ) ) {
GetTokenExtra( false, "(", true ); // (
if ( !strcmp( token, "(" ) ) {
GetTokenExtra( false, ")", false ); // filename)
newclass->model = strdup( token );
GetTokenExtra( false,")",true ); // )
GetTokenExtra( false, ")", true ); // )
}
}
else
@ -805,8 +812,8 @@ void Eclass_ScanFile( char *filename ){
}
GetToken( false ); // =
strcpy( token_debug,token );
if ( !strcmp( token,"=" ) ) {
Q_strncpyz( token_debug, token, sizeof( token_debug ) );
if ( !strcmp( token, "=" ) ) {
GetToken( false );
newclass->classname = strdup( token );
}
@ -814,7 +821,7 @@ void Eclass_ScanFile( char *filename ){
// Get the description
if ( newclass->classtype != CLASS_BASECLASS ) {
GetToken( false );
if ( !strcmp( token,":" ) ) {
if ( !strcmp( token, ":" ) ) {
GetToken( false );
newclass->description = strdup( token );
}
@ -840,7 +847,8 @@ void Eclass_ScanFile( char *filename ){
}
// parse the data and build the option_t
strcpy( temp,token );
Q_strncpyz( temp, token, sizeof( temp ) );
len = strlen( temp );
char *ptr = strchr( temp,'(' );
@ -884,7 +892,7 @@ void Eclass_ScanFile( char *filename ){
break;
}
GetToken( false ); // :
strcpy( token_debug,token );
Q_strncpyz( token_debug, token, sizeof( token_debug ) );
if ( ( token[0] == ':' ) && ( strlen( token ) > 1 ) ) {
newoption->optioninfo = strdup( token + 1 );
}
@ -909,18 +917,18 @@ void Eclass_ScanFile( char *filename ){
break;
case OPTION_CHOICES:
GetTokenExtra( false,":",true ); // : or :"something like this" (bah!)
strcpy( token_debug,token );
GetTokenExtra( false, ":", true ); // : or :"something like this" (bah!)
Q_strncpyz( token_debug, token, sizeof( token_debug ) );
if ( ( token[0] == ':' ) && ( strlen( token ) > 1 ) ) {
if ( token[1] == '\"' ) {
strcpy( temp,token + 2 );
Q_strncpyz( temp, token + 2, sizeof( temp ) );
while ( 1 )
{
if ( !GetToken( false ) ) {
break;
}
strcat( temp," " );
strcat( temp,token );
strncat( temp, " ", sizeof( temp ) );
strncat( temp, token, sizeof( temp ) );
len = strlen( temp );
if ( temp[len - 1] == '\"' ) {
temp[len - 1] = 0;
@ -936,7 +944,7 @@ void Eclass_ScanFile( char *filename ){
newoption->optioninfo = strdup( token );
}
GetToken( false ); // : or =
strcpy( token_debug,token );
Q_strncpyz( token_debug, token, sizeof( token_debug ) );
if ( !strcmp( token,":" ) ) {
GetToken( false );
newoption->optiondefault = strdup( token );
@ -948,13 +956,13 @@ void Eclass_ScanFile( char *filename ){
// And Follow on...
case OPTION_FLAGS:
GetToken( false ); // : or =
strcpy( token_debug,token );
Q_strncpyz( token_debug, token, sizeof( token_debug ) );
if ( strcmp( token,"=" ) ) { // missing ?
break;
}
GetToken( true ); // [
strcpy( token_debug,token );
Q_strncpyz( token_debug, token, sizeof( token_debug ) );
if ( strcmp( token,"[" ) ) { // missing ?
break;
}
@ -962,13 +970,13 @@ void Eclass_ScanFile( char *filename ){
choice_t *newchoice;
while ( 1 )
{
GetTokenExtra( true,":",true ); // "]" or "number", or "number:"
strcpy( token_debug,token );
if ( !strcmp( token,"]" ) ) { // no more ?
GetTokenExtra( true, ":", true ); // "]" or "number", or "number:"
Q_strncpyz( token_debug, token, sizeof( token_debug ) );
if ( !strcmp( token, "]" ) ) { // no more ?
optioncomplete = true;
break;
}
strcpy( temp,token );
Q_strncpyz( temp, token, sizeof( temp ) );
len = strlen( temp );
if ( temp[len - 1] == ':' ) {
temp[len - 1] = 0;
@ -976,7 +984,7 @@ void Eclass_ScanFile( char *filename ){
else
{
GetToken( false ); // :
if ( strcmp( token,":" ) ) { // missing ?
if ( strcmp( token, ":" ) ) { // missing ?
break;
}
}

View file

@ -35,17 +35,17 @@ void LoadM8( const char *name, unsigned char **pic, int *width, int *height ){
unsigned char *palette_ent, *buf_temp;
unsigned char *buffer, *m8_file_buffer;
strcpy( text_buf, name );
Q_strncpyz( text_buf, name, sizeof( text_buf ) );
text_dot_pos = strchr( text_buf, '.' );
if ( text_dot_pos ) {
*text_dot_pos = 0;
}
// Fix for .pcx.m8 extention
strcat( text_buf, ".pcx.m8" );
strncat( text_buf, ".pcx.m8", sizeof( text_buf ) );
// open file
if ( ( length = vfsLoadFile( (char *) text_buf, (void **) &m8_file_buffer, 0 ) ) == (unsigned int) -1 ) {
strcpy( text_buf, name );
Q_strncpyz( text_buf, name, sizeof( text_buf ) );
for ( i = ( strlen( text_buf ) - 1 ); i > 0; i-- )
{
if ( text_buf[i] == '.' ) {
@ -53,7 +53,7 @@ void LoadM8( const char *name, unsigned char **pic, int *width, int *height ){
break;
}
}
strcat( text_buf, ".m8" );
strncat( text_buf, ".m8", sizeof( text_buf ) );
if ( ( length = vfsLoadFile( (char *) text_buf, (void **) &m8_file_buffer, 0 ) ) == (unsigned int) -1 ) {
Sys_Printf( "Unable to open file %s\n",name );
return;

View file

@ -218,7 +218,7 @@ void HandleXMLError( void* ctxt, const char* text, ... ){
static char buf[32768];
va_start( argptr,text );
vsprintf( buf, text, argptr );
vsnprintf( buf, sizeof( buf ), text, argptr );
Sys_FPrintf( SYS_ERR, "XML %s\n", buf );
va_end( argptr );
}

View file

@ -178,15 +178,15 @@ extern "C" void QERPlug_Dispatch( const char *p, vec3_t vMin, vec3_t vMax, bool
else if ( !strcmp( p, "About..." ) ) {
const picoModule_t** modules = PicoModuleList( NULL );
char about_buf[1024];
strncpy( about_buf, PLUGIN_ABOUT, sizeof( about_buf ) - 1 );
Q_strncpyz( about_buf, PLUGIN_ABOUT, sizeof( about_buf ) );
while ( *modules != NULL ) {
const picoModule_t* module = *modules++;
strncat( about_buf, module->displayName, sizeof( about_buf ) - 1 );
strncat( about_buf, " (", sizeof( about_buf ) - 1 );
strncat( about_buf, module->defaultExts[0], sizeof( about_buf ) - 1 );
strncat( about_buf, ")\n\t", sizeof( about_buf ) - 1 );
strncat( about_buf, module->copyright, sizeof( about_buf ) - 1 );
strncat( about_buf, "\n", sizeof( about_buf ) - 1 );
strncat( about_buf, module->displayName, sizeof( about_buf ) );
strncat( about_buf, " (", sizeof( about_buf ) );
strncat( about_buf, module->defaultExts[0], sizeof( about_buf ) );
strncat( about_buf, ")\n\t", sizeof( about_buf ) );
strncat( about_buf, module->copyright, sizeof( about_buf ) );
strncat( about_buf, "\n", sizeof( about_buf ) );
}
g_FuncTable.m_pfnMessageBox( NULL, about_buf, "About...", MB_OK, NULL );
}

View file

@ -164,7 +164,7 @@ void add_remap( const char *remap ){
else {
pRemap = new remap_t;
strncpy( pRemap->m_remapbuff, remap, sizeof( pRemap->m_remapbuff ) );
Q_strncpyz( pRemap->m_remapbuff, remap, sizeof( pRemap->m_remapbuff ) );
pRemap->m_remapbuff[ch - remap] = '\0';

View file

@ -658,7 +658,7 @@ IShader *WINAPI QERApp_CreateShader_ForTextureName( const char *name ){
// Hydra: display an error message, so the user can quickly find a list of missing
// textures by looking at the console.
if ( !pShader->Activate() ) {
Sys_Printf( "WARNING: Activate shader failed for %s\n",pShader->getName() );
Sys_Printf( "WARNING: Activate shader failed for %s\n", pShader->getName() );
}
pShader->SetDisplayed( true );

View file

@ -116,7 +116,7 @@
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<AdditionalIncludeDirectories>$(SolutionDir)\include;$(SolutionDir)\libs;$(SolutionDir)\..\GtkRadiant-libs\jpeg-9a;$(SolutionDir)\..\GtkRadiant-libs\glib-2.34.3\lib\glib-2.0\include;$(SolutionDir)\..\GtkRadiant-libs\glib-2.34.3\include\glib-2.0;$(SolutionDir)\..\GtkRadiant-libs\gtk-3.6.4\include\gtk-3.0;$(SolutionDir)\..\GtkRadiant-libs\pango-1.30.1\include\pango-1.0;$(SolutionDir)\..\GtkRadiant-libs\cairo-1.10.2\include\cairo;$(SolutionDir)\..\GtkRadiant-libs\gdk-pixbuf-2.26.5\include\gdk-pixbuf-2.0;$(SolutionDir)\..\GtkRadiant-libs\atk-2.6.0\include\atk-1.0;$(SolutionDir)\..\GtkRadiant-libs\STLport-5.2.1\stlport;$(SolutionDir)\..\GtkRadiant-libs\gtkglext-1.3\include;$(SolutionDir)\..\GtkRadiant-libs\libxml2-2.9.2\include;$(SolutionDir)\..\GtkRadiant-libs\lpng1618;$(SolutionDir)\..\GtkRadiant-libs\libiconv-1.14\woe32dll\libiconv;$(SolutionDir)\..\GtkRadiant-libs\gettext-0.19.5.1\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;TEXTOOL_EXPORTS;_STLP_DONT_USE_EXCEPTIONS;_STLP_NO_NAMESPACES;_STLP_NO_IOSTREAMS;_WIN32;%(PreprocessorDefinitions);_STLP_DONT_USE_EXCEPTIONS;_STLP_NO_NAMESPACES;_STLP_NO_IOSTREAMS;_WIN32</PreprocessorDefinitions>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;TEXTOOL_EXPORTS;_STLP_DONT_USE_EXCEPTIONS;_STLP_NO_NAMESPACES;_STLP_NO_IOSTREAMS;_WIN32;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<PrecompiledHeader />
<WarningLevel>Level3</WarningLevel>

View file

@ -93,11 +93,11 @@ static bool g_bUsePak = true;
// =============================================================================
// Static functions
static void vfsAddSlash( char *str ){
static void vfsAddSlash( char *str, size_t length ){
int n = strlen( str );
if ( n > 0 ) {
if ( str[n - 1] != '\\' && str[n - 1] != '/' ) {
strcat( str, "/" );
strncat( str, "/", length );
}
}
}
@ -182,10 +182,10 @@ static GSList* vfsGetListInternal( const char *dir, const char *ext, bool direct
dirname[0] = '\0';
if ( dir != NULL ) {
strcat( dirname, dir );
strncat( dirname, dir, sizeof( dirname ) );
strlwr( dirname );
vfsFixDOSName( dirname );
vfsAddSlash( dirname );
vfsAddSlash( dirname, sizeof( dirname ) );
Sys_Printf( "vfs dirname_1: %s\n", dirname );
}
//else
@ -259,11 +259,11 @@ static GSList* vfsGetListInternal( const char *dir, const char *ext, bool direct
for ( i = 0; i < g_numDirs; i++ )
{
strcpy( dirname, g_strDirs[i] );
strcat( dirname, dir );
Q_strncpyz( dirname, g_strDirs[i], sizeof( dirname ) );
strncat( dirname, dir, sizeof( dirname ) );
strlwr( dirname );
vfsFixDOSName( dirname );
vfsAddSlash( dirname );
vfsAddSlash( dirname, sizeof( dirname ) );
diskdir = g_dir_open( dirname, 0, NULL );
@ -381,9 +381,9 @@ void vfsInitDirectory( const char *path ){
return;
}
strcpy( g_strDirs[g_numDirs], path );
Q_strncpyz( g_strDirs[g_numDirs], path, sizeof( g_strDirs[g_numDirs] ) );
vfsFixDOSName( g_strDirs[g_numDirs] );
vfsAddSlash( g_strDirs[g_numDirs] );
vfsAddSlash( g_strDirs[g_numDirs], sizeof( g_strDirs[g_numDirs] ) );
g_numDirs++;
if ( g_bUsePak ) {
@ -417,9 +417,9 @@ void vfsInitDirectory( const char *path ){
while ( dirlist )
{
GSList *cur = dirlist;
char* name = (char*)cur->data;
gchar* name = (gchar*)cur->data;
sprintf( filename, "%s/%s", path, name );
snprintf( filename, sizeof( filename ), "%s/%s", path, name );
vfsInitPakFile( filename );
g_free( name );
@ -471,7 +471,7 @@ int vfsGetFileCount( const char *filename, int flag ){
char fixed[NAME_MAX], tmp[NAME_MAX];
GSList *lst;
strcpy( fixed, filename );
Q_strncpyz( fixed, filename, sizeof( fixed ) );
vfsFixDOSName( fixed );
strlwr( fixed );
@ -486,8 +486,8 @@ int vfsGetFileCount( const char *filename, int flag ){
for ( i = 0; i < g_numDirs; i++ )
{
strcpy( tmp, g_strDirs[i] );
strcat( tmp, fixed );
Q_strncpyz( tmp, g_strDirs[i], sizeof( tmp ) );
strncat( tmp, fixed, sizeof( tmp ) );
if ( access( tmp, R_OK ) == 0 ) {
count++;
}
@ -503,14 +503,14 @@ int vfsLoadFile( const char *filename, void **bufferptr, int index ){
GSList *lst;
*bufferptr = NULL;
strcpy( fixed, filename );
Q_strncpyz( fixed, filename, sizeof( fixed ) );
vfsFixDOSName( fixed );
strlwr( fixed );
for ( i = 0; i < g_numDirs; i++ )
{
strcpy( tmp, g_strDirs[i] );
strcat( tmp, filename );
Q_strncpyz( tmp, g_strDirs[i], sizeof( tmp ) );
strncat( tmp, filename, sizeof( tmp ) );
if ( access( tmp, R_OK ) == 0 ) {
if ( count == index ) {
long len;
@ -646,7 +646,7 @@ char* vfsExtractRelativePath_short( const char *in, bool shorten ){
}
else
{
strcpy( l_in,in );
Q_strncpyz( l_in, in, sizeof( l_in ) );
}
vfsCleanFileName( l_in );
#else
@ -661,7 +661,7 @@ char* vfsExtractRelativePath_short( const char *in, bool shorten ){
for ( i = 0; i < g_numDirs; i++ )
{
strcpy( check,g_strDirs[i] );
Q_strncpyz( check, g_strDirs[i], sizeof( check ) );
vfsCleanFileName( check );
#ifdef DBG_RLTPATH
Sys_Printf( "Matching against %s\n", check );
@ -669,7 +669,7 @@ char* vfsExtractRelativePath_short( const char *in, bool shorten ){
// try to find a match
if ( strstr( l_in, check ) ) {
strcpy( out,l_in + strlen( check ) + 1 );
Q_strncpyz( out, l_in + strlen( check ) + 1, sizeof( out ) );
break;
}
@ -701,7 +701,7 @@ char* vfsGetFullPath( const char *in, int index, int flag ){
char fixed[NAME_MAX];
GSList *lst;
strcpy( fixed, in );
Q_strncpyz( fixed, in, sizeof( fixed ) );
vfsFixDOSName( fixed );
strlwr( fixed );
@ -716,7 +716,7 @@ char* vfsGetFullPath( const char *in, int index, int flag ){
lastptr = ptr + 1;
if ( strcmp( lastptr, fixed ) == 0 ) {
strncpy( out,file->name,PATH_MAX );
Q_strncpyz( out, file->name, sizeof( out ) );
return out;
}
}
@ -726,11 +726,11 @@ char* vfsGetFullPath( const char *in, int index, int flag ){
if ( !flag || ( flag & VFS_SEARCH_DIR ) ) {
for ( i = 0; i < g_numDirs; i++ )
{
strcpy( tmp, g_strDirs[i] );
strcat( tmp, in );
Q_strncpyz( tmp, g_strDirs[i], sizeof( tmp ) );
strncat( tmp, in, sizeof( tmp ) );
if ( access( tmp, R_OK ) == 0 ) {
if ( count == index ) {
strcpy( out, tmp );
Q_strncpyz( out, tmp, sizeof( out ) );
return out;
}
count++;
@ -762,7 +762,7 @@ char* vfsExtractRelativePath( const char *in ){
}
}
// this is the clean, not short version
strcpy( out, in );
Q_strncpyz( out, in, sizeof( out ) );
vfsCleanFileName( out );
for ( i = 0; i <= count; i++ )
{

View file

@ -85,11 +85,11 @@ static bool g_bUsePak = true;
// =============================================================================
// Static functions
static void vfsAddSlash( char *str ){
static void vfsAddSlash( char *str, size_t length ){
int n = strlen( str );
if ( n > 0 ) {
if ( str[n - 1] != '\\' && str[n - 1] != '/' ) {
strcat( str, "/" );
strncat( str, "/", length );
}
}
}
@ -172,10 +172,10 @@ static GSList* vfsGetListInternal( const char *refdir, const char *ext, bool dir
int i;
if ( refdir != NULL ) {
strcpy( dirname, refdir );
Q_strncpyz( dirname, refdir, sizeof( dirname ) );
strlwr( dirname );
vfsFixDOSName( dirname );
vfsAddSlash( dirname );
vfsAddSlash( dirname, sizeof( dirname ) );
}
else{
dirname[0] = '\0';
@ -183,7 +183,7 @@ static GSList* vfsGetListInternal( const char *refdir, const char *ext, bool dir
dirlen = strlen( dirname );
if ( ext != NULL ) {
strcpy( extension, ext );
Q_strncpyz( extension, ext, sizeof( extension ) );
}
else{
extension[0] = '\0';
@ -250,8 +250,8 @@ static GSList* vfsGetListInternal( const char *refdir, const char *ext, bool dir
for ( i = 0; i < g_numDirs; i++ )
{
strcpy( basedir, g_strDirs[i] );
strcat( basedir, dirname );
Q_strncpyz( basedir, g_strDirs[i], sizeof( basedir ) );
strncat( basedir, dirname, sizeof( basedir ) );
diskdir = g_dir_open( basedir, 0, NULL );
@ -267,7 +267,7 @@ static GSList* vfsGetListInternal( const char *refdir, const char *ext, bool dir
continue;
}
sprintf( filename, "%s%s", basedir, name );
snprintf( filename, sizeof( filename ), "%s%s", basedir, name );
stat( filename, &st );
if ( ( S_ISDIR( st.st_mode ) != 0 ) != directories ) {
@ -392,9 +392,9 @@ void vfsInitDirectory( const char *path ){
iGameMode = 0;
}
strcpy( g_strDirs[g_numDirs], path );
Q_strncpyz( g_strDirs[g_numDirs], path, sizeof( g_strDirs[g_numDirs] ) );
vfsFixDOSName( g_strDirs[g_numDirs] );
vfsAddSlash( g_strDirs[g_numDirs] );
vfsAddSlash( g_strDirs[g_numDirs], sizeof( g_strDirs[g_numDirs] ) );
g_numDirs++;
if ( g_bUsePak ) {
@ -421,13 +421,13 @@ void vfsInitDirectory( const char *path ){
switch ( iGameMode )
{
case 1: // SP
if ( strncmp( direntry,"sp_",3 ) == 0 ) {
memcpy( direntry,"zz",2 );
if ( strncmp( direntry, "sp_", 3 ) == 0 ) {
memcpy( direntry, "zz", 2 );
}
break;
case 2: // MP
if ( strncmp( direntry,"mp_",3 ) == 0 ) {
memcpy( direntry,"zz",2 );
if ( strncmp( direntry, "mp_", 3 ) == 0 ) {
memcpy( direntry, "zz", 2 );
}
break;
}
@ -449,28 +449,28 @@ void vfsInitDirectory( const char *path ){
switch ( iGameMode )
{
case 1: // SP
if ( strncmp( name,"mp_",3 ) == 0 ) {
if ( strncmp( name, "mp_", 3 ) == 0 ) {
g_free( name );
dirlist = g_slist_remove( cur, name );
continue;
}
else if ( strncmp( name,"zz_",3 ) == 0 ) {
memcpy( name,"sp",2 );
else if ( strncmp( name, "zz_", 3 ) == 0 ) {
memcpy( name, "sp", 2 );
}
break;
case 2: // MP
if ( strncmp( name,"sp_",3 ) == 0 ) {
if ( strncmp( name, "sp_", 3 ) == 0 ) {
g_free( name );
dirlist = g_slist_remove( cur, name );
continue;
}
else if ( strncmp( name,"zz_",3 ) == 0 ) {
memcpy( name,"mp",2 );
else if ( strncmp( name, "zz_", 3 ) == 0 ) {
memcpy( name, "mp", 2 );
}
break;
}
sprintf( filename, "%s/%s", path, name );
snprintf( filename, sizeof( filename ), "%s/%s", path, name );
vfsInitPakFile( filename );
g_free( name );
@ -532,7 +532,7 @@ int vfsGetFileCount( const char *filename, int flag ){
char fixed[NAME_MAX], tmp[NAME_MAX];
GSList *lst;
strcpy( fixed, filename );
Q_strncpyz( fixed, filename, sizeof( fixed ) );
vfsFixDOSName( fixed );
strlwr( fixed );
@ -550,8 +550,8 @@ int vfsGetFileCount( const char *filename, int flag ){
if ( !flag || ( flag & VFS_SEARCH_DIR ) ) {
for ( i = 0; i < g_numDirs; i++ )
{
strcpy( tmp, g_strDirs[i] );
strcat( tmp, fixed );
Q_strncpyz( tmp, g_strDirs[i], sizeof( tmp ) );
strncat( tmp, fixed, sizeof( tmp ) );
if ( access( tmp, R_OK ) == 0 ) {
count++;
}
@ -596,14 +596,14 @@ int vfsLoadFile( const char *filename, void **bufferptr, int index ){
GSList *lst;
*bufferptr = NULL;
strcpy( fixed, filename );
Q_strncpyz( fixed, filename, sizeof( fixed ) );
vfsFixDOSName( fixed );
strlwr( fixed );
for ( i = 0; i < g_numDirs; i++ )
{
strcpy( tmp, g_strDirs[i] );
strcat( tmp, filename );
Q_strncpyz( tmp, g_strDirs[i], sizeof( tmp ) );
strncat( tmp, filename, sizeof( tmp ) );
if ( access( tmp, R_OK ) == 0 ) {
if ( count == index ) {
return vfsLoadFullPathFile( tmp,bufferptr );
@ -682,7 +682,7 @@ char* vfsExtractRelativePath_short( const char *in, bool shorten ){
}
else
{
strcpy( l_in,in );
Q_strncpyz( l_in, in, sizeof( l_in ) );
}
vfsCleanFileName( l_in );
#else
@ -697,7 +697,7 @@ char* vfsExtractRelativePath_short( const char *in, bool shorten ){
for ( i = 0; i < g_numDirs; i++ )
{
strcpy( check,g_strDirs[i] );
Q_strncpyz( check, g_strDirs[i], sizeof( check ) );
vfsCleanFileName( check );
#ifdef DBG_RLTPATH
Sys_Printf( "Matching against %s\n", check );
@ -705,7 +705,7 @@ char* vfsExtractRelativePath_short( const char *in, bool shorten ){
// try to find a match
if ( strstr( l_in, check ) ) {
strcpy( out,l_in + strlen( check ) + 1 );
Q_strncpyz( out, l_in + strlen( check ) + 1, sizeof( out ) );
break;
}
@ -745,7 +745,7 @@ char* vfsExtractRelativePath( const char *in ){
}
}
// this is the clean, not short version
strcpy( out, in );
Q_strncpyz( out, in, sizeof( out ) );
vfsCleanFileName( out );
for ( i = 0; i <= count; i++ )
{
@ -786,7 +786,7 @@ char* vfsGetFullPath( const char *in, int index, int flag ){
char fixed[NAME_MAX];
GSList *lst;
strcpy( fixed, in );
Q_strncpyz( fixed, in, sizeof( fixed ) );
vfsFixDOSName( fixed );
strlwr( fixed );
@ -801,7 +801,7 @@ char* vfsGetFullPath( const char *in, int index, int flag ){
lastptr = ptr + 1;
if ( strcmp( lastptr, fixed ) == 0 ) {
strncpy( out,file->name,PATH_MAX );
Q_strncpyz( out, file->name, sizeof( out ) );
return out;
}
}
@ -811,11 +811,11 @@ char* vfsGetFullPath( const char *in, int index, int flag ){
if ( !flag || ( flag & VFS_SEARCH_DIR ) ) {
for ( i = 0; i < g_numDirs; i++ )
{
strcpy( tmp, g_strDirs[i] );
strcat( tmp, in );
Q_strncpyz( tmp, g_strDirs[i], sizeof( tmp ) );
strncat( tmp, in, sizeof( tmp ) );
if ( access( tmp, R_OK ) == 0 ) {
if ( count == index ) {
strcpy( out, tmp );
Q_strncpyz( out, tmp, sizeof( out ) );
return out;
}
count++;

View file

@ -116,7 +116,7 @@
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<AdditionalIncludeDirectories>$(SolutionDir)\include;$(SolutionDir)\libs;$(SolutionDir)\..\GtkRadiant-libs\jpeg-9a;$(SolutionDir)\..\GtkRadiant-libs\glib-2.34.3\lib\glib-2.0\include;$(SolutionDir)\..\GtkRadiant-libs\glib-2.34.3\include\glib-2.0;$(SolutionDir)\..\GtkRadiant-libs\gtk-3.6.4\include\gtk-3.0;$(SolutionDir)\..\GtkRadiant-libs\pango-1.30.1\include\pango-1.0;$(SolutionDir)\..\GtkRadiant-libs\cairo-1.10.2\include\cairo;$(SolutionDir)\..\GtkRadiant-libs\gdk-pixbuf-2.26.5\include\gdk-pixbuf-2.0;$(SolutionDir)\..\GtkRadiant-libs\atk-2.6.0\include\atk-1.0;$(SolutionDir)\..\GtkRadiant-libs\STLport-5.2.1\stlport;$(SolutionDir)\..\GtkRadiant-libs\gtkglext-1.3\include;$(SolutionDir)\..\GtkRadiant-libs\libxml2-2.9.2\include;$(SolutionDir)\..\GtkRadiant-libs\lpng1618;$(SolutionDir)\..\GtkRadiant-libs\libiconv-1.14\woe32dll\libiconv;$(SolutionDir)\..\GtkRadiant-libs\gettext-0.19.5.1\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;VFSPK3_EXPORTS;_STLP_DONT_USE_EXCEPTIONS;_STLP_NO_NAMESPACES;_STLP_NO_IOSTREAMS;_WIN32;%(PreprocessorDefinitions);_STLP_DONT_USE_EXCEPTIONS;_STLP_NO_NAMESPACES;_STLP_NO_IOSTREAMS;_WIN32</PreprocessorDefinitions>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;VFSPK3_EXPORTS;_STLP_DONT_USE_EXCEPTIONS;_STLP_NO_NAMESPACES;_STLP_NO_IOSTREAMS;_WIN32;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<PrecompiledHeader />
<WarningLevel>Level3</WarningLevel>

View file

@ -85,11 +85,11 @@ static bool g_bUsePak = true;
// =============================================================================
// Static functions
static void vfsAddSlash( char *str ){
static void vfsAddSlash( char *str, size_t length ){
int n = strlen( str );
if ( n > 0 ) {
if ( str[n - 1] != '\\' && str[n - 1] != '/' ) {
strcat( str, "/" );
strncat( str, "/", length );
}
}
}
@ -172,10 +172,10 @@ static GSList* vfsGetListInternal( const char *refdir, const char *ext, bool dir
int i;
if ( refdir != NULL ) {
strcpy( dirname, refdir );
Q_strncpyz( dirname, refdir, sizeof( dirname ) );
strlwr( dirname );
vfsFixDOSName( dirname );
vfsAddSlash( dirname );
vfsAddSlash( dirname, sizeof( dirname ) );
}
else{
dirname[0] = '\0';
@ -183,7 +183,7 @@ static GSList* vfsGetListInternal( const char *refdir, const char *ext, bool dir
dirlen = strlen( dirname );
if ( ext != NULL ) {
strcpy( extension, ext );
Q_strncpyz( extension, ext, sizeof( extension ) );
}
else{
extension[0] = '\0';
@ -250,8 +250,8 @@ static GSList* vfsGetListInternal( const char *refdir, const char *ext, bool dir
for ( i = 0; i < g_numDirs; i++ )
{
strcpy( basedir, g_strDirs[i] );
strcat( basedir, dirname );
Q_strncpyz( basedir, g_strDirs[i], sizeof( basedir ) );
strncat( basedir, dirname, sizeof( basedir ) );
diskdir = g_dir_open( basedir, 0, NULL );
@ -392,9 +392,9 @@ void vfsInitDirectory( const char *path ){
iGameMode = 0;
}
strcpy( g_strDirs[g_numDirs], path );
Q_strncpyz( g_strDirs[g_numDirs], path, sizeof( g_strDirs[g_numDirs] ) );
vfsFixDOSName( g_strDirs[g_numDirs] );
vfsAddSlash( g_strDirs[g_numDirs] );
vfsAddSlash( g_strDirs[g_numDirs], sizeof( g_strDirs[g_numDirs] ) );
g_numDirs++;
if ( g_bUsePak ) {
@ -532,7 +532,7 @@ int vfsGetFileCount( const char *filename, int flag ){
char fixed[NAME_MAX], tmp[NAME_MAX];
GSList *lst;
strcpy( fixed, filename );
Q_strncpyz( fixed, filename, sizeof( fixed ) );
vfsFixDOSName( fixed );
strlwr( fixed );
@ -550,8 +550,8 @@ int vfsGetFileCount( const char *filename, int flag ){
if ( !flag || ( flag & VFS_SEARCH_DIR ) ) {
for ( i = 0; i < g_numDirs; i++ )
{
strcpy( tmp, g_strDirs[i] );
strcat( tmp, fixed );
Q_strncpyz( tmp, g_strDirs[i], sizeof( tmp ) );
strncat( tmp, fixed, sizeof( tmp ) );
if ( access( tmp, R_OK ) == 0 ) {
count++;
}
@ -596,14 +596,14 @@ int vfsLoadFile( const char *filename, void **bufferptr, int index ){
GSList *lst;
*bufferptr = NULL;
strcpy( fixed, filename );
Q_strncpyz( fixed, filename, sizeof( fixed ) );
vfsFixDOSName( fixed );
strlwr( fixed );
for ( i = 0; i < g_numDirs; i++ )
{
strcpy( tmp, g_strDirs[i] );
strcat( tmp, filename );
Q_strncpyz( tmp, g_strDirs[i], sizeof( tmp ) );
strncat( tmp, filename, sizeof( tmp ) );
if ( access( tmp, R_OK ) == 0 ) {
if ( count == index ) {
return vfsLoadFullPathFile( tmp,bufferptr );
@ -682,11 +682,11 @@ char* vfsExtractRelativePath_short( const char *in, bool shorten ){
}
else
{
strcpy( l_in,in );
Q_strncpyz( l_in, in, sizeof( l_in ) );
}
vfsCleanFileName( l_in );
#else
strcpy( l_in, in );
Q_strncpyz( l_in, in, sizeof( l_in ) );
vfsCleanFileName( l_in );
#endif // ifdef WIN32
@ -697,7 +697,7 @@ char* vfsExtractRelativePath_short( const char *in, bool shorten ){
for ( i = 0; i < g_numDirs; i++ )
{
strcpy( check,g_strDirs[i] );
Q_strncpyz( check, g_strDirs[i], sizeof( check ) );
vfsCleanFileName( check );
#ifdef DBG_RLTPATH
Sys_Printf( "Matching against %s\n", check );
@ -705,7 +705,7 @@ char* vfsExtractRelativePath_short( const char *in, bool shorten ){
// try to find a match
if ( strstr( l_in, check ) ) {
strcpy( out,l_in + strlen( check ) + 1 );
Q_strncpyz( out, l_in + strlen( check ) + 1, sizeof( out ) );
break;
}
@ -745,7 +745,7 @@ char* vfsExtractRelativePath( const char *in ){
}
}
// this is the clean, not short version
strcpy( out, in );
Q_strncpyz( out, in, sizeof( out ) );
vfsCleanFileName( out );
for ( i = 0; i <= count; i++ )
{
@ -786,7 +786,7 @@ char* vfsGetFullPath( const char *in, int index, int flag ){
char fixed[NAME_MAX];
GSList *lst;
strcpy( fixed, in );
Q_strncpyz( fixed, in, sizeof( fixed ) );
vfsFixDOSName( fixed );
strlwr( fixed );
@ -801,7 +801,7 @@ char* vfsGetFullPath( const char *in, int index, int flag ){
lastptr = ptr + 1;
if ( strcmp( lastptr, fixed ) == 0 ) {
strncpy( out,file->name,PATH_MAX );
Q_strncpyz( out, file->name, sizeof( out ) );
return out;
}
}
@ -811,11 +811,11 @@ char* vfsGetFullPath( const char *in, int index, int flag ){
if ( !flag || ( flag & VFS_SEARCH_DIR ) ) {
for ( i = 0; i < g_numDirs; i++ )
{
strcpy( tmp, g_strDirs[i] );
strcat( tmp, in );
Q_strncpyz( tmp, g_strDirs[i], sizeof( tmp ) );
strncat( tmp, in, sizeof( tmp ) );
if ( access( tmp, R_OK ) == 0 ) {
if ( count == index ) {
strcpy( out, tmp );
Q_strncpyz( out, tmp, sizeof( out ) );
return out;
}
count++;

View file

@ -85,11 +85,11 @@ static int g_numDirs;
// =============================================================================
// Static functions
static void vfsAddSlash( char *str ){
static void vfsAddSlash( char *str, size_t length ){
int n = strlen( str );
if ( n > 0 ) {
if ( str[n - 1] != '\\' && str[n - 1] != '/' ) {
strcat( str, "/" );
strncat( str, "/", length );
}
}
}
@ -224,7 +224,7 @@ static GSList* vfsGetListInternal( const char *refdir, const char *ext, bool dir
strcpy( dirname, refdir );
strlwr( dirname );
vfsFixDOSName( dirname );
vfsAddSlash( dirname );
vfsAddSlash( dirname, sizeof( dirname ) );
}
else{
dirname[0] = '\0';
@ -299,8 +299,8 @@ static GSList* vfsGetListInternal( const char *refdir, const char *ext, bool dir
for ( i = 0; i < g_numDirs; i++ )
{
strcpy( basedir, g_strDirs[i] );
strcat( basedir, dirname );
Q_strncpyz( basedir, g_strDirs[i], sizeof( basedir ) );
strncat( basedir, dirname, sizeof( basedir ) );
GDir* dir = g_dir_open( basedir, 0, NULL );
@ -316,7 +316,7 @@ static GSList* vfsGetListInternal( const char *refdir, const char *ext, bool dir
continue;
}
sprintf( filename, "%s%s", basedir, name );
snprintf( filename, sizeof( filename ), "%s%s", basedir, name );
stat( filename, &st );
if ( ( S_ISDIR( st.st_mode ) != 0 ) != directories ) {
@ -368,7 +368,7 @@ void vfsInitDirectory( const char *path ){
strcpy( g_strDirs[g_numDirs], path );
vfsFixDOSName( g_strDirs[g_numDirs] );
vfsAddSlash( g_strDirs[g_numDirs] );
vfsAddSlash( g_strDirs[g_numDirs], sizeof( g_strDirs[g_numDirs] ) );
g_numDirs++;
// if (g_PrefsDlg.m_bPAK)
@ -468,8 +468,8 @@ int vfsGetFileCount( const char *filename, int flag ){
if ( !flag || ( flag & VFS_SEARCH_DIR ) ) {
for ( i = 0; i < g_numDirs; i++ )
{
strcpy( tmp, g_strDirs[i] );
strcat( tmp, fixed );
Q_strncpyz( tmp, g_strDirs[i], sizeof( tmp ) );
strncat( tmp, fixed, sizeof( tmp ) );
if ( access( tmp, R_OK ) == 0 ) {
count++;
}
@ -520,8 +520,8 @@ int vfsLoadFile( const char *filename, void **bufferptr, int index ){
for ( i = 0; i < g_numDirs; i++ )
{
strcpy( tmp, g_strDirs[i] );
strcat( tmp, filename );
Q_strncpyz( tmp, g_strDirs[i], sizeof( tmp ) );
strncat( tmp, filename, sizeof( tmp ) );
if ( access( tmp, R_OK ) == 0 ) {
if ( count == index ) {
return vfsLoadFullPathFile( tmp,bufferptr );
@ -709,7 +709,7 @@ char* vfsGetFullPath( const char *in, int index, int flag ){
lastptr = ptr + 1;
if ( strcmp( lastptr, fixed ) == 0 ) {
strncpy( out,file->name,PATH_MAX );
Q_strncpyz( out, file->name, sizeof( out ) );
return out;
}
}
@ -719,8 +719,8 @@ char* vfsGetFullPath( const char *in, int index, int flag ){
if ( !flag || ( flag & VFS_SEARCH_DIR ) ) {
for ( i = 0; i < g_numDirs; i++ )
{
strcpy( tmp, g_strDirs[i] );
strcat( tmp, in );
Q_strncpyz( tmp, g_strDirs[i], sizeof( tmp ) );
strncat( tmp, in, sizeof( tmp ) );
if ( access( tmp, R_OK ) == 0 ) {
if ( count == index ) {
strcpy( out, tmp );

View file

@ -1536,13 +1536,13 @@ const char* Brush_GetKeyValue( brush_t *b, const char *pKey ){
temporary stuff, detect potential problems when saving the texture name
=================
*/
void CheckName( face_t *fa, char *pname ){
void CheckName( face_t *fa, char *pname, size_t length ){
if ( !strlen( fa->texdef.GetName() ) ) {
#ifdef _DEBUG
Sys_Printf( "WARNING: unexpected texdef.name is empty in Brush.cpp CheckName\n" );
#endif
fa->texdef.SetName( SHADER_NOT_FOUND );
strcpy( pname, SHADER_NOT_FOUND );
Q_strncpyz( pname, SHADER_NOT_FOUND, length );
return;
}
@ -1554,7 +1554,7 @@ void CheckName( face_t *fa, char *pname ){
Sys_Printf( "%s\n", Msg1 );
gtk_MessageBox( g_pParentWnd->m_pWidget, Msg1, "Error saving map", MB_OK );
strcpy( pname, SHADER_NOT_FOUND );
Q_strncpyz( pname, SHADER_NOT_FOUND, length );
return;
}
@ -1566,10 +1566,10 @@ void CheckName( face_t *fa, char *pname ){
gtk_MessageBox( g_pParentWnd->m_pWidget, text, "Error saving map", MB_OK );
// need to cleanup this dead face name or we may loop endlessly
fa->texdef.SetName( SHADER_NOT_FOUND );
strcpy( pname, SHADER_NOT_FOUND );
Q_strncpyz( pname, SHADER_NOT_FOUND, length );
return;
}
strcpy( pname, fa->texdef.GetName() + 9 ); // remove "textures/"
Q_strncpyz( pname, fa->texdef.GetName() + 9, length ); // remove "textures/"
}
/*

View file

@ -269,7 +269,7 @@ void EClass_InitForFileList( GSList *pFiles, _EClassTable *pTable ){
// this allows to override baseq3/scripts/entities.def for instance
char relPath[PATH_MAX];
strcpy( relPath, "scripts/" );
strcat( relPath, (char*)pFile->data );
strncat( relPath, (char*)pFile->data, sizeof( relPath ) );
if ( !vfsGetFullPath( relPath, 0, 0 ) ) {
Sys_FPrintf( SYS_ERR, "Failed to find the full path for '%s' in the VFS\n", relPath );
}
@ -313,13 +313,13 @@ eclass_t * EClass_Create( const char *name, float col1, float col2, float col3,
// b) no entity definition files were found
// c) no entity definition file contained an entry for worldspawn.
if ( stricmp( name,"worldspawn" ) != 0 ) {
if ( stricmp( name, "worldspawn" ) != 0 ) {
e->fixedsize = true;
}
// copy the sizes..
memcpy( e->mins,mins,sizeof( vec3_t ) );
memcpy( e->maxs,maxs,sizeof( vec3_t ) );
memcpy( e->mins, mins, sizeof( vec3_t ) );
memcpy( e->maxs, maxs, sizeof( vec3_t ) );
}
if ( comments ) {
@ -404,7 +404,7 @@ void Eclass_Init(){
// this allows to override baseq3/scripts/entities.def for instance
char relPath[PATH_MAX];
strcpy( relPath, "scripts/" );
strcat( relPath, (char*)pFile->data );
strncat( relPath, (char*)pFile->data, sizeof( relPath ) );
char *fullpath = vfsGetFullPath( relPath, 0, 0 );
if ( !fullpath ) {
Sys_FPrintf( SYS_ERR, "Failed to find the full path for \"%s\" in the VFS\n", relPath );

View file

@ -113,8 +113,7 @@ void setSpecialLoad( eclass_t *e, const char* pWhat, char*& p ){
if ( where ) {
int len = ( where - pText );
p = new char[len + 1];
strncpy( p,pText,len );
p[len] = 0; // just to make sure, as most implementations of strncpy don't null terminate
Q_strncpyz( p, pText, len );
}
else{
p = strdup( pText );
@ -202,7 +201,12 @@ eclass_t *Eclass_InitFromText( char *text ){
if ( !p ) {
break;
}
strcpy( e->flagnames[i], Get_COM_Token() );
Q_strncpyz( e->flagnames[i], Get_COM_Token(), sizeof( e->flagnames[i] ) );
if( strlen( Get_COM_Token() ) > sizeof( e->flagnames[i] ) - 1 )
{
Syn_Printf( "Warning: spawnflag/parm/flagname too long for Eclass %s: %s\n", e->name, e->flagnames[i] );
}
}
// find the length until close comment

View file

@ -45,16 +45,16 @@ void Error( const char *error, ... ){
char text[4096];
va_start( argptr,error );
vsprintf( text, error,argptr );
vsnprintf( text, sizeof( text ), error, argptr );
va_end( argptr );
strcat( text, "\n" );
strncat( text, "\n", sizeof( text ) );
#if defined ( __linux__ ) || defined ( __APPLE__ )
if ( errno != 0 ) {
strcat( text, "errno: " );
strcat( text, strerror( errno ) );
strcat( text, "\n" );
strncat( text, "errno: ", sizeof( text ) );
strncat( text, strerror( errno ), sizeof( text ) );
strncat( text, "\n", sizeof( text ) );
}
#endif
@ -72,7 +72,7 @@ void Error( const char *error, ... ){
0,
NULL
);
strcat( text, "GetLastError: " );
strncat( text, "GetLastError: ", sizeof( text ) );
/*
Gtk will only crunch 0<=char<=127
this is a bit hackish, but I didn't find useful functions in win32 API for this
@ -90,7 +90,7 @@ void Error( const char *error, ... ){
}
next = CharNext( scan );
} while ( next != scan );
strcat( text, "\n" );
strncat( text, "\n", sizeof( text ) );
LocalFree( lpMsgBuf );
}
#endif
@ -103,14 +103,14 @@ void Error( const char *error, ... ){
GLenum iGLError = qglGetError();
if ( iGLError != GL_NO_ERROR ) {
// use our own gluErrorString
strcat( text, "qgluErrorString: " );
strcat( text, (char*)qgluErrorString( iGLError ) );
strcat( text, "\n" );
strncat( text, "qgluErrorString: ", sizeof( text ) );
strncat( text, (char*)qgluErrorString( iGLError ), sizeof( text ) );
strncat( text, "\n", sizeof( text ) );
}
}
strcat( text, "An unrecoverable error has occured.\n"
"Would you like to edit Preferences before exiting Radiant?" );
strncat( text, "An unrecoverable error has occured.\n"
"Would you like to edit Preferences before exiting Radiant?", sizeof( text ) );
Sys_Printf( text );
@ -137,7 +137,7 @@ void WINAPI Error( char *error, ... ){
char text[1024];
va_start( argptr,error );
vsprintf( text, error,argptr );
vsnprintf( text, sizeof( text ), error, argptr );
va_end( argptr );
Error( (const char *)text );

View file

@ -229,7 +229,7 @@ void MemStream::printf( const char* s, ... ){
char buffer[4096];
va_start( args, s );
vsprintf( buffer, s, args );
vsnprintf( buffer, sizeof( buffer ), s, args );
va_end( args );
Write( buffer, strlen( buffer ) );
}

View file

@ -579,13 +579,13 @@ bool GetSelectAllCriteria( CString &strKey, CString &strVal ){
void AssignSound(){
char buffer[NAME_MAX];
strcpy( buffer, g_qeglobals.m_strHomeMaps.GetBuffer() );
strcat( buffer, "sound/" );
Q_strncpyz( buffer, g_qeglobals.m_strHomeMaps.GetBuffer(), sizeof( buffer ) );
strncat( buffer, "sound/", sizeof( buffer ) );
if ( access( buffer, R_OK ) != 0 ) {
// just go to fsmain
strcpy( buffer, g_qeglobals.m_strHomeMaps.GetBuffer() );
strcat( buffer, "/" );
Q_strncpyz( buffer, g_qeglobals.m_strHomeMaps.GetBuffer(), sizeof( buffer ) );
strncat( buffer, "/", sizeof( buffer ) );
}
const char *filename = file_dialog( g_pGroupDlg->m_pWidget, TRUE, _( "Open Wav File" ), buffer, "sound" );
@ -610,13 +610,13 @@ void AssignSound(){
void AssignModel(){
char buffer[NAME_MAX];
strcpy( buffer, g_qeglobals.m_strHomeMaps.GetBuffer() );
strcat( buffer, "models/" );
Q_strncpyz( buffer, g_qeglobals.m_strHomeMaps.GetBuffer(), sizeof( buffer ) );
strncat( buffer, "models/", sizeof( buffer ) );
if ( access( buffer, R_OK ) != 0 ) {
// just go to fsmain
strcpy( buffer, g_qeglobals.m_strHomeMaps.GetBuffer() );
strcat( buffer, "/" );
Q_strncpyz( buffer, g_qeglobals.m_strHomeMaps.GetBuffer(), sizeof( buffer ) );
strncat( buffer, "/", sizeof( buffer ) );
}
const char *filename = file_dialog( g_pGroupDlg->m_pWidget, TRUE, _( "Open Model" ), buffer, MODEL_MAJOR );
@ -1274,6 +1274,7 @@ void GroupDlg::Create(){
{
GtkWidget* split1 = gtk_paned_new( GTK_ORIENTATION_VERTICAL );
#if GTK_CHECK_VERSION( 3,12,0 )
todo; //do we want a wide handle?
gtk_paned_set_wide_handle( GTK_PANED( split1 ), TRUE );
#else
@ -1284,6 +1285,7 @@ void GroupDlg::Create(){
{
GtkWidget* split2 = gtk_paned_new( GTK_ORIENTATION_VERTICAL );
#if GTK_CHECK_VERSION(3,12,0)
todo; //do we want a wide handle?
gtk_paned_set_wide_handle( GTK_PANED( split2 ), TRUE );
#else

View file

@ -436,7 +436,7 @@ void OnSelchangeComboWhatgame( GtkWidget *widget, gpointer data ){
void ProjectSettings_dirbutton_clicked( GtkButton *button, gpointer user_data ){
GtkWidget *dialog, *entry;
const gchar *path;
char *dir;
gchar *dir;
dialog = GTK_WIDGET( user_data );
entry = GTK_WIDGET( g_object_get_data( G_OBJECT( dialog ), "base" ) );
@ -1182,7 +1182,7 @@ void DoEntityList(){
gtk_tree_store_append( store, &parent, NULL );
gtk_tree_store_set( store, &parent, 0, pEntity->eclass->name, 1, NULL, -1 );
entry = (map_t*)malloc( sizeof( map_t ) );
entry = (map_t*)g_malloc( sizeof( map_t ) );
entitymap = g_slist_append( entitymap, entry );
entry->name = pEntity->eclass->name;
entry->node = parent;
@ -1195,7 +1195,7 @@ void DoEntityList(){
while ( entitymap )
{
free( entitymap->data );
g_free( entitymap->data );
entitymap = g_slist_remove( entitymap, entitymap->data );
}
}

View file

@ -1423,11 +1423,11 @@ const char* file_dialog( void *parent, gboolean open, const char* title, const c
// we expect an actual path below, if the path is NULL we might crash
if ( !path || path[0] == '\0' ) {
strcpy( buf, g_pGameDescription->mEnginePath.GetBuffer() );
strcat( buf, g_pGameDescription->mBaseGame.GetBuffer() );
strcat( buf, "/" );
Q_strncpyz( buf, g_pGameDescription->mEnginePath.GetBuffer(), sizeof( buf ) );
strncat( buf, g_pGameDescription->mBaseGame.GetBuffer(), sizeof( buf ) );
strncat( buf, "/", sizeof( buf ) );
if ( baseSubDir ) {
strcat( buf, baseSubDir );
strncat( buf, baseSubDir, sizeof( buf ) );
}
path = buf;
}
@ -1474,7 +1474,9 @@ const char* file_dialog( void *parent, gboolean open, const char* title, const c
}
if ( gtk_dialog_run( GTK_DIALOG( file_sel ) ) == GTK_RESPONSE_ACCEPT ) {
strcpy( szFile, gtk_file_chooser_get_filename( GTK_FILE_CHOOSER( file_sel ) ) );
gchar * filename = gtk_file_chooser_get_filename( GTK_FILE_CHOOSER( file_sel ) );
Q_strncpyz( szFile, filename, sizeof( szFile ) );
g_free( filename );
}
else {
szFile[0] = '\0';
@ -1555,9 +1557,9 @@ const char* file_dialog( void *parent, gboolean open, const char* title, const c
return szFile;
}
char* WINAPI dir_dialog( void *parent, const char* title, const char* path ){
gchar* WINAPI dir_dialog( void *parent, const char* title, const char* path ){
GtkWidget* file_sel;
char* filename = (char*)NULL;
gchar* filename = (char*)NULL;
gint response_id;
GtkFileChooserAction action = GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER;
@ -1572,7 +1574,7 @@ char* WINAPI dir_dialog( void *parent, const char* title, const char* path ){
response_id = gtk_dialog_run( GTK_DIALOG( file_sel ) );
if ( response_id == GTK_RESPONSE_ACCEPT ) {
filename = g_strdup( gtk_file_chooser_get_filename( GTK_FILE_CHOOSER( file_sel ) ) );
filename = gtk_file_chooser_get_filename( GTK_FILE_CHOOSER( file_sel ) );
}
else {
filename = NULL;

View file

@ -89,7 +89,7 @@ const gchar* file_dialog( void *parent, gboolean open, const char* title, const
/*!
\fn dir_dialog, prompts for a directory
*/
char* WINAPI dir_dialog( void *parent, const char* title = "Choose Directory", const char* path = (char*)NULL );
gchar* WINAPI dir_dialog( void *parent, const char* title = "Choose Directory", const char* path = (char*)NULL );
// GtkWidget *parent
bool WINAPI color_dialog( void *parent, float *color, const char* title = "Choose Color" );

View file

@ -310,61 +310,61 @@ void error_redirect( const gchar *domain, GLogLevelFlags log_level, const gchar
}
if ( domain ) {
strcpy( buf, domain );
Q_strncpyz( buf, domain, sizeof( buf ) );
}
else{
strcpy( buf, "**" );
Q_strncpyz( buf, "**", sizeof( buf ) );
}
strcat( buf, "-" );
strncat( buf, "-", sizeof( buf ) );
switch ( log_level )
{
case G_LOG_LEVEL_ERROR:
if ( in_recursion ) {
strcat( buf, "ERROR (recursed) **: " );
strncat( buf, "ERROR (recursed) **: ", sizeof( buf ) );
}
else{
strcat( buf, "ERROR **: " );
strncat( buf, "ERROR **: ", sizeof( buf ) );
}
break;
case G_LOG_LEVEL_CRITICAL:
if ( in_recursion ) {
strcat( buf, "CRITICAL (recursed) **: " );
strncat( buf, "CRITICAL (recursed) **: ", sizeof( buf ) );
}
else{
strcat( buf, "CRITICAL **: " );
strncat( buf, "CRITICAL **: ", sizeof( buf ) );
}
break;
case G_LOG_LEVEL_WARNING:
if ( in_recursion ) {
strcat( buf, "WARNING (recursed) **: " );
strncat( buf, "WARNING (recursed) **: ", sizeof( buf ) );
}
else{
strcat( buf, "WARNING **: " );
strncat( buf, "WARNING **: ", sizeof( buf ) );
}
break;
case G_LOG_LEVEL_MESSAGE:
if ( in_recursion ) {
strcat( buf, "Message (recursed): " );
strncat( buf, "Message (recursed): ", sizeof( buf ) );
}
else{
strcat( buf, "Message: " );
strncat( buf, "Message: ", sizeof( buf ) );
}
break;
case G_LOG_LEVEL_INFO:
if ( in_recursion ) {
strcat( buf, "INFO (recursed): " );
strncat( buf, "INFO (recursed): ", sizeof( buf ) );
}
else{
strcat( buf, "INFO: " );
strncat( buf, "INFO: ", sizeof( buf ) );
}
break;
case G_LOG_LEVEL_DEBUG:
if ( in_recursion ) {
strcat( buf, "DEBUG (recursed): " );
strncat( buf, "DEBUG (recursed): ", sizeof( buf ) );
}
else{
strcat( buf, "DEBUG: " );
strncat( buf, "DEBUG: ", sizeof( buf ) );
}
break;
default:
@ -372,10 +372,10 @@ void error_redirect( const gchar *domain, GLogLevelFlags log_level, const gchar
* try to make the best out of it.
*/
if ( in_recursion ) {
strcat( buf, "LOG (recursed:" );
strncat( buf, "LOG (recursed:", sizeof( buf ) );
}
else{
strcat( buf, "LOG (" );
strncat( buf, "LOG (", sizeof( buf ) );
}
if ( log_level ) {
gchar string[] = "0x00): ";
@ -390,19 +390,19 @@ void error_redirect( const gchar *domain, GLogLevelFlags log_level, const gchar
*p += 'A' - '9' - 1;
}
strcat( buf, string );
strncat( buf, string, sizeof( buf ) );
}
else{
strcat( buf, "): " );
strncat( buf, "): ", sizeof( buf ) );
}
}
strcat( buf, message );
strncat( buf, message, sizeof( buf ) );
if ( is_fatal ) {
strcat( buf, "\naborting...\n" );
strncat( buf, "\naborting...\n", sizeof( buf ) );
}
else{
strcat( buf, "\n" );
strncat( buf, "\n", sizeof( buf ) );
}
printf( "%s\n", buf );
@ -930,12 +930,12 @@ void QE_ExpandBspString( char *bspaction, GPtrArray *out_array, char *mapname ){
char rsh[BIG_PATH_MAX];
char base[BIG_PATH_MAX];
strcpy( src, mapname );
Q_strncpyz( src, mapname, sizeof( src ) );
strlwr( src );
in = strstr( src, "maps/" );
if ( in ) {
in += 5;
strcpy( base, in );
Q_strncpyz( base, in, sizeof( base ) );
out = base;
while ( *out )
{
@ -981,7 +981,7 @@ void QE_ExpandBspString( char *bspaction, GPtrArray *out_array, char *mapname ){
while ( *in )
{
if ( in[0] == '!' ) {
strcpy( out, rsh );
Q_strncpyz( out, rsh, sizeof( out ) );
out += strlen( rsh );
in++;
continue;
@ -992,7 +992,7 @@ void QE_ExpandBspString( char *bspaction, GPtrArray *out_array, char *mapname ){
if ( g_PrefsDlg.m_bWatchBSP ) {
// -connect global option (the only global option so far anyway)
strcpy( tmp, " -connect 127.0.0.1:39000 " );
strcpy( out, tmp );
Q_strncpyz( out, tmp, sizeof( out ) );
out += strlen( tmp );
}
in++;
@ -1000,7 +1000,7 @@ void QE_ExpandBspString( char *bspaction, GPtrArray *out_array, char *mapname ){
}
if ( in[0] == '$' ) {
// $ expansion
strcpy( out, src );
Q_strncpyz( out, src, sizeof( out ) );
out += strlen( src );
in++;
continue;
@ -1040,15 +1040,15 @@ void FindReplace( CString& strContents, const char* pTag, const char* pValue ){
}
// save the map, deals with regioning
void SaveWithRegion( char *name ){
strcpy( name, currentmap );
void SaveWithRegion( char *name, size_t length ){
Q_strncpyz( name, currentmap, length );
if ( region_active ) {
// temporary cut the region to save regular map
region_active = false;
Map_SaveFile( name, false );
region_active = true;
StripExtension( name );
strcat( name, ".reg" );
strncat( name, ".reg", length );
}
Map_SaveFile( name, region_active );
@ -1119,9 +1119,9 @@ void RunBsp( char *command ){
SetInspectorMode( W_CONSOLE );
strcpy( temppath, g_strTempPath.GetBuffer() );
Q_strncpyz( temppath, g_strTempPath.GetBuffer(), sizeof( temppath ) );
SaveWithRegion( name );
SaveWithRegion( name, sizeof( name ) );
const char *rsh = ValueForKey( g_qeglobals.d_project_entity, "rshcmd" );
if ( rsh == NULL ) {
@ -1129,10 +1129,10 @@ void RunBsp( char *command ){
ExtractPath_and_Filename( name, strPath, strFile );
AddSlash( strPath );
strncpy( cWork, strPath, 1024 );
strcat( cWork, strFile );
Q_strncpyz( cWork, strPath, 1024 );
strncat( cWork, strFile, sizeof( cWork ) );
} else {
strcpy( cWork, name );
Q_strncpyz( cWork, name, sizeof( cWork ) );
}
// get the array ready

View file

@ -3577,7 +3577,7 @@ void MainFrame::LoadCommandMap(){
for ( int i = 0; i < g_nCommandCount; i++ )
{
char value[1024];
if ( read_var( strINI.GetBuffer(), "Commands", g_Commands[i].m_strCommand, value ) ) {
if ( read_var( strINI.GetBuffer(), "Commands", g_Commands[i].m_strCommand, value, sizeof( value ) ) ) {
if ( !bUserCmdList ) {
Sys_Printf( "Found user's shortcuts list at %s\n", strINI.GetBuffer() );
bUserCmdList = true;
@ -3747,10 +3747,10 @@ void MainFrame::CreateQEChildren(){
// check to see if the project template is versioned
strcpy( buf, g_pGameDescription->mEnginePath.GetBuffer() );
strcat( buf, g_pGameDescription->mBaseGame.GetBuffer() );
strcat( buf, "/scripts/" );
strcat( buf, PROJECT_TEMPLATE_NAME );
Q_strncpyz( buf, g_pGameDescription->mEnginePath.GetBuffer(), sizeof( buf ) );
strncat( buf, g_pGameDescription->mBaseGame.GetBuffer(), sizeof( buf ) );
strncat( buf, "/scripts/", sizeof( buf ) );
strncat( buf, PROJECT_TEMPLATE_NAME, sizeof( buf ) );
templateVersion = QE_GetTemplateVersionForProject( buf );
r = g_PrefsDlg.m_strLastProject.GetBuffer();
@ -3761,10 +3761,10 @@ void MainFrame::CreateQEChildren(){
// try default project location
bTriedTemplate = true;
// for all OSes, we look for the template in the base installation (no homepath here)
strcpy( buf, g_pGameDescription->mEnginePath.GetBuffer() );
strcat( buf, g_pGameDescription->mBaseGame.GetBuffer() );
strcat( buf, "/scripts/" );
strcat( buf, PROJECT_TEMPLATE_NAME );
Q_strncpyz( buf, g_pGameDescription->mEnginePath.GetBuffer(), sizeof( buf ) );
strncat( buf, g_pGameDescription->mBaseGame.GetBuffer(), sizeof( buf ) );
strncat( buf, "/scripts/", sizeof( buf ) );
strncat( buf, PROJECT_TEMPLATE_NAME, sizeof( buf ) );
r = buf;
}
else
@ -4333,8 +4333,8 @@ void MainFrame::OnFileOpen(){
char buf[NAME_MAX];
if ( !g_pGameDescription->noMapsInHome ) {
strcpy( buf, g_qeglobals.m_strHomeMaps.GetBuffer() );
strcat( buf, "maps/" );
Q_strncpyz( buf, g_qeglobals.m_strHomeMaps.GetBuffer(), sizeof( buf ) );
strncat( buf, "maps/", sizeof( buf ) );
}
else {
buf[0] = '\0';
@ -4343,7 +4343,7 @@ void MainFrame::OnFileOpen(){
str = file_dialog( m_pWidget, TRUE, _( "Open Map" ), buf, MAP_MAJOR, "maps/" );
if ( str != NULL ) {
strcpy( currentmap,str );
Q_strncpyz( currentmap, str, sizeof( currentmap ) );
MRU_AddFile( str );
Map_LoadFile( str );
}
@ -4354,8 +4354,8 @@ void MainFrame::OnFileImportmap(){
char buf[NAME_MAX];
if ( !g_pGameDescription->noMapsInHome ) {
strcpy( buf, g_qeglobals.m_strHomeMaps.GetBuffer() );
strcat( buf, "maps/" );
Q_strncpyz( buf, g_qeglobals.m_strHomeMaps.GetBuffer(), sizeof( buf ) );
strncat( buf, "maps/", sizeof( buf ) );
}
else {
buf[0] = '\0';
@ -4382,8 +4382,8 @@ void MainFrame::OnFileSaveas(){
char buf[NAME_MAX];
if ( !g_pGameDescription->noMapsInHome ) {
strcpy( buf, g_qeglobals.m_strHomeMaps.GetBuffer() );
strcat( buf, "maps/" );
Q_strncpyz( buf, g_qeglobals.m_strHomeMaps.GetBuffer(), sizeof( buf ) );
strncat( buf, "maps/", sizeof( buf ) );
}
else {
buf[0] = '\0';
@ -4392,7 +4392,7 @@ void MainFrame::OnFileSaveas(){
str = file_dialog( g_pParentWnd->m_pWidget, FALSE, _( "Save Map" ), buf, MAP_MAJOR, "maps/" );
if ( str != NULL ) {
strcpy( currentmap, str );
Q_strncpyz( currentmap, str, sizeof( currentmap ) );
MRU_AddFile( str );
Map_SaveFile( str, false ); // ignore region
}
@ -4403,8 +4403,8 @@ void MainFrame::OnFileExportmap(){
char buf[NAME_MAX];
if ( !g_pGameDescription->noMapsInHome ) {
strcpy( buf, g_qeglobals.m_strHomeMaps.GetBuffer() );
strcat( buf, "maps/" );
Q_strncpyz( buf, g_qeglobals.m_strHomeMaps.GetBuffer(), sizeof( buf ) );
strncat( buf, "maps/", sizeof( buf ) );
}
else {
buf[0] = '\0';
@ -4422,8 +4422,8 @@ void MainFrame::OnFileSaveregion(){
char buf[NAME_MAX];
if ( !g_pGameDescription->noMapsInHome ) {
strcpy( buf, g_qeglobals.m_strHomeMaps.GetBuffer() );
strcat( buf, "maps/" );
Q_strncpyz( buf, g_qeglobals.m_strHomeMaps.GetBuffer(), sizeof( buf ) );
strncat( buf, "maps/", sizeof( buf ) );
}
else {
buf[0] = '\0';
@ -5801,11 +5801,11 @@ void MainFrame::OnTexturesLoad(){
// FIXME
// check if that works with fs_game (I suspect some more design is needed)
// see how this is done in 1.2?
strcpy( def_path, g_pGameDescription->mEnginePath.GetBuffer() );
strcat( def_path, g_pGameDescription->mBaseGame.GetBuffer() );
strcat( def_path, "/" );
Q_strncpyz( def_path, g_pGameDescription->mEnginePath.GetBuffer(), sizeof( def_path ) );
strncat( def_path, g_pGameDescription->mBaseGame.GetBuffer(), sizeof( def_path ) );
strncat( def_path, "/", sizeof( def_path ) );
char *dir = dir_dialog( m_pWidget, _( "Load textures from path" ), def_path );
gchar *dir = dir_dialog( m_pWidget, _( "Load textures from path" ), def_path );
if ( dir != NULL ) {
// very uncertain task, let's hope the guy pointed to somewhere below the dir we gave him
@ -5816,7 +5816,7 @@ void MainFrame::OnTexturesLoad(){
}
char *pouic = MAX( strrchr( dir, '/' ),strrchr( dir, '\\' ) );
if ( pouic ) {
strcpy( texture_directory, pouic + 1 );
Q_strncpyz( texture_directory, pouic + 1, 128 );
Sys_Printf( "Loading '%s'\n", texture_directory );
Texture_ShowDirectory();
}

View file

@ -549,7 +549,7 @@ void Map_LoadFile( const char *filename ){
// used when conversion between standard map format and BP format is required and the user cancels the process
g_bCancel_Map_LoadFile = false;
strcpy( currentmap, filename );
Q_strncpyz( currentmap, filename, sizeof( currentmap ) );
g_bScreenUpdates = false; // leo: avoid redraws while loading the map (see fenris:1952)
@ -778,9 +778,9 @@ void Map_SaveFile( const char *filename, qboolean use_region ){
char backup[1024];
// rename current to .bak
strcpy( backup, filename );
Q_strncpyz( backup, filename, sizeof( backup ) );
StripExtension( backup );
strcat( backup, ".bak" );
strncat( backup, ".bak", sizeof( backup ) );
unlink( backup );
rename( filename, backup );
}
@ -1272,7 +1272,7 @@ void MemFile_fprintf( MemStream* pMemFile, const char* pText, ... ){
char Buffer[4096];
va_list args;
va_start( args,pText );
vsprintf( Buffer, pText, args );
vsnprintf( Buffer, sizeof( Buffer ), pText, args );
pMemFile->Write( Buffer, strlen( Buffer ) );
}

View file

@ -115,7 +115,7 @@ bool radCreateDirectory( const char *directory, bool fatal_on_error ) {
int GetFullPathName( const char *lpFileName, int nBufferLength, char *lpBuffer, char **lpFilePart ){
if ( lpFileName[0] == '/' ) {
strcpy( lpBuffer, lpFileName );
Q_strncpyz( lpBuffer, lpFileName, nBufferLength );
*lpFilePart = strrchr( lpBuffer, '/' );
return strlen( lpBuffer );
}
@ -124,9 +124,9 @@ int GetFullPathName( const char *lpFileName, int nBufferLength, char *lpBuffer,
return 0;
}
strcat( lpBuffer, "/" );
strncat( lpBuffer, "/", nBufferLength );
*lpFilePart = lpBuffer + strlen( lpBuffer );
strcat( lpBuffer, lpFileName );
strncat( lpBuffer, lpFileName, nBufferLength );
char *scr = lpBuffer, *dst = lpBuffer;
for ( int i = 0; ( i < nBufferLength ) && ( *scr != 0 ); i++ )

View file

@ -33,7 +33,7 @@
#endif
//#include "qe3.h"
int QERApp_EClassScanDir( char *path, void* hPlug ){
int QERApp_EClassScanDir( const char *path, void* hPlug ){
char temp[NAME_MAX];
char filebase[NAME_MAX];
char filename[NAME_MAX];
@ -43,7 +43,7 @@ int QERApp_EClassScanDir( char *path, void* hPlug ){
struct dirent *dirlist;
QE_ConvertDOSToUnixName( temp, path );
strcpy( filebase, path );
Q_strncpyz( filebase, path, sizeof( filebase ) );
s = filebase + strlen( filebase ) - 1;
while ( *s != '\\' && *s != '/' && s != filebase )
s--;

View file

@ -493,7 +493,11 @@ CPluginSlot::~CPluginSlot(){
void CPluginSlot::Init(){
CString str = mpTable->m_pfnQERPlug_GetCommandList();
char cTemp[1024];
strcpy( cTemp, str );
Q_strncpyz( cTemp, str, sizeof( cTemp ) );
if( str.GetLength() > sizeof( cTemp ) - 1 )
{
Sys_Printf( "WARNING: Temporary buffer is too small in CPluginSlot::Init\n" );
}
char* token = strtok( cTemp, ",;" );
if ( token && *token == ' ' ) {
while ( *token == ' ' )
@ -1088,7 +1092,7 @@ _QERFaceData* WINAPI QERApp_GetFaceData( void* pv, int nFaceIndex ){
face.m_fShift[0] = f->texdef.shift[0];
face.m_fShift[1] = f->texdef.shift[1];
}
strcpy( face.m_TextureName, f->texdef.GetName() );
Q_strncpyz( face.m_TextureName, f->texdef.GetName(), sizeof( face.m_TextureName ) );
VectorCopy( f->planepts[0], face.m_v1 );
VectorCopy( f->planepts[1], face.m_v2 );
VectorCopy( f->planepts[2], face.m_v3 );
@ -1296,7 +1300,7 @@ char* WINAPI QERApp_GetTexture( int nIndex ){
break;
}
if ( n == nIndex ) {
strcpy( name, pShader->getName() );
Q_strncpyz( name, pShader->getName(), sizeof( name ) );
return name;
}
n++;
@ -1306,7 +1310,7 @@ char* WINAPI QERApp_GetTexture( int nIndex ){
char* WINAPI QERApp_GetCurrentTexture(){
static char current_tex[1024];
strcpy( current_tex,g_qeglobals.d_texturewin.texdef.GetName() );
Q_strncpyz( current_tex, g_qeglobals.d_texturewin.texdef.GetName(), sizeof( current_tex ) );
return current_tex;
}
@ -1516,7 +1520,7 @@ int QERApp_ScriptLine(){
// we save the map and return the name .. either .map or .reg to support region compiling
char* QERApp_GetMapName(){
static char name[PATH_MAX];
SaveWithRegion( name );
SaveWithRegion( name, sizeof( name ) );
return name;
}

View file

@ -4755,7 +4755,7 @@ void Patch_AdjustSelected( bool bInsert, bool bColumn, bool bFlag ){
strategies that call here too much are known to be slow
patch 84 to bug 253 adds an additionnal check for textures/
*/
void CheckName( patchMesh_t *p, char *pname ){
void CheckName( patchMesh_t *p, char *pname, size_t length ){
if ( strncmp( p->pShader->getName(), "textures/", 9 ) != 0 ) {
p->pShader = QERApp_Shader_ForName( SHADER_NOT_FOUND );
}
@ -4766,12 +4766,12 @@ void CheckName( patchMesh_t *p, char *pname ){
sprintf( Msg1, "Can't save texture with spaces in name. Rename %s\nNOTE: This message may popup several times .. once for each buggy face detected.", p->pShader->getName() );
Sys_Printf( "%s\n", Msg1 );
gtk_MessageBox( g_pParentWnd->m_pWidget, Msg1, "Error saving map", MB_OK );
strcpy( pname, SHADER_NOT_FOUND );
Q_strncpyz( pname, SHADER_NOT_FOUND, length );
p->pShader = QERApp_Shader_ForName( SHADER_NOT_FOUND );
p->d_texture = p->pShader->getTexture();
return;
}
strcpy( pname, p->pShader->getName() + 9 ); // remove "textures/"
Q_strncpyz( pname, p->pShader->getName() + 9, length ); // remove "textures/"
}
/*
@ -4784,7 +4784,7 @@ void Patch_Write( patchMesh_t *p, MemStream *file ){
MemFile_fprintf( file, " {\n patchDef2\n {\n" );
CheckName( p, pname );
CheckName( p, pname, sizeof( pname ) );
MemFile_fprintf( file, " %s\n", pname );
MemFile_fprintf( file, " ( %i %i %i %i %i ) \n", p->width, p->height, p->contents, p->flags, p->value );
@ -4823,7 +4823,7 @@ void Patch_Write( patchMesh_t *p, FILE *file ){
fprintf( file, " {\n patchDef2\n {\n" );
{
CheckName( p, pname );
CheckName( p, pname, sizeof( pname ) );
fprintf( file, " %s\n", pname );
fprintf( file, " ( %i %i %i %i %i ) \n", p->width, p->height, p->contents, p->flags, p->value );
}

View file

@ -72,9 +72,9 @@ void CPointfile::GenerateDisplayList(){
void Pointfile_Delete( void ){
char name[1024];
strcpy( name, currentmap );
Q_strncpyz( name, currentmap, sizeof( name ) );
StripExtension( name );
strcat( name, ".lin" );
strncat( name, ".lin", sizeof( name ) );
remove( name );
}
@ -120,14 +120,14 @@ void Pointfile_Prev( void ){
void WINAPI Pointfile_Check( void ){
char name[1024];
int size;
char *data;
char *text;
gchar *data;
gchar *text;
int line = 1;
vec3_t v;
strcpy( name, currentmap );
Q_strncpyz( name, currentmap, sizeof( name ) );
StripExtension( name );
strcat( name, ".lin" );
strncat( name, ".lin", sizeof( name ) );
size = vfsLoadFullPathFile( name, (void**)&data );
if ( size <= 0 ) {

View file

@ -523,7 +523,7 @@ static void OnBtnBrowseprefab( GtkWidget *widget, gpointer data ){
if ( strlen( path ) == 0 ) {
path = g_strGameToolsPath;
}
char *dir = dir_dialog( g_PrefsDlg.GetWidget(), _( "Set prefab path" ), path );
gchar *dir = dir_dialog( g_PrefsDlg.GetWidget(), _( "Set prefab path" ), path );
dlg->UpdateData( TRUE );
if ( dir != NULL ) {
@ -729,9 +729,9 @@ CGameDescription::CGameDescription( xmlDocPtr pDoc, const Str &GameFile ){
{
char full[PATH_MAX];
#ifdef _WIN32
_fullpath( full, prop, PATH_MAX );
_fullpath( full, prop, sizeof( full ) );
#else
strncpy( full, prop, PATH_MAX );
Q_strncpyz( full, prop, sizeof( full ) );
#endif
xmlFree( prop );
prop = NULL;
@ -822,9 +822,9 @@ CGameDescription::CGameDescription( xmlDocPtr pDoc, const Str &GameFile ){
if ( prop != NULL ) {
char full[PATH_MAX];
#ifdef _WIN32
_fullpath( full, prop, PATH_MAX );
_fullpath( full, prop, sizeof( full ) );
#else
strncpy( full, prop, PATH_MAX );
Q_strncpyz( full, prop, sizeof( full ) );
#endif
xmlFree( prop );
prop = NULL;
@ -844,7 +844,7 @@ CGameDescription::CGameDescription( xmlDocPtr pDoc, const Str &GameFile ){
// if engine path was not specified in the .game, it implies we can guess it from the gametools path
// on win32, and for most game package, the gametools are installed with the game
char aux_path[PATH_MAX]; // aux
strcpy( aux_path, mGameToolsPath.GetBuffer() );
Q_strncpyz( aux_path, mGameToolsPath.GetBuffer(), sizeof( aux_path ) );
if ( ( aux_path[ strlen( aux_path ) - 1 ] == '/' ) || ( aux_path[ strlen( aux_path ) - 1 ] == '\\' ) ) {
aux_path[strlen( aux_path ) - 1] = '\0'; // strip ending '/' if any
}
@ -3272,7 +3272,7 @@ void CGameInstall::OnBtnBrowseEngine( GtkWidget *widget, gpointer data ) {
Sys_Printf( "OnBtnBrowseEngine\n" );
CGameInstall* i = static_cast<CGameInstall*>( data );
char *dir = dir_dialog( i->m_pWidget, _( "Select game directory" ), NULL );
gchar *dir = dir_dialog( i->m_pWidget, _( "Select game directory" ), NULL );
i->UpdateData( TRUE );
@ -3287,7 +3287,7 @@ void CGameInstall::OnBtnBrowseExecutables( GtkWidget *widget, gpointer data ) {
Sys_Printf( "OnBtnBrowseExecutables\n" );
CGameInstall* i = static_cast<CGameInstall*>( data );
char *dir = dir_dialog( i->m_pWidget, _( "Select executables directory" ), NULL );
gchar *dir = dir_dialog( i->m_pWidget, _( "Select executables directory" ), NULL );
i->UpdateData( TRUE );

View file

@ -46,7 +46,7 @@
// =============================================================================
// Static functions
bool read_var( const char *filename, const char *section, const char *key, char *value ){
bool read_var( const char *filename, const char *section, const char *key, char *value, size_t length ){
char line[1024], *ptr;
FILE *rc;
@ -83,7 +83,7 @@ bool read_var( const char *filename, const char *section, const char *key, char
line[strlen( line ) - 1] = '\0';
if ( strcmp( line, key ) == 0 ) {
strcpy( value, ptr + 1 );
Q_strncpyz( value, ptr + 1, length );
fclose( rc );
if ( value[strlen( value ) - 1] == 10 || value[strlen( value ) - 1] == 13 || value[strlen( value ) - 1] == 32 ) {
@ -254,7 +254,7 @@ bool profile_load_buffer( const char * rc_path, const char *name, void *buffer,
int WINAPI profile_load_int( const char *filename, const char *section, const char *key, int default_value ){
char value[1024];
if ( read_var( filename, section, key, value ) ) {
if ( read_var( filename, section, key, value, sizeof( value ) ) ) {
return atoi( value );
}
else{
@ -265,7 +265,7 @@ int WINAPI profile_load_int( const char *filename, const char *section, const ch
float WINAPI profile_load_float( const char *filename, const char *section, const char *key, float default_value ){
char value[1024];
if ( read_var( filename, section, key, value ) ) {
if ( read_var( filename, section, key, value, sizeof( value ) ) ) {
return atof( value );
}
else{
@ -277,7 +277,7 @@ char* WINAPI profile_load_string( const char *filename, const char *section, con
static Str ret;
char value[1024];
if ( read_var( filename, section, key, value ) ) {
if ( read_var( filename, section, key, value, sizeof( value ) ) ) {
ret = value;
}
else{

View file

@ -133,7 +133,7 @@ char *ExpandReletivePath( char *p ){
char *copystring( char *s ){
char *b;
b = (char*)malloc( strlen( s ) + 1 );
strcpy( b,s );
strcpy( b, s );
return b;
}
@ -282,7 +282,7 @@ int BuildShortPathName( const char* pPath, char* pBuffer, int nBufferLen ){
int nResult = GetFullPathName( pPath, nBufferLen, pBuffer, &pFile );
nResult = GetShortPathName( pPath, pBuffer, nBufferLen );
if ( nResult == 0 ) {
strcpy( pBuffer, pPath ); // Use long filename
Q_strncpyz( pBuffer, pPath, nBufferLen ); // Use long filename
}
return nResult;
}
@ -354,7 +354,7 @@ void HandleXMLError( void* ctxt, const char* text, ... ){
static char buf[32768];
va_start( argptr,text );
vsprintf( buf, text, argptr );
vsnprintf( buf, sizeof( buf ), text, argptr );
Sys_FPrintf( SYS_ERR, "XML %s\n", buf );
va_end( argptr );
}
@ -654,9 +654,9 @@ bool QE_LoadProject( const char *projectfile ){
}
// create the writable project file path
strcpy( buf, g_qeglobals.m_strHomeGame.GetBuffer() );
strcat( buf, g_pGameDescription->mBaseGame.GetBuffer() );
strcat( buf, G_DIR_SEPARATOR_S "scripts" G_DIR_SEPARATOR_S );
Q_strncpyz( buf, g_qeglobals.m_strHomeGame.GetBuffer(), sizeof( buf ) );
strncat( buf, g_pGameDescription->mBaseGame.GetBuffer(), sizeof( buf ) );
strncat( buf, G_DIR_SEPARATOR_S "scripts" G_DIR_SEPARATOR_S, sizeof( buf ) );
// while the filename is already in use, increment the number we add to the end
int counter = 0;
char pUser[PATH_MAX];
@ -666,7 +666,7 @@ bool QE_LoadProject( const char *projectfile ){
counter++;
if ( access( pUser, R_OK ) != 0 ) {
// this is the one
strcpy( buf, pUser );
Q_strncpyz( buf, pUser, sizeof( buf ) );
break;
}
}
@ -1393,7 +1393,7 @@ void buffer_write_escaped_mnemonic( char* buffer, const char* string ){
}
static void MRU_SetText( int index, const char *filename ){
strcpy( MRU_filenames[index], filename );
Q_strncpyz( MRU_filenames[index], filename, sizeof( MRU_filenames[index] ) );
char mnemonic[PATH_MAX * 2 + 4];
mnemonic[0] = '_';
@ -1531,9 +1531,9 @@ void ProjectDialog(){
* store it in buffer.
*/
strcpy( buffer, g_qeglobals.m_strHomeGame.GetBuffer() );
strcat( buffer, g_pGameDescription->mBaseGame.GetBuffer() );
strcat( buffer, "/scripts/" );
Q_strncpyz( buffer, g_qeglobals.m_strHomeGame.GetBuffer(), sizeof( buffer ) );
strncat( buffer, g_pGameDescription->mBaseGame.GetBuffer(), sizeof( buffer ) );
strncat( buffer, "/scripts/", sizeof( buffer ) );
// Display the Open dialog box
filename = file_dialog( NULL, TRUE, _( "Open File" ), buffer, "project" );
@ -1590,7 +1590,7 @@ void FillBSPMenu(){
if ( g_qeglobals.bBSPFrontendPlugin ) {
CString str = g_BSPFrontendTable.m_pfnGetBSPMenu();
char cTemp[1024];
strcpy( cTemp, str );
Q_strncpyz( cTemp, str, sizeof( cTemp ) );
char* token = strtok( cTemp, ",;" );
if ( token && *token == ' ' ) {
while ( *token == ' ' )

View file

@ -276,7 +276,7 @@ int WINAPI profile_load_int( const char *filename, const char *section, const ch
float WINAPI profile_load_float( const char *filename, const char *section, const char *key, float default_value );
char* WINAPI profile_load_string( const char *filename, const char *section, const char *key, const char *default_value );
// used in the command map code
bool read_var( const char *filename, const char *section, const char *key, char *value );
bool read_var( const char *filename, const char *section, const char *key, char *value, size_t length );
//
// entityw.c
@ -796,7 +796,7 @@ extern void CheckBspProcess();
extern void QE_CountBrushesAndUpdateStatusBar();
extern void QE_CheckAutoSave();
extern qtexture_t *current_texture;
extern void SaveWithRegion( char *name ); // save the current map, sets the map name in the name buffer (deals with regioning)
extern void SaveWithRegion( char *name, size_t length ); // save the current map, sets the map name in the name buffer (deals with regioning)
extern void RunBsp( char *command );
extern void Map_Snapshot();
extern void WXY_Print();

View file

@ -114,7 +114,7 @@
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<AdditionalIncludeDirectories>$(SolutionDir)\include;$(SolutionDir)\libs;$(SolutionDir)\..\GtkRadiant-libs\jpeg-9a;$(SolutionDir)\..\GtkRadiant-libs\glib-2.34.3\lib\glib-2.0\include;$(SolutionDir)\..\GtkRadiant-libs\glib-2.34.3\include\glib-2.0;$(SolutionDir)\..\GtkRadiant-libs\gtk-3.6.4\include\gtk-3.0;$(SolutionDir)\..\GtkRadiant-libs\pango-1.30.1\include\pango-1.0;$(SolutionDir)\..\GtkRadiant-libs\cairo-1.10.2\include\cairo;$(SolutionDir)\..\GtkRadiant-libs\gdk-pixbuf-2.26.5\include\gdk-pixbuf-2.0;$(SolutionDir)\..\GtkRadiant-libs\atk-2.6.0\include\atk-1.0;$(SolutionDir)\..\GtkRadiant-libs\STLport-5.2.1\stlport;$(SolutionDir)\..\GtkRadiant-libs\gtkglext-1.3\include;$(SolutionDir)\..\GtkRadiant-libs\libxml2-2.9.2\include;$(SolutionDir)\..\GtkRadiant-libs\lpng1618;$(SolutionDir)\..\GtkRadiant-libs\libiconv-1.14\woe32dll\libiconv;$(SolutionDir)\..\GtkRadiant-libs\gettext-0.19.5.1\include;$(SolutionDir)\..\GtkRadiant-libs\gtkglext-1.3;$(SolutionDir)\..\GtkRadiant-libs\fontconfig-2.10.2\include;$(SolutionDir)\..\GtkRadiant-libs\freetype-2.4.11\include;$(SolutionDir)\..\GtkRadiant-libs\freetype-2.4.11\include\freetype2;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;_STLP_DONT_USE_EXCEPTIONS;_STLP_NO_NAMESPACES;_STLP_NO_IOSTREAMS;_WIN32;%(PreprocessorDefinitions);_STLP_DONT_USE_EXCEPTIONS;_STLP_NO_NAMESPACES;_STLP_NO_IOSTREAMS;_WIN32</PreprocessorDefinitions>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;_STLP_DONT_USE_EXCEPTIONS;_STLP_NO_NAMESPACES;_STLP_NO_IOSTREAMS;_WIN32;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<PrecompiledHeader />
<WarningLevel>Level3</WarningLevel>

View file

@ -60,7 +60,7 @@ int WINAPI QERApp_GetFaceInfo( int iface, _QERFaceData *pFaceData, winding_t *pW
return 0;
}
face_t *selFace = reinterpret_cast<face_t*>( g_ptrSelectedFaces.GetAt( iface ) );
strcpy( pFaceData->m_TextureName, selFace->texdef.GetName() );
Q_strncpyz( pFaceData->m_TextureName, selFace->texdef.GetName(), sizeof( pFaceData->m_TextureName ) );
VectorCopy( selFace->planepts[0], pFaceData->m_v1 );
VectorCopy( selFace->planepts[1], pFaceData->m_v2 );
VectorCopy( selFace->planepts[2], pFaceData->m_v3 );

View file

@ -1035,7 +1035,7 @@ void SurfaceDlg::GetTexMods(){
else
{
strcpy( buffer, "textures/" );
strcpy( buffer + 9, text );
Q_strncpyz( buffer + 9, text, sizeof( buffer ) - 9 );
pt->SetName( buffer );
}

View file

@ -494,7 +494,7 @@ void BuildShaderList(){
}
if ( g_pGameDescription->mGameFile != "hl.game" ) {
strcpy( filename, g_pGameDescription->mShaderlist.GetBuffer() );
Q_strncpyz( filename, g_pGameDescription->mShaderlist.GetBuffer(), sizeof( filename ) );
count = vfsGetFileCount( filename, 0 );
if ( count == 0 ) {
Sys_FPrintf( SYS_ERR, "Couldn't find '%s'\n", g_pGameDescription->mShaderlist.GetBuffer() );
@ -1135,7 +1135,7 @@ void Texture_ShowStartupShaders(){
int nLen;
GSList *shaderfiles = NULL;
strcpy( filename, g_pGameDescription->mShaderlist.GetBuffer() );
Q_strncpyz( filename, g_pGameDescription->mShaderlist.GetBuffer(), sizeof( filename ) );
count = vfsGetFileCount( filename, 0 );
if ( count == 0 ) {
Sys_FPrintf( SYS_ERR, "Couldn't find '%s'\n", g_pGameDescription->mShaderlist.GetBuffer() );
@ -1171,7 +1171,7 @@ void Texture_ShowStartupShaders(){
if ( !found ) {
shaderfiles = g_slist_append( l_shaderfiles, strdup( dirstring ) );
strcpy( texture_directory, dirstring );
Q_strncpyz( texture_directory, dirstring, sizeof( texture_directory ) );
Texture_ShowDirectory();
nLen++;
}

View file

@ -191,7 +191,7 @@ static void saxWarning( void *ctx, const char *msg, ... ){
va_list args;
va_start( args, msg );
vsprintf( saxMsgBuffer, msg, args );
vsnprintf( saxMsgBuffer, sizeof( saxMsgBuffer ), msg, args );
va_end( args );
Sys_FPrintf( SYS_WRN, "XML warning: %s\n", saxMsgBuffer );
}
@ -201,7 +201,7 @@ static void saxError( void *ctx, const char *msg, ... ){
va_list args;
va_start( args, msg );
vsprintf( saxMsgBuffer, msg, args );
vsnprintf( saxMsgBuffer, sizeof( saxMsgBuffer ), msg, args );
va_end( args );
Sys_FPrintf( SYS_ERR, "XML error: %s\n", saxMsgBuffer );
}
@ -212,7 +212,7 @@ static void saxFatal( void *ctx, const char *msg, ... ){
va_list args;
va_start( args, msg );
vsprintf( buffer, msg, args );
vsnprintf( buffer, sizeof( buffer ), msg, args );
va_end( args );
Sys_FPrintf( SYS_ERR, "XML fatal error: %s\n", buffer );
}

View file

@ -157,7 +157,7 @@ void ASE_Load( const char *filename, qboolean verbose, qboolean grabAnims ){
fclose( fp );
strcpy( gl_filename, filename );
Q_strncpyz( gl_filename, filename, sizeof( gl_filename ) );
ASE_Process();
}
@ -243,8 +243,8 @@ polyset_t *ASE_GetSurfaceAnimation( int which, int *pNumFrames, int skipFrameSta
}
}
strcpy( psets[f].name, pObject->name );
strcpy( psets[f].materialname, ase.materials[pObject->materialRef].name );
Q_strncpyz( psets[f].name, pObject->name, sizeof( psets[f].name ) );
Q_strncpyz( psets[f].materialname, ase.materials[pObject->materialRef].name, sizeof( psets[f].materialname ) );
psets[f].triangles = calloc( sizeof( triangle_t ) * pObject->anim.frames[i].numFaces, 1 );
psets[f].numtriangles = pObject->anim.frames[i].numFaces;
@ -415,7 +415,7 @@ static void ASE_KeyMAP_DIFFUSE( const char *token ){
char filename[1024];
int i = 0, count;
strcpy( filename, gl_filename );
Q_strncpyz( filename, gl_filename, sizeof( filename ) );
if ( !strcmp( token, "*BITMAP" ) ) {
ASE_GetToken( qfalse );
@ -423,7 +423,7 @@ static void ASE_KeyMAP_DIFFUSE( const char *token ){
// the purpose of this whole chunk of code below is to extract the relative path
// from a full path in the ASE
strcpy( bitmap, s_token + 1 );
Q_strncpyz( bitmap, s_token + 1, sizeof( bitmap ) );
if ( strchr( bitmap, '"' ) ) {
*strchr( bitmap, '"' ) = 0;
}
@ -458,15 +458,17 @@ static void ASE_KeyMAP_DIFFUSE( const char *token ){
break;
}
}
strcpy( bitmap, &bitmap[3] );
Q_strncpyz( bitmap, &bitmap[3], sizeof( bitmap ) );
}
strcat( filename, "/" );
strcat( filename, bitmap );
strcpy( bitmap, filename );
strncat( filename, "/", sizeof( filename ) );
strncat( filename, bitmap, sizeof( filename ) );
Q_strncpyz( bitmap, filename, sizeof( bitmap ) );
}
if ( strstr( bitmap, gamedir ) ) {
strcpy( ase.materials[ase.numMaterials].name, strstr( bitmap, gamedir ) + strlen( gamedir ) );
Q_strncpyz( ase.materials[ase.numMaterials].name,
strstr( bitmap, gamedir ) + strlen( gamedir ),
sizeof( ase.materials[ase.numMaterials].name ));
Sys_Printf( "material name: \'%s\'\n", strstr( bitmap, gamedir ) + strlen( gamedir ) );
}
else
@ -608,13 +610,13 @@ static void ASE_KeyMESH_TVERTLIST( const char *token ){
ASE_GetToken( qfalse );
ASE_GetToken( qfalse );
strcpy( u, s_token );
Q_strncpyz( u, s_token, sizeof( u ) );
ASE_GetToken( qfalse );
strcpy( v, s_token );
Q_strncpyz( v, s_token, sizeof( v ) );
ASE_GetToken( qfalse );
strcpy( w, s_token );
Q_strncpyz( w, s_token, sizeof( w ) );
pMesh->tvertexes[pMesh->currentVertex].s = atof( u );
pMesh->tvertexes[pMesh->currentVertex].t = 1.0f - atof( v );
@ -724,7 +726,7 @@ static void ASE_KeyGEOMOBJECT( const char *token ){
ASE_GetToken( qtrue );
VERBOSE( ( " %s\n", s_token ) );
strcpy( ase.objects[ase.currentObject].name, s_token + 1 );
Q_strncpyz( ase.objects[ase.currentObject].name, s_token + 1, sizeof( ase.objects[ase.currentObject].name ) );
if ( strchr( ase.objects[ase.currentObject].name, '"' ) ) {
*strchr( ase.objects[ase.currentObject].name, '"' ) = 0;
}

View file

@ -626,20 +626,20 @@ void UnparseEntities( void ) {
continue; // ent got removed
}
strcat( end,"{\n" );
strncat( end, "{\n", sizeof( dentdata ) + dentdata - end );
end += 2;
for ( ep = entities[i].epairs ; ep ; ep = ep->next ) {
strcpy( key, ep->key );
Q_strncpyz( key, ep->key, sizeof( key ) );
StripTrailing( key );
strcpy( value, ep->value );
Q_strncpyz( value, ep->value, sizeof( value ) );
StripTrailing( value );
sprintf( line, "\"%s\" \"%s\"\n", key, value );
strcat( end, line );
snprintf( line, sizeof( line ), "\"%s\" \"%s\"\n", key, value );
strncat( end, line, sizeof( end ) );
end += strlen( line );
}
strcat( end,"}\n" );
strncat( end, "}\n", sizeof( dentdata ) + dentdata - end );
end += 2;
if ( end > buf + MAX_MAP_ENTSTRING ) {

View file

@ -162,7 +162,7 @@ void SetQdirFromPath( const char *path ){
if ( !( path[0] == '/' || path[0] == '\\' || path[1] == ':' ) ) { // path is partial
Q_getwd( temp );
strcat( temp, path );
strncat( temp, path, sizeof( temp ) );
path = temp;
}
@ -211,7 +211,7 @@ void SetQdirFromPath( const char *path ){
Sys_Printf( "gamedir: %s\n", gamedir );
if ( !writedir[0] ) {
strcpy( writedir, gamedir );
Q_strncpyz( writedir, gamedir, sizeof( writedir ) );
}
else if ( writedir[strlen( writedir ) - 1] != '/' ) {
writedir[strlen( writedir )] = '/';
@ -234,10 +234,10 @@ char *ExpandArg( const char *path ){
if ( path[0] != '/' && path[0] != '\\' && path[1] != ':' ) {
Q_getwd( full );
strcat( full, path );
strncat( full, path, sizeof( full ) );
}
else{
strcpy( full, path );
Q_strncpyz( full, path, sizeof( full ) );
}
return full;
}
@ -245,7 +245,7 @@ char *ExpandArg( const char *path ){
char *ExpandPath( const char *path ){
static char full[1024];
if ( path[0] == '/' || path[0] == '\\' || path[1] == ':' ) {
strcpy( full, path );
Q_strncpyz( full, path, sizeof( full ) );
return full;
}
sprintf( full, "%s%s", qdir, path );
@ -294,11 +294,11 @@ void Q_getwd( char *out ){
#ifdef WIN32
_getcwd( out, 256 );
strcat( out, "\\" );
strncat( out, "\\", sizeof( out ) );
#else
// Gef: Changed from getwd() to getcwd() to avoid potential buffer overflow
getcwd( out, 256 );
strcat( out, "/" );
strncat( out, "/", sizeof( out ) );
#endif
while ( out[i] != 0 )
{
@ -698,7 +698,7 @@ void DefaultExtension( char *path, const char *extension ){
src--;
}
strcat( path, extension );
strncat( path, extension, sizeof( path ) );
}
@ -708,9 +708,9 @@ void DefaultPath( char *path, const char *basepath ){
if ( path[ 0 ] == '/' || path[ 0 ] == '\\' ) {
return; // absolute path location
}
strcpy( temp,path );
strcpy( path,basepath );
strcat( path,temp );
Q_strncpyz( temp, path, sizeof( temp ) );
Q_strncpyz( path, basepath, sizeof( path ) );
strncat( path, temp, sizeof( path ) );
}
@ -795,7 +795,7 @@ void ExtractFileExtension( const char *path, char *dest ){
return;
}
strcpy( dest,src );
Q_strncpyz( dest, src, sizeof( dest ) );
}

View file

@ -76,6 +76,12 @@ char *strlower( char *in );
int Q_strncasecmp( const char *s1, const char *s2, int n );
int Q_stricmp( const char *s1, const char *s2 );
void Q_getwd( char *out );
#define Q_strncpyz(_dst, _source, _len) do { strncpy((_dst), (_source), (_len) - 1); (_dst)[(_len) - 1] = 0; } while( 0 )
#if defined(_MSC_VER) && _MSC_VER<1900 && !(defined snprintf)
#define snprintf _snprintf
#endif
int Q_filelength( FILE *f );
int FileTime( const char *path );

View file

@ -216,7 +216,7 @@ void xml_Winding( char *msg, vec3_t p[], int numpoints, qboolean die ){
if ( strlen( buf ) + strlen( smlbuf ) > WINDING_BUFSIZE ) {
break;
}
strcat( buf, smlbuf );
strncat( buf, smlbuf, sizeof( buf ) );
}
winding = xmlNewNode( NULL, "winding" );
@ -316,7 +316,7 @@ void Sys_FPrintf( int flag, const char *format, ... ){
}
va_start( argptr, format );
vsprintf( out_buffer, format, argptr );
vsnprintf( out_buffer, sizeof( out_buffer ), format, argptr );
va_end( argptr );
FPrintf( flag, out_buffer );
@ -327,7 +327,7 @@ void Sys_Printf( const char *format, ... ){
va_list argptr;
va_start( argptr, format );
vsprintf( out_buffer, format, argptr );
vsnprintf( out_buffer, sizeof( out_buffer ), format, argptr );
va_end( argptr );
FPrintf( SYS_STD, out_buffer );
@ -346,7 +346,7 @@ void Error( const char *error, ... ){
va_list argptr;
va_start( argptr,error );
vsprintf( tmp, error, argptr );
vsnprintf( tmp, sizeof( tmp ), error, argptr );
va_end( argptr );
sprintf( out_buffer, "************ ERROR ************\n%s\n", tmp );

View file

@ -103,7 +103,7 @@
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<AdditionalIncludeDirectories>$(SolutionDir)\include;$(SolutionDir)\libs;$(SolutionDir)\..\GtkRadiant-libs\jpeg-9a;$(SolutionDir)\..\GtkRadiant-libs\glib-2.34.3\lib\glib-2.0\include;$(SolutionDir)\..\GtkRadiant-libs\glib-2.34.3\include\glib-2.0;$(SolutionDir)\..\GtkRadiant-libs\gtk-3.6.4\include\gtk-3.0;$(SolutionDir)\..\GtkRadiant-libs\pango-1.30.1\include\pango-1.0;$(SolutionDir)\..\GtkRadiant-libs\cairo-1.10.2\include\cairo;$(SolutionDir)\..\GtkRadiant-libs\gdk-pixbuf-2.26.5\include\gdk-pixbuf-2.0;$(SolutionDir)\..\GtkRadiant-libs\atk-2.6.0\include\atk-1.0;$(SolutionDir)\..\GtkRadiant-libs\STLport-5.2.1\stlport;$(SolutionDir)\..\GtkRadiant-libs\gtkglext-1.3\include;$(SolutionDir)\..\GtkRadiant-libs\libxml2-2.9.2\include;$(SolutionDir)\..\GtkRadiant-libs\lpng1618;$(SolutionDir)\..\GtkRadiant-libs\libiconv-1.14\woe32dll\libiconv;$(SolutionDir)\..\GtkRadiant-libs\gettext-0.19.5.1\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions);_STLP_DONT_USE_EXCEPTIONS;_STLP_NO_NAMESPACES;_STLP_NO_IOSTREAMS;_WIN32;inline=__inline;_STLP_DONT_USE_EXCEPTIONS;_STLP_NO_NAMESPACES;_STLP_NO_IOSTREAMS;_WIN32</PreprocessorDefinitions>
<PreprocessorDefinitions>WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions);_STLP_DONT_USE_EXCEPTIONS;_STLP_NO_NAMESPACES;_STLP_NO_IOSTREAMS;_WIN32;inline=__inline</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<PrecompiledHeader />
<WarningLevel>Level3</WarningLevel>

View file

@ -63,7 +63,7 @@ void AddScriptToStack( const char *filename, int index ){
if ( script == &scriptstack[MAX_INCLUDES] ) {
Error( "script file exceeded MAX_INCLUDES" );
}
strcpy( script->filename, ExpandPath( filename ) );
Q_strncpyz( script->filename, ExpandPath( filename ), sizeof( script->filename ) );
size = vfsLoadFile( script->filename, (void **)&script->buffer, index );
@ -111,7 +111,7 @@ void ParseFromMemory( char *buffer, int size ){
if ( script == &scriptstack[MAX_INCLUDES] ) {
Error( "script file exceeded MAX_INCLUDES" );
}
strcpy( script->filename, "memory buffer" );
Q_strncpyz( script->filename, "memory buffer", sizeof( script->filename ) );
script->buffer = buffer;
script->line = 1;

View file

@ -151,7 +151,7 @@ void TRI_LoadPolysets( const char *filename, polyset_t **ppPSET, int *numpsets )
} while ( name[i] != '\0' );
if ( i != 0 ) {
strncpy( pPSET[pset].name, name, sizeof( pPSET[pset].name ) - 1 );
Q_strncpyz( pPSET[pset].name, name, sizeof( pPSET[pset].name ) );
}
else{
strcpy( pPSET[pset].name, "(unnamed)" );
@ -202,7 +202,7 @@ void TRI_LoadPolysets( const char *filename, polyset_t **ppPSET, int *numpsets )
} while ( name[i] != '\0' );
if ( i != 0 ) {
strncpy( pPSET[pset].name, name, sizeof( pPSET[pset].name ) - 1 );
Q_strncpyz( pPSET[pset].name, name, sizeof( pPSET[pset].name ) );
}
else{
strcpy( pPSET[pset].name, "(unnamed)" );

View file

@ -85,11 +85,11 @@ static gboolean g_bUsePak = TRUE;
// =============================================================================
// Static functions
static void vfsAddSlash( char *str ){
static void vfsAddSlash( char *str, size_t length ){
int n = strlen( str );
if ( n > 0 ) {
if ( str[n - 1] != '\\' && str[n - 1] != '/' ) {
strcat( str, "/" );
strncat( str, "/", length );
}
}
}
@ -176,9 +176,9 @@ void vfsInitDirectory( const char *path ){
Sys_Printf( "VFS Init: %s\n", path );
strcpy( g_strDirs[g_numDirs], path );
Q_strncpyz( g_strDirs[g_numDirs], path, sizeof( g_strDirs[g_numDirs] ) );
vfsFixDOSName( g_strDirs[g_numDirs] );
vfsAddSlash( g_strDirs[g_numDirs] );
vfsAddSlash( g_strDirs[g_numDirs], sizeof( g_strDirs[g_numDirs] ) );
g_numDirs++;
if ( g_bUsePak ) {
@ -234,7 +234,7 @@ int vfsGetFileCount( const char *filename ){
char fixed[NAME_MAX], tmp[NAME_MAX];
GSList *lst;
strcpy( fixed, filename );
Q_strncpyz( fixed, filename, sizeof( fixed ) );
vfsFixDOSName( fixed );
g_strdown( fixed );
@ -249,8 +249,8 @@ int vfsGetFileCount( const char *filename ){
for ( i = 0; i < g_numDirs; i++ )
{
strcpy( tmp, g_strDirs[i] );
strcat( tmp, fixed );
Q_strncpyz( tmp, g_strDirs[i], sizeof( tmp ) );
strncat( tmp, fixed, sizeof( tmp ) );
if ( access( tmp, R_OK ) == 0 ) {
count++;
}
@ -294,14 +294,14 @@ int vfsLoadFile( const char *filename, void **bufferptr, int index ){
}
*bufferptr = NULL;
strcpy( fixed, filename );
Q_strncpyz( fixed, filename, sizeof( fixed ) );
vfsFixDOSName( fixed );
g_strdown( fixed );
for ( i = 0; i < g_numDirs; i++ )
{
strcpy( tmp, g_strDirs[i] );
strcat( tmp, filename );
Q_strncpyz( tmp, g_strDirs[i], sizeof( tmp ) );
strncat( tmp, filename, sizeof( tmp ) );
if ( access( tmp, R_OK ) == 0 ) {
if ( count == index ) {
long len;

View file

@ -584,19 +584,19 @@ void _3DS_LoadPolysets( const char *filename, polyset_t **ppPSET, int *numpsets,
pPSET[i].triangles = ptri;
pPSET[i].numtriangles = pTO->numFaces;
strcpy( pPSET[i].name, _3ds.editChunk.pNamedObjects[i].name );
Q_strncpyz( pPSET[i].name, _3ds.editChunk.pNamedObjects[i].name, sizeof( pPSET[i].name ) );
strcpy( matnamebuf, filename );
Q_strncpyz( matnamebuf, filename, sizeof( matnamebuf ) );
if ( strrchr( matnamebuf, '/' ) ) {
*( strrchr( matnamebuf, '/' ) + 1 ) = 0;
}
strcat( matnamebuf, pTO->pMeshMaterialGroups[0].name );
strncat( matnamebuf, pTO->pMeshMaterialGroups[0].name, sizeof( matnamebuf ) );
if ( strstr( matnamebuf, gamedir ) ) {
strcpy( pPSET[i].materialname, strstr( matnamebuf, gamedir ) + strlen( gamedir ) );
Q_strncpyz( pPSET[i].materialname, strstr( matnamebuf, gamedir ) + strlen( gamedir ), sizeof( pPSET[i].materialname ) );
}
else{
strcpy( pPSET[i].materialname, pTO->pMeshMaterialGroups[0].name );
Q_strncpyz( pPSET[i].materialname, pTO->pMeshMaterialGroups[0].name, sizeof( pPSET[i].materialname ) );
}
assert( pPSET[i].numtriangles < POLYSET_MAXTRIANGLES );

View file

@ -118,7 +118,7 @@
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<AdditionalIncludeDirectories>$(SolutionDir)\tools\quake3\common;$(SolutionDir)\include;$(SolutionDir)\libs;$(SolutionDir)\..\GtkRadiant-libs\jpeg-9a;$(SolutionDir)\..\GtkRadiant-libs\glib-2.34.3\lib\glib-2.0\include;$(SolutionDir)\..\GtkRadiant-libs\glib-2.34.3\include\glib-2.0;$(SolutionDir)\..\GtkRadiant-libs\gtk-3.6.4\include\gtk-3.0;$(SolutionDir)\..\GtkRadiant-libs\pango-1.30.1\include\pango-1.0;$(SolutionDir)\..\GtkRadiant-libs\cairo-1.10.2\include\cairo;$(SolutionDir)\..\GtkRadiant-libs\gdk-pixbuf-2.26.5\include\gdk-pixbuf-2.0;$(SolutionDir)\..\GtkRadiant-libs\atk-2.6.0\include\atk-1.0;$(SolutionDir)\..\GtkRadiant-libs\STLport-5.2.1\stlport;$(SolutionDir)\..\GtkRadiant-libs\gtkglext-1.3\include;$(SolutionDir)\..\GtkRadiant-libs\libxml2-2.9.2\include;$(SolutionDir)\..\GtkRadiant-libs\lpng1618;$(SolutionDir)\..\GtkRadiant-libs\libiconv-1.14\woe32dll\libiconv;$(SolutionDir)\..\GtkRadiant-libs\gettext-0.19.5.1\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>NDEBUG;_CRT_SECURE_NO_WARNINGS;_STLP_DONT_USE_EXCEPTIONS;_STLP_NO_NAMESPACES;_STLP_NO_IOSTREAMS;_WIN32;inline=__inline;%(PreprocessorDefinitions);_STLP_DONT_USE_EXCEPTIONS;_STLP_NO_NAMESPACES;_STLP_NO_IOSTREAMS;_WIN32</PreprocessorDefinitions>
<PreprocessorDefinitions>NDEBUG;_CRT_SECURE_NO_WARNINGS;_STLP_DONT_USE_EXCEPTIONS;_STLP_NO_NAMESPACES;_STLP_NO_IOSTREAMS;_WIN32;inline=__inline;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>

View file

@ -75,7 +75,7 @@ static void ProcessAdvertisements( void ) {
else {
if ( numBSPAds < MAX_MAP_ADVERTISEMENTS ) {
bspAds[numBSPAds].cellId = IntForKey( &entities[ i ], "cellId" );
strncpy( bspAds[numBSPAds].model, modelKey, sizeof( bspAds[numBSPAds].model ) );
Q_strncpyz( bspAds[numBSPAds].model, modelKey, sizeof( bspAds[numBSPAds].model ) );
modelKey++;
modelNum = atoi( modelKey );
@ -681,7 +681,7 @@ int BSPMain( int argc, char **argv ){
onlyents = qtrue;
}
else if ( !strcmp( argv[ i ], "-tempname" ) ) {
strcpy( tempSource, argv[ ++i ] );
Q_strncpyz( tempSource, argv[ ++i ], sizeof( tempSource ) );
}
else if ( !strcmp( argv[ i ], "-tmpout" ) ) {
strcpy( outbase, "/tmp" );
@ -857,7 +857,7 @@ int BSPMain( int argc, char **argv ){
}
/* copy source name */
strcpy( source, ExpandArg( argv[ i ] ) );
Q_strncpyz( source, ExpandArg( argv[ i ] ), sizeof( source ) );
StripExtension( source );
/* ydnar: set default sample size */
@ -872,12 +872,12 @@ int BSPMain( int argc, char **argv ){
//% remove( path );
/* expand mapname */
strcpy( name, ExpandArg( argv[ i ] ) );
Q_strncpyz( name, ExpandArg( argv[ i ] ), sizeof( name ) );
if ( strcmp( name + strlen( name ) - 4, ".reg" ) ) {
/* if we are doing a full map, delete the last saved region map */
sprintf( path, "%s.reg", source );
remove( path );
DefaultExtension( name, ".map" ); /* might be .reg */
DefaultExtension( name, ".map", sizeof( name ) ); /* might be .reg */
}
/* if onlyents, just grab the entites and resave */

View file

@ -626,16 +626,16 @@ void UnparseEntities( void ){
}
/* add beginning brace */
strcat( end, "{\n" );
strncat( end, "{\n", sizeof( bspEntData ) + bspEntData - end );
end += 2;
/* walk epair list */
for ( ep = entities[ i ].epairs; ep != NULL; ep = ep->next )
{
/* copy and clean */
strcpy( key, ep->key );
Q_strncpyz( key, ep->key, sizeof( key ) );
StripTrailing( key );
strcpy( value, ep->value );
Q_strncpyz( value, ep->value, sizeof( value ) );
StripTrailing( value );
/* add to buffer */
@ -645,7 +645,7 @@ void UnparseEntities( void ){
}
/* add trailing brace */
strcat( end,"}\n" );
strncat( end, "}\n", sizeof( bspEntData ) + bspEntData - end );
end += 2;
/* check for overflow */

View file

@ -248,7 +248,7 @@ static void ConvertShader( FILE *f, bspShader_t *shader, int shaderNum ){
/* set bitmap filename */
if ( si->shaderImage->filename[ 0 ] != '*' ) {
strcpy( filename, si->shaderImage->filename );
Q_strncpyz( filename, si->shaderImage->filename, sizeof( filename ) );
}
else{
sprintf( filename, "%s.tga", si->shader );

View file

@ -98,7 +98,7 @@ int ExportEntitiesMain( int argc, char **argv ){
/* do some path mangling */
strcpy( source, ExpandArg( argv[ argc - 1 ] ) );
StripExtension( source );
DefaultExtension( source, ".bsp" );
DefaultExtension( source, ".bsp", sizeof( source ) );
/* load the bsp */
Sys_Printf( "Loading %s\n", source );

View file

@ -2257,10 +2257,10 @@ int LightMain( int argc, char **argv ){
/* clean up map name */
strcpy( source, ExpandArg( argv[ i ] ) );
StripExtension( source );
DefaultExtension( source, ".bsp" );
DefaultExtension( source, ".bsp", sizeof( source ) );
strcpy( mapSource, ExpandArg( argv[ i ] ) );
StripExtension( mapSource );
DefaultExtension( mapSource, ".map" );
DefaultExtension( mapSource, ".map", sizeof( mapSource ) );
/* ydnar: set default sample size */
SetDefaultSampleSize( sampleSize );

View file

@ -161,7 +161,7 @@ int ExportLightmapsMain( int argc, char **argv ){
/* do some path mangling */
strcpy( source, ExpandArg( argv[ argc - 1 ] ) );
StripExtension( source );
DefaultExtension( source, ".bsp" );
DefaultExtension( source, ".bsp", sizeof( source ) );
/* load the bsp */
Sys_Printf( "Loading %s\n", source );
@ -196,7 +196,7 @@ int ImportLightmapsMain( int argc, char **argv ){
/* do some path mangling */
strcpy( source, ExpandArg( argv[ argc - 1 ] ) );
StripExtension( source );
DefaultExtension( source, ".bsp" );
DefaultExtension( source, ".bsp", sizeof( source ) );
/* load the bsp */
Sys_Printf( "Loading %s\n", source );

View file

@ -46,7 +46,7 @@ vec_t Random( void ){
}
char *Q_strncpyz( char *dst, const char *src, size_t len ) {
/*char *Q_strncpyz( char *dst, const char *src, size_t len ) {
if ( len == 0 ) {
abort();
}
@ -54,7 +54,7 @@ char *Q_strncpyz( char *dst, const char *src, size_t len ) {
strncpy( dst, src, len );
dst[ len - 1 ] = '\0';
return dst;
}
}*/
char *Q_strcat( char *dst, size_t dlen, const char *src ) {
@ -64,7 +64,8 @@ char *Q_strcat( char *dst, size_t dlen, const char *src ) {
abort(); /* buffer overflow */
}
return Q_strncpyz( dst + n, src, dlen - n );
Q_strncpyz( dst + n, src, dlen - n );
return dst;
}
@ -75,7 +76,8 @@ char *Q_strncat( char *dst, size_t dlen, const char *src, size_t slen ) {
abort(); /* buffer overflow */
}
return Q_strncpyz( dst + n, src, MIN( slen, dlen - n ) );
Q_strncpyz( dst + n, src, MIN( slen, dlen - n ) );
return dst;
}
@ -132,7 +134,7 @@ int FixAAS( int argc, char **argv ){
/* do some path mangling */
strcpy( source, ExpandArg( argv[ argc - 1 ] ) );
StripExtension( source );
DefaultExtension( source, ".bsp" );
DefaultExtension( source, ".bsp", sizeof( source ) );
/* note it */
Sys_Printf( "--- FixAAS ---\n" );
@ -364,11 +366,11 @@ int BSPInfo( int count, char **fileNames ){
/* mangle filename and get size */
strcpy( source, fileNames[ i ] );
ExtractFileExtension( source, ext );
ExtractFileExtension( source, ext, sizeof( ext ) );
if ( !Q_stricmp( ext, "map" ) ) {
StripExtension( source );
}
DefaultExtension( source, ".bsp" );
DefaultExtension( source, ".bsp", sizeof( source ) );
f = fopen( source, "rb" );
if ( f ) {
size = Q_filelength( f );
@ -427,7 +429,7 @@ int ScaleBSPMain( int argc, char **argv ){
/* do some path mangling */
strcpy( source, ExpandArg( argv[ argc - 1 ] ) );
StripExtension( source );
DefaultExtension( source, ".bsp" );
DefaultExtension( source, ".bsp", sizeof( source ) );
/* load the bsp */
Sys_Printf( "Loading %s\n", source );
@ -499,7 +501,7 @@ int ScaleBSPMain( int argc, char **argv ){
/* write the bsp */
UnparseEntities();
StripExtension( source );
DefaultExtension( source, "_s.bsp" );
DefaultExtension( source, "_s.bsp", sizeof( source ) );
Sys_Printf( "Writing %s\n", source );
WriteBSPFile( source );
@ -555,7 +557,7 @@ int ConvertBSPMain( int argc, char **argv ){
/* clean up map name */
strcpy( source, ExpandArg( argv[ i ] ) );
StripExtension( source );
DefaultExtension( source, ".bsp" );
DefaultExtension( source, ".bsp", sizeof( source ) );
LoadShaderInfo();
@ -576,7 +578,7 @@ int ConvertBSPMain( int argc, char **argv ){
/* write bsp */
StripExtension( source );
DefaultExtension( source, "_c.bsp" );
DefaultExtension( source, "_c.bsp", sizeof( source ) );
Sys_Printf( "Writing %s\n", source );
WriteBSPFile( source );

View file

@ -1426,7 +1426,7 @@ void LoadEntityIndexMap( entity_t *e ){
Sys_FPrintf( SYS_VRB, "Entity %d (%s) has shader index map \"%s\"\n", mapEnt->mapEntityNum, ValueForKey( e, "classname" ), indexMapFilename );
/* get index map file extension */
ExtractFileExtension( indexMapFilename, ext );
ExtractFileExtension( indexMapFilename, ext, sizeof( ext ) );
/* handle tga image */
if ( !Q_stricmp( ext, "tga" ) ) {

View file

@ -1461,7 +1461,10 @@ surfaceInfo_t;
/* main.c */
vec_t Random( void );
char *Q_strncpyz( char *dst, const char *src, size_t len );
#ifndef Q_strncpyz
#define Q_strncpyz(_dst, _source, _len) do { strncpy((_dst), (_source), (_len) - 1); (_dst)[(_len) - 1] = 0; } while( 0 )
#endif
//char *Q_strncpyz( char *dst, const char *src, size_t len );
char *Q_strcat( char *dst, size_t dlen, const char *src );
char *Q_strncat( char *dst, size_t dlen, const char *src, size_t slen );
int BSPInfo( int count, char **fileNames );

View file

@ -1023,7 +1023,7 @@ static void ParseShaderFile( const char *filename ){
GetTokenAppend( shaderText, qfalse );
if ( token[ 0 ] != '*' && token[ 0 ] != '$' ) {
strcpy( si->lightImagePath, token );
DefaultExtension( si->lightImagePath, ".tga" );
DefaultExtension( si->lightImagePath, ".tga", sizeof( si->lightImagePath ) );
/* debug code */
//% Sys_FPrintf( SYS_VRB, "Deduced shader image: %s\n", si->lightImagePath );
@ -1177,21 +1177,21 @@ static void ParseShaderFile( const char *filename ){
else if ( !Q_stricmp( token, "qer_editorImage" ) ) {
GetTokenAppend( shaderText, qfalse );
strcpy( si->editorImagePath, token );
DefaultExtension( si->editorImagePath, ".tga" );
DefaultExtension( si->editorImagePath, ".tga", sizeof( si->editorImagePath ) );
}
/* ydnar: q3map_normalimage <image> (bumpmapping normal map) */
else if ( !Q_stricmp( token, "q3map_normalImage" ) ) {
GetTokenAppend( shaderText, qfalse );
strcpy( si->normalImagePath, token );
DefaultExtension( si->normalImagePath, ".tga" );
DefaultExtension( si->normalImagePath, ".tga", sizeof( si->normalImagePath ) );
}
/* q3map_lightimage <image> */
else if ( !Q_stricmp( token, "q3map_lightImage" ) ) {
GetTokenAppend( shaderText, qfalse );
strcpy( si->lightImagePath, token );
DefaultExtension( si->lightImagePath, ".tga" );
DefaultExtension( si->lightImagePath, ".tga", sizeof( si->lightImagePath ) );
}
/* ydnar: skyparms <outer image> <cloud height> <inner image> */