sprintf -> snprintf

This commit is contained in:
Pan7 2015-09-07 00:41:21 +02:00
parent 73e54acf55
commit 8a3387a765
71 changed files with 328 additions and 317 deletions

View file

@ -169,7 +169,7 @@ void CBackgroundDialogPage::Browse(){
void CBackgroundDialogPage::SetPosLabel(){ void CBackgroundDialogPage::SetPosLabel(){
char s[64]; char s[64];
snprintf( s, sizeof( s ) - 1, _( "Size/Position (%d,%d) (%d,%d)" ),(int)( m_pImage->m_xmin ), snprintf( s, sizeof( s ), _( "Size/Position (%d,%d) (%d,%d)" ),(int)( m_pImage->m_xmin ),
(int)( m_pImage->m_ymin ),(int)( m_pImage->m_xmax ),(int)( m_pImage->m_ymax ) ); (int)( m_pImage->m_ymin ),(int)( m_pImage->m_xmax ),(int)( m_pImage->m_ymax ) );
gtk_label_set_text( GTK_LABEL( m_pPosLabel ),s ); gtk_label_set_text( GTK_LABEL( m_pPosLabel ),s );
} }

View file

@ -683,9 +683,9 @@ void DBrush::SaveToFile( FILE *pFile ){
for ( list<DPlane *>::const_iterator pp = faceList.begin(); pp != faceList.end(); pp++ ) for ( list<DPlane *>::const_iterator pp = faceList.begin(); pp != faceList.end(); pp++ )
{ {
char buffer[512]; char buffer[720 + PATH_MAX];
sprintf( buffer, "( %.0f %.0f %.0f ) ( %.0f %.0f %.0f ) ( %.0f %.0f %.0f ) %s %.0f %.0f %f %f %.0f 0 0 0\n", snprintf( buffer, sizeof( buffer ), "( %.0f %.0f %.0f ) ( %.0f %.0f %.0f ) ( %.0f %.0f %.0f ) %s %.0f %.0f %f %f %.0f 0 0 0\n",
( *pp )->points[0][0], ( *pp )->points[0][1], ( *pp )->points[0][2], ( *pp )->points[0][0], ( *pp )->points[0][1], ( *pp )->points[0][2],
( *pp )->points[1][0], ( *pp )->points[1][1], ( *pp )->points[1][2], ( *pp )->points[1][0], ( *pp )->points[1][1], ( *pp )->points[1][2],
( *pp )->points[2][0], ( *pp )->points[2][1], ( *pp )->points[2][2], ( *pp )->points[2][0], ( *pp )->points[2][1], ( *pp )->points[2][2],

View file

@ -235,7 +235,7 @@ void DTrainDrawer::BuildPaths() {
AddSplineControl( control, pSP ); AddSplineControl( control, pSP );
for ( int j = 2;; j++ ) { for ( int j = 2;; j++ ) {
char buffer[16]; char buffer[32];
sprintf( buffer, "control%i", j ); sprintf( buffer, "control%i", j );
e.SpawnString( buffer, NULL, &control ); e.SpawnString( buffer, NULL, &control );

View file

@ -154,7 +154,7 @@ bool ValidateTextFloatRange( const char* pData, float min, float max, const char
bool ValidateTextIntRange( const char* pData, int min, int max, const char* error_title, int* value ){ bool ValidateTextIntRange( const char* pData, int min, int max, const char* error_title, int* value ){
char error_buffer[256]; char error_buffer[256];
sprintf( error_buffer, "Please Enter An Integer Between %i and %i", min, max ); snprintf( error_buffer, sizeof( error_buffer ), "Please Enter An Integer Between %i and %i", min, max );
if ( pData ) { if ( pData ) {
int testNum = atoi( pData ); int testNum = atoi( pData );

View file

@ -117,7 +117,7 @@ void DoLoadCamera(){
if ( !strcmp( fullpathtofile, checkCam->GetFileName() ) ) { if ( !strcmp( fullpathtofile, checkCam->GetFileName() ) ) {
char error[PATH_MAX + 64]; char error[PATH_MAX + 64];
FreeCam( cam ); FreeCam( cam );
sprintf( error, "Camera file \'%s\' is already loaded", fullpathtofile ); snprintf( error, sizeof( error ), "Camera file \'%s\' is already loaded", fullpathtofile );
g_FuncTable.m_pfnMessageBox( (GtkWidget *)g_pRadiantWnd, error, "Load error", MB_OK, NULL ); g_FuncTable.m_pfnMessageBox( (GtkWidget *)g_pRadiantWnd, error, "Load error", MB_OK, NULL );
//g_free( filename ); //g_free( filename );
return; return;
@ -135,7 +135,7 @@ void DoLoadCamera(){
else { else {
char error[PATH_MAX + 64]; char error[PATH_MAX + 64];
FreeCam( cam ); FreeCam( cam );
sprintf( error, "An error occured during the loading of \'%s\'", fullpathtofile ); snprintf( error, sizeof( error ), "An error occured during the loading of \'%s\'", fullpathtofile );
g_FuncTable.m_pfnMessageBox( (GtkWidget *)g_pRadiantWnd, error, "Load error", MB_OK, NULL ); g_FuncTable.m_pfnMessageBox( (GtkWidget *)g_pRadiantWnd, error, "Load error", MB_OK, NULL );
} }
@ -191,7 +191,7 @@ void DoSaveCamera() {
} }
else if ( !strcmp( fullpathtofile, checkCam->GetFileName() ) ) { else if ( !strcmp( fullpathtofile, checkCam->GetFileName() ) ) {
char error[PATH_MAX + 64]; char error[PATH_MAX + 64];
sprintf( error, "Camera file \'%s\' is currently loaded by GtkRadiant.\nPlease select a different filename.", fullpathtofile ); snprintf( error, sizeof( error ), "Camera file \'%s\' is currently loaded by GtkRadiant.\nPlease select a different filename.", fullpathtofile );
g_FuncTable.m_pfnMessageBox( (GtkWidget *)g_pRadiantWnd, error, "Save error", MB_OK, NULL ); g_FuncTable.m_pfnMessageBox( (GtkWidget *)g_pRadiantWnd, error, "Save error", MB_OK, NULL );
return; return;
} }
@ -213,14 +213,14 @@ void DoUnloadCamera() {
if ( !GetCurrentCam()->HasBeenSaved() ) { if ( !GetCurrentCam()->HasBeenSaved() ) {
char buf[PATH_MAX + 64]; char buf[PATH_MAX + 64];
sprintf( buf, "Do you want to save the changes for camera '%s'?", GetCurrentCam()->GetCam()->getName() ); snprintf( buf, sizeof( buf ), "Do you want to save the changes for camera '%s'?", GetCurrentCam()->GetCam()->getName() );
if ( g_FuncTable.m_pfnMessageBox( (GtkWidget *)g_pRadiantWnd, buf, "Warning", MB_YESNO, NULL ) == IDYES ) { if ( g_FuncTable.m_pfnMessageBox( (GtkWidget *)g_pRadiantWnd, buf, "Warning", MB_YESNO, NULL ) == IDYES ) {
DoSaveCamera(); DoSaveCamera();
} }
} }
else if ( GetCurrentCam()->HasBeenSaved() == 2 ) { else if ( GetCurrentCam()->HasBeenSaved() == 2 ) {
char buf[PATH_MAX + 64]; char buf[PATH_MAX + 64];
sprintf( buf, "Do you want to save the changes made to camera file '%s'?", GetCurrentCam()->GetFileName() ); snprintf( buf, sizeof( buf ), "Do you want to save the changes made to camera file '%s'?", GetCurrentCam()->GetFileName() );
if ( g_FuncTable.m_pfnMessageBox( (GtkWidget *)g_pRadiantWnd, buf, "Warning", MB_YESNO, NULL ) == IDYES ) { if ( g_FuncTable.m_pfnMessageBox( (GtkWidget *)g_pRadiantWnd, buf, "Warning", MB_YESNO, NULL ) == IDYES ) {
DoSaveCamera(); DoSaveCamera();
} }

View file

@ -442,7 +442,7 @@ bool OpenBitmap(){
g_print( "failed to load file gbmp %s\n",gbmp.name ); g_print( "failed to load file gbmp %s\n",gbmp.name );
char Text[256]; char Text[256];
sprintf( Text, "Error opening %s", gbmp.name ); snprintf( Text, sizeof( Text ), "Error opening %s", gbmp.name );
g_FuncTable.m_pfnMessageBox( g_pWnd, Text, "Bitmap", MB_ICONEXCLAMATION, NULL ); g_FuncTable.m_pfnMessageBox( g_pWnd, Text, "Bitmap", MB_ICONEXCLAMATION, NULL );
strcpy( gbmp.name, "" ); strcpy( gbmp.name, "" );
} }

View file

@ -280,32 +280,32 @@ static void SetDlgValues( int tab ){
gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( wave_radios[WaveType] ), TRUE ); gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( wave_radios[WaveType] ), TRUE );
gtk_spin_button_set_value( GTK_SPIN_BUTTON( g_object_get_data( G_OBJECT( g_pWnd ), "random" ) ), gtk_spin_button_set_value( GTK_SPIN_BUTTON( g_object_get_data( G_OBJECT( g_pWnd ), "random" ) ),
RandomSeed ); RandomSeed );
sprintf( Text, RForm, WaveLength ); snprintf( Text, sizeof( Text ), RForm, WaveLength );
gtk_entry_set_text( GTK_ENTRY( g_object_get_data( G_OBJECT( g_pWnd ), "wavelength" ) ), Text ); gtk_entry_set_text( GTK_ENTRY( g_object_get_data( G_OBJECT( g_pWnd ), "wavelength" ) ), Text );
sprintf( Text, RForm, Amplitude ); snprintf( Text, sizeof( Text ), RForm, Amplitude );
gtk_entry_set_text( GTK_ENTRY( g_object_get_data( G_OBJECT( g_pWnd ), "amplitude" ) ), Text ); gtk_entry_set_text( GTK_ENTRY( g_object_get_data( G_OBJECT( g_pWnd ), "amplitude" ) ), Text );
sprintf( Text, RForm, Roughness ); snprintf( Text, sizeof( Text ), RForm, Roughness );
gtk_entry_set_text( GTK_ENTRY( g_object_get_data( G_OBJECT( g_pWnd ), "roughness" ) ), Text ); gtk_entry_set_text( GTK_ENTRY( g_object_get_data( G_OBJECT( g_pWnd ), "roughness" ) ), Text );
gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( g_object_get_data gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( g_object_get_data
( G_OBJECT( g_pWnd ), "main_antialiasing" ) ), Antialiasing ); ( G_OBJECT( g_pWnd ), "main_antialiasing" ) ), Antialiasing );
break; break;
case EXTENTS_TAB: case EXTENTS_TAB:
sprintf( Text,RForm,Hll ); snprintf( Text, sizeof( Text ), RForm, Hll );
gtk_entry_set_text( GTK_ENTRY( g_object_get_data( G_OBJECT( g_pWnd ), "hmin" ) ), Text ); gtk_entry_set_text( GTK_ENTRY( g_object_get_data( G_OBJECT( g_pWnd ), "hmin" ) ), Text );
sprintf( Text,RForm,Vll ); snprintf( Text, sizeof( Text ), RForm, Vll );
gtk_entry_set_text( GTK_ENTRY( g_object_get_data( G_OBJECT( g_pWnd ), "vmin" ) ), Text ); gtk_entry_set_text( GTK_ENTRY( g_object_get_data( G_OBJECT( g_pWnd ), "vmin" ) ), Text );
sprintf( Text,RForm,Hur ); snprintf( Text, sizeof( Text ), RForm, Hur );
gtk_entry_set_text( GTK_ENTRY( g_object_get_data( G_OBJECT( g_pWnd ), "hmax" ) ), Text ); gtk_entry_set_text( GTK_ENTRY( g_object_get_data( G_OBJECT( g_pWnd ), "hmax" ) ), Text );
sprintf( Text,RForm,Vur ); snprintf( Text, sizeof( Text ), RForm, Vur );
gtk_entry_set_text( GTK_ENTRY( g_object_get_data( G_OBJECT( g_pWnd ), "vmax" ) ), Text ); gtk_entry_set_text( GTK_ENTRY( g_object_get_data( G_OBJECT( g_pWnd ), "vmax" ) ), Text );
sprintf( Text,RForm,Z00 ); snprintf( Text, sizeof( Text ), RForm, Z00 );
gtk_entry_set_text( GTK_ENTRY( g_object_get_data( G_OBJECT( g_pWnd ), "z00" ) ), Text ); gtk_entry_set_text( GTK_ENTRY( g_object_get_data( G_OBJECT( g_pWnd ), "z00" ) ), Text );
sprintf( Text,RForm,Z01 ); snprintf( Text, sizeof( Text ), RForm, Z01 );
gtk_entry_set_text( GTK_ENTRY( g_object_get_data( G_OBJECT( g_pWnd ), "z01" ) ), Text ); gtk_entry_set_text( GTK_ENTRY( g_object_get_data( G_OBJECT( g_pWnd ), "z01" ) ), Text );
sprintf( Text,RForm,Z10 ); snprintf( Text, sizeof( Text ), RForm, Z10 );
gtk_entry_set_text( GTK_ENTRY( g_object_get_data( G_OBJECT( g_pWnd ), "z10" ) ), Text ); gtk_entry_set_text( GTK_ENTRY( g_object_get_data( G_OBJECT( g_pWnd ), "z10" ) ), Text );
sprintf( Text,RForm,Z11 ); snprintf( Text, sizeof( Text ), RForm, Z11 );
gtk_entry_set_text( GTK_ENTRY( g_object_get_data( G_OBJECT( g_pWnd ), "z11" ) ), Text ); gtk_entry_set_text( GTK_ENTRY( g_object_get_data( G_OBJECT( g_pWnd ), "z11" ) ), Text );
gtk_spin_button_set_value( GTK_SPIN_BUTTON( g_object_get_data( G_OBJECT( g_pWnd ), "nh" ) ), NH ); gtk_spin_button_set_value( GTK_SPIN_BUTTON( g_object_get_data( G_OBJECT( g_pWnd ), "nh" ) ), NH );
gtk_spin_button_set_value( GTK_SPIN_BUTTON( g_object_get_data( G_OBJECT( g_pWnd ), "nv" ) ), NV ); gtk_spin_button_set_value( GTK_SPIN_BUTTON( g_object_get_data( G_OBJECT( g_pWnd ), "nv" ) ), NV );
@ -385,9 +385,9 @@ static void SetDlgValues( int tab ){
case BITMAP_TAB: case BITMAP_TAB:
gtk_entry_set_text( GTK_ENTRY( g_object_get_data( G_OBJECT( g_pWnd ), "bmp_file" ) ), gbmp.name ); gtk_entry_set_text( GTK_ENTRY( g_object_get_data( G_OBJECT( g_pWnd ), "bmp_file" ) ), gbmp.name );
sprintf( Text,"%g",gbmp.black_value ); snprintf( Text, sizeof( Text ), "%g", gbmp.black_value );
gtk_entry_set_text( GTK_ENTRY( g_object_get_data( G_OBJECT( g_pWnd ), "bmp_black" ) ), Text ); gtk_entry_set_text( GTK_ENTRY( g_object_get_data( G_OBJECT( g_pWnd ), "bmp_black" ) ), Text );
sprintf( Text,"%g",gbmp.white_value ); snprintf( Text, sizeof( Text ), "%g", gbmp.white_value );
gtk_entry_set_text( GTK_ENTRY( g_object_get_data( G_OBJECT( g_pWnd ), "bmp_white" ) ), Text ); gtk_entry_set_text( GTK_ENTRY( g_object_get_data( G_OBJECT( g_pWnd ), "bmp_white" ) ), Text );
break; break;
@ -400,13 +400,13 @@ static void SetDlgValues( int tab ){
gtk_entry_set_text( GTK_ENTRY( g_object_get_data( G_OBJECT( g_pWnd ), "texture3" ) ), Texture[Game][2] ); gtk_entry_set_text( GTK_ENTRY( g_object_get_data( G_OBJECT( g_pWnd ), "texture3" ) ), Texture[Game][2] );
gtk_spin_button_set_value( GTK_SPIN_BUTTON( g_object_get_data( G_OBJECT( g_pWnd ), "tex_slant" ) ), gtk_spin_button_set_value( GTK_SPIN_BUTTON( g_object_get_data( G_OBJECT( g_pWnd ), "tex_slant" ) ),
SlantAngle ); SlantAngle );
sprintf( Text,RForm,TexOffset[0] ); snprintf( Text, sizeof( Text ), RForm, TexOffset[0] );
gtk_entry_set_text( GTK_ENTRY( g_object_get_data( G_OBJECT( g_pWnd ), "texoffsetx" ) ), Text ); gtk_entry_set_text( GTK_ENTRY( g_object_get_data( G_OBJECT( g_pWnd ), "texoffsetx" ) ), Text );
sprintf( Text,RForm,TexOffset[1] ); snprintf( Text, sizeof( Text ), RForm, TexOffset[1] );
gtk_entry_set_text( GTK_ENTRY( g_object_get_data( G_OBJECT( g_pWnd ), "texoffsety" ) ), Text ); gtk_entry_set_text( GTK_ENTRY( g_object_get_data( G_OBJECT( g_pWnd ), "texoffsety" ) ), Text );
sprintf( Text,RForm,TexScale[0] ); snprintf( Text, sizeof( Text ), RForm, TexScale[0] );
gtk_entry_set_text( GTK_ENTRY( g_object_get_data( G_OBJECT( g_pWnd ), "texscalex" ) ), Text ); gtk_entry_set_text( GTK_ENTRY( g_object_get_data( G_OBJECT( g_pWnd ), "texscalex" ) ), Text );
sprintf( Text,RForm,TexScale[1] ); snprintf( Text, sizeof( Text ), RForm, TexScale[1] );
gtk_entry_set_text( GTK_ENTRY( g_object_get_data( G_OBJECT( g_pWnd ), "texscaley" ) ), Text ); gtk_entry_set_text( GTK_ENTRY( g_object_get_data( G_OBJECT( g_pWnd ), "texscaley" ) ), Text );
CHECK_WIDGET( "detail", UseDetail ); CHECK_WIDGET( "detail", UseDetail );
@ -726,14 +726,14 @@ static void main_go( GtkWidget *widget, gpointer data ){
ReadDlgValues( current_tab ); ReadDlgValues( current_tab );
if ( NH < 1 || NH > MAX_ROWS ) { if ( NH < 1 || NH > MAX_ROWS ) {
sprintf( Text, "The number of divisions must be > 0 and no greater than %d.", MAX_ROWS ); sprintf( Text, _( "The number of divisions must be > 0 and no greater than %d." ), MAX_ROWS );
g_FuncTable.m_pfnMessageBox( g_pWnd, Text, "GenSurf", MB_ICONEXCLAMATION, NULL ); g_FuncTable.m_pfnMessageBox( g_pWnd, Text, "GenSurf", MB_ICONEXCLAMATION, NULL );
gtk_notebook_set_current_page( GTK_NOTEBOOK( notebook ), EXTENTS_TAB ); gtk_notebook_set_current_page( GTK_NOTEBOOK( notebook ), EXTENTS_TAB );
return; return;
} }
if ( NV < 1 || NV > MAX_ROWS ) { if ( NV < 1 || NV > MAX_ROWS ) {
sprintf( Text, "The number of divisions must be > 0 and no greater than %d.", MAX_ROWS ); sprintf( Text, _( "The number of divisions must be > 0 and no greater than %d." ), MAX_ROWS );
g_FuncTable.m_pfnMessageBox( g_pWnd, Text, "GenSurf", MB_ICONEXCLAMATION, NULL ); g_FuncTable.m_pfnMessageBox( g_pWnd, Text, "GenSurf", MB_ICONEXCLAMATION, NULL );
gtk_notebook_set_current_page( GTK_NOTEBOOK( notebook ), EXTENTS_TAB ); gtk_notebook_set_current_page( GTK_NOTEBOOK( notebook ), EXTENTS_TAB );
return; return;
@ -1005,7 +1005,7 @@ static void fix_freeall( GtkWidget *widget, gpointer data ){
} }
void vertex_selected(){ void vertex_selected(){
char Text[32]; char Text[64];
int k; int k;
SetupControls(); SetupControls();
@ -1031,9 +1031,9 @@ void vertex_selected(){
gtk_spin_button_set_value( GTK_SPIN_BUTTON( g_object_get_data( G_OBJECT( g_pWnd ), "fix_value" ) ), gtk_spin_button_set_value( GTK_SPIN_BUTTON( g_object_get_data( G_OBJECT( g_pWnd ), "fix_value" ) ),
(int)xyz[Vertex[0].i][Vertex[0].j].fixed_value ); (int)xyz[Vertex[0].i][Vertex[0].j].fixed_value );
sprintf( Text,"%d",(int)xyz[Vertex[0].i][Vertex[0].j].range ); sprintf( Text, "%d", (int)xyz[Vertex[0].i][Vertex[0].j].range );
gtk_entry_set_text( GTK_ENTRY( g_object_get_data( G_OBJECT( g_pWnd ), "fix_range" ) ), Text ); gtk_entry_set_text( GTK_ENTRY( g_object_get_data( G_OBJECT( g_pWnd ), "fix_range" ) ), Text );
sprintf( Text,"%.5g",xyz[Vertex[0].i][Vertex[0].j].rate ); snprintf( Text, sizeof( Text ), "%.5g", xyz[Vertex[0].i][Vertex[0].j].rate );
gtk_entry_set_text( GTK_ENTRY( g_object_get_data( G_OBJECT( g_pWnd ), "fix_rate" ) ), Text ); gtk_entry_set_text( GTK_ENTRY( g_object_get_data( G_OBJECT( g_pWnd ), "fix_rate" ) ), Text );
for ( k = 0; k < NumVerticesSelected; k++ ) for ( k = 0; k < NumVerticesSelected; k++ )

View file

@ -192,8 +192,8 @@ int MapPatches(){
NH_patch -= 2; NH_patch -= 2;
NH_remain -= ( NH_patch - 1 ); NH_remain -= ( NH_patch - 1 );
if ( NH_remain < 0 ) { if ( NH_remain < 0 ) {
sprintf( szOops,"Oops... screwed up with NH=%d",NH ); sprintf( szOops, "Oops... screwed up with NH=%d", NH );
g_FuncTable.m_pfnMessageBox( NULL,szOops,"Uh oh", 0, NULL ); g_FuncTable.m_pfnMessageBox( NULL, szOops, "Uh oh", 0, NULL );
} }
NV_remain = NV + 1; NV_remain = NV + 1;
j0 = 0; j0 = 0;
@ -233,8 +233,8 @@ int MapPatches(){
NV_patch -= 2; NV_patch -= 2;
NV_remain -= ( NV_patch - 1 ); NV_remain -= ( NV_patch - 1 );
if ( NV_remain < 0 ) { if ( NV_remain < 0 ) {
sprintf( szOops,"Oops... screwed up with NV=%d",NV ); sprintf( szOops, "Oops... screwed up with NV=%d", NV );
g_FuncTable.m_pfnMessageBox( NULL,szOops,"Uh oh", 0, NULL ); g_FuncTable.m_pfnMessageBox( NULL, szOops, "Uh oh", 0, NULL );
} }
p.width = NH_patch; p.width = NH_patch;

View file

@ -423,7 +423,7 @@ void SaveSetup( GtkWidget *parent ){
g_FuncTable.m_pfnProfileGetDirectory(), "gtkgensurf", NULL ); g_FuncTable.m_pfnProfileGetDirectory(), "gtkgensurf", NULL );
if ( name != NULL ) { if ( name != NULL ) {
char key[32], text[32]; char key[32], text[128];
int i, j; int i, j;
WriteIniFile( name ); WriteIniFile( name );
@ -437,8 +437,8 @@ void SaveSetup( GtkWidget *parent ){
for ( j = 0; j <= NV; j++ ) for ( j = 0; j <= NV; j++ )
{ {
if ( xyz[i][j].fixed ) { if ( xyz[i][j].fixed ) {
sprintf( key,"I%dJ%d",i,j ); sprintf( key, "I%dJ%d", i, j );
sprintf( text,"%g %g %g", xyz[i][j].fixed_value, xyz[i][j].range, xyz[i][j].rate ); snprintf( text, sizeof( text ), "%g %g %g", xyz[i][j].fixed_value, xyz[i][j].range, xyz[i][j].rate );
g_FuncTable.m_pfnProfileSaveString( name, "FixedPoints",key,text ); g_FuncTable.m_pfnProfileSaveString( name, "FixedPoints",key,text );
} }
} }

View file

@ -349,10 +349,10 @@ void INISetInt( const char *key, int val, const char *comment /* = NULL */ ){
char s[1000]; char s[1000];
if ( comment ) { if ( comment ) {
sprintf( s, "%d ; %s", val, comment ); snprintf( s, sizeof( s ), "%d ; %s", val, comment );
} }
else{ else{
sprintf( s, "%d", val ); snprintf( s, sizeof( s ), "%d", val );
} }
#if defined( __linux__ ) || defined( __APPLE__ ) #if defined( __linux__ ) || defined( __APPLE__ )
save_var( INIfn, CONFIG_SECTION, key, s ); save_var( INIfn, CONFIG_SECTION, key, s );

View file

@ -260,7 +260,7 @@ idStr operator+
const idStr& a, const idStr& a,
const float b const float b
){ ){
char text[ 20 ]; char text[ 64 ];
idStr result( a ); idStr result( a );
@ -304,7 +304,7 @@ idStr& idStr::operator+=
( (
const float a const float a
){ ){
char text[ 20 ]; char text[ 64 ];
sprintf( text, "%f", a ); sprintf( text, "%f", a );
append( text ); append( text );

View file

@ -366,7 +366,7 @@ class_t *Find_Class( GSList *l,char *classname, class_t *ignore ){
Note: this is somewhat recursive, as a class can require a class that requires a class and so on.. Note: this is somewhat recursive, as a class can require a class that requires a class and so on..
*/ */
void EClass_ImportFromClass( eclass_t *e, GSList *l_classes, class_t *bc ){ void EClass_ImportFromClass( eclass_t *e, GSList *l_classes, class_t *bc ){
char color[128]; char color[256];
// We allocate 16k here, but only the memory actually used is kept allocated. // We allocate 16k here, but only the memory actually used is kept allocated.
// this is just used for building the final comments string. // this is just used for building the final comments string.
@ -596,12 +596,12 @@ void Create_EClasses( GSList *l_classes ){
if ( havespawnflags ) { if ( havespawnflags ) {
char spawnline[80]; char spawnline[80];
e->comments = addstr( e->comments,"Spawnflags\n" ); e->comments = addstr( e->comments, "Spawnflags\n" );
for ( i = 0 ; i < MAX_FLAGS ; i++ ) for ( i = 0 ; i < MAX_FLAGS ; i++ )
{ {
if ( *e->flagnames[i] ) { if ( *e->flagnames[i] ) {
sprintf( spawnline," %d - %s\n", 1 << i, e->flagnames[i] ); snprintf( spawnline, sizeof( spawnline ), " %d - %s\n", 1 << i, e->flagnames[i] );
e->comments = addstr( e->comments,spawnline ); e->comments = addstr( e->comments, spawnline );
} }
} }
} }

View file

@ -40,15 +40,15 @@ char *str_append_token( char *str1, const char *str2 ){
return str; return str;
} }
void str_from_float( char *buf, float f ){ void str_from_float( char *buf, float f, size_t length ){
if ( f == (int)f ) { if ( f == (int)f ) {
sprintf( buf, "%i", (int)f ); snprintf( buf, length, "%i", (int)f );
} }
else{ sprintf( buf, "%f", f ); } else{ snprintf( buf, length, "%f", f ); }
} }
void Patch_XMLWrite( patchMesh_t *pPatch, xmlNodePtr surface ){ void Patch_XMLWrite( patchMesh_t *pPatch, xmlNodePtr surface ){
char buf[16]; char buf[64];
char *str; char *str;
int i, j; int i, j;
xmlNodePtr node; xmlNodePtr node;
@ -62,15 +62,15 @@ void Patch_XMLWrite( patchMesh_t *pPatch, xmlNodePtr surface ){
{ {
for ( j = 0; j < pPatch->height; j++ ) for ( j = 0; j < pPatch->height; j++ )
{ {
str_from_float( buf, pPatch->ctrl[i][j].xyz[0] ); str_from_float( buf, pPatch->ctrl[i][j].xyz[0], sizeof( buf ) );
str = str_append_token( str, buf ); str = str_append_token( str, buf );
str_from_float( buf, pPatch->ctrl[i][j].xyz[1] ); str_from_float( buf, pPatch->ctrl[i][j].xyz[1], sizeof( buf ) );
str = str_append_token( str, buf ); str = str_append_token( str, buf );
str_from_float( buf, pPatch->ctrl[i][j].xyz[2] ); str_from_float( buf, pPatch->ctrl[i][j].xyz[2], sizeof( buf ) );
str = str_append_token( str, buf ); str = str_append_token( str, buf );
str_from_float( buf, pPatch->ctrl[i][j].st[0] ); str_from_float( buf, pPatch->ctrl[i][j].st[0], sizeof( buf ) );
str = str_append_token( str, buf ); str = str_append_token( str, buf );
str_from_float( buf, pPatch->ctrl[i][j].st[1] ); str_from_float( buf, pPatch->ctrl[i][j].st[1], sizeof( buf ) );
str = str_append_token( str, buf ); str = str_append_token( str, buf );
} }
} }
@ -84,7 +84,7 @@ void Patch_XMLWrite( patchMesh_t *pPatch, xmlNodePtr surface ){
} }
void Face_XMLWrite( face_t *face, xmlNodePtr surface, bool bAlternateTexdef = false ){ void Face_XMLWrite( face_t *face, xmlNodePtr surface, bool bAlternateTexdef = false ){
char buf[16]; char buf[64];
xmlNodePtr node; xmlNodePtr node;
int i, j; int i, j;
char *str; char *str;
@ -98,7 +98,7 @@ void Face_XMLWrite( face_t *face, xmlNodePtr surface, bool bAlternateTexdef = fa
{ {
for ( j = 0 ; j < 3 ; j++ ) for ( j = 0 ; j < 3 ; j++ )
{ {
str_from_float( buf, face->planepts[i][j] ); str_from_float( buf, face->planepts[i][j], sizeof( buf ) );
str = str_append_token( str, buf ); str = str_append_token( str, buf );
} }
} }
@ -130,7 +130,7 @@ void Face_XMLWrite( face_t *face, xmlNodePtr surface, bool bAlternateTexdef = fa
{ {
for ( j = 0 ; j < 3 ; j++ ) for ( j = 0 ; j < 3 ; j++ )
{ {
str_from_float( buf, face->brushprimit_texdef.coords[i][j] ); str_from_float( buf, face->brushprimit_texdef.coords[i][j], sizeof( buf ) );
str = str_append_token( str, buf ); str = str_append_token( str, buf );
} }
} }

View file

@ -38,6 +38,8 @@ CPicoSurface::CPicoSurface( picoSurface_t *pSurface ){
// directory as a fall-back. This is a hack for malformed models. // directory as a fall-back. This is a hack for malformed models.
if ( m_shader->IsDefault() ) { if ( m_shader->IsDefault() ) {
Sys_Printf( "WARNING: Failed to load shader %s for %s\n", m_shader->getName(), m_pSurface->model->name );
gchar *dir = g_path_get_dirname( m_pSurface->model->name ); gchar *dir = g_path_get_dirname( m_pSurface->model->name );
gchar *skin = g_strdup_printf( "%s/skin.tga", dir ); gchar *skin = g_strdup_printf( "%s/skin.tga", dir );

View file

@ -71,7 +71,7 @@ const char *WINAPI QERApp_CleanTextureName( const char *name, bool bAddTexture =
} }
#endif #endif
strcpy( stdName, name ); Q_strncpyz( stdName, name, sizeof( stdName ) );
g_FuncTable.m_pfnQE_ConvertDOSToUnixName( stdName, stdName ); g_FuncTable.m_pfnQE_ConvertDOSToUnixName( stdName, stdName );
if ( stdName[strlen( name ) - 4] == '.' ) { if ( stdName[strlen( name ) - 4] == '.' ) {
// strip extension // strip extension
@ -80,8 +80,8 @@ const char *WINAPI QERApp_CleanTextureName( const char *name, bool bAddTexture =
if ( bAddTexture ) { if ( bAddTexture ) {
char aux[QER_MAX_NAMELEN]; char aux[QER_MAX_NAMELEN];
sprintf( aux, "textures/%s", stdName ); snprintf( aux, sizeof( aux ), "textures/%s", stdName );
strcpy( stdName, aux ); Q_strncpyz( stdName, aux, sizeof( stdName ) );
} }
return stdName; return stdName;
} }

View file

@ -86,7 +86,7 @@ void set_surface_flags_button_state( texdef_to_face_t *texdef_face_list, bool b_
int diff_contents = 0; int diff_contents = 0;
int diff_flags = 0; int diff_flags = 0;
gboolean diff_value = FALSE; gboolean diff_value = FALSE;
char tex_buff[11]; char tex_buff[16];
texdef_t* tmp_texdef; texdef_t* tmp_texdef;
texdef_to_face_t* temp_texdef_face_list; texdef_to_face_t* temp_texdef_face_list;
int i; int i;
@ -301,7 +301,7 @@ GtkWidget* create_SurfaceFlagsFrame( GtkWidget* surfacedialog_widget ){
GtkWidget *label6; GtkWidget *label6;
int i, x, y; int i, x, y;
const char *buttonLabel; const char *buttonLabel;
char buffer[8]; char buffer[16];
frame1 = gtk_frame_new( _( "Flags" ) ); frame1 = gtk_frame_new( _( "Flags" ) );
gtk_widget_show( frame1 ); gtk_widget_show( frame1 );
@ -333,7 +333,7 @@ GtkWidget* create_SurfaceFlagsFrame( GtkWidget* surfacedialog_widget ){
y++; y++;
} }
x = i % 4; x = i % 4;
snprintf( buffer, sizeof( buffer ) - 1, "surf%i", i + 1 ); snprintf( buffer, sizeof( buffer ), "surf%i", i + 1 );
buttonLabel = g_FuncTable.m_pfnReadProjectKey( buffer ); buttonLabel = g_FuncTable.m_pfnReadProjectKey( buffer );
//Sys_Printf( "%s: %s\n", buffer, buttonLabel ); //Sys_Printf( "%s: %s\n", buffer, buttonLabel );
surface_buttons[i] = gtk_toggle_button_new_with_label( buttonLabel ); surface_buttons[i] = gtk_toggle_button_new_with_label( buttonLabel );
@ -391,7 +391,7 @@ GtkWidget* create_SurfaceFlagsFrame( GtkWidget* surfacedialog_widget ){
y++; y++;
} }
x = i % 4; x = i % 4;
snprintf( buffer, sizeof( buffer ) - 1, "cont%i", i + 1 ); snprintf( buffer, sizeof( buffer ), "cont%i", i + 1 );
buttonLabel = g_FuncTable.m_pfnReadProjectKey( buffer ); buttonLabel = g_FuncTable.m_pfnReadProjectKey( buffer );
content_buttons[i] = gtk_toggle_button_new_with_label( buttonLabel ); content_buttons[i] = gtk_toggle_button_new_with_label( buttonLabel );
g_signal_connect( content_buttons[i], "toggled", G_CALLBACK( on_content_button_toggled ), GINT_TO_POINTER( 1 << i ) ); g_signal_connect( content_buttons[i], "toggled", G_CALLBACK( on_content_button_toggled ), GINT_TO_POINTER( 1 << i ) );

View file

@ -279,7 +279,7 @@ static GSList* vfsGetListInternal( const char *dir, const char *ext, bool direct
continue; continue;
} }
sprintf( filename, "%s%s", dirname, name ); snprintf( filename, sizeof( filename ), "%s%s", dirname, name );
stat( filename, &st ); stat( filename, &st );
Sys_Printf( "vfs FileName: %s\n", filename ); Sys_Printf( "vfs FileName: %s\n", filename );

View file

@ -267,7 +267,7 @@ static GSList* vfsGetListInternal( const char *refdir, const char *ext, bool dir
continue; continue;
} }
sprintf( filename, "%s%s", basedir, name ); snprintf( filename, sizeof( filename ), "%s%s", basedir, name );
stat( filename, &st ); stat( filename, &st );
if ( ( S_ISDIR( st.st_mode ) != 0 ) != directories ) { if ( ( S_ISDIR( st.st_mode ) != 0 ) != directories ) {
@ -470,7 +470,7 @@ void vfsInitDirectory( const char *path ){
break; break;
} }
sprintf( filename, "%s/%s", path, name ); snprintf( filename, sizeof( filename ), "%s/%s", path, name );
vfsInitPakFile( filename ); vfsInitPakFile( filename );
g_free( name ); g_free( name );

View file

@ -190,10 +190,10 @@ static void vfsInitPakFile( const char *filename ){
// texturenames in wad files don't have an extensions or paths, so we must add them! // texturenames in wad files don't have an extensions or paths, so we must add them!
if ( wf->lpLump->type == WAD2_TYPE_MIP ) { if ( wf->lpLump->type == WAD2_TYPE_MIP ) {
sprintf( filename_inwadfixed,"textures/%s/%s.mip",wadname,filename_inwad ); snprintf( filename_inwadfixed, sizeof( filename_inwadfixed ), "textures/%s/%s.mip", wadname,filename_inwad );
} }
else { else {
sprintf( filename_inwadfixed,"textures/%s/%s.hlw",wadname,filename_inwad ); snprintf( filename_inwadfixed, sizeof( filename_inwadfixed ), "textures/%s/%s.hlw", wadname,filename_inwad );
} }
//g_FuncTable.m_pfnSysFPrintf(SYS_WRN, " scanned %s\\%s\n", filename,filename_inwad); //g_FuncTable.m_pfnSysFPrintf(SYS_WRN, " scanned %s\\%s\n", filename,filename_inwad);
@ -389,7 +389,7 @@ void vfsInitDirectory( const char *path ){
continue; continue;
} }
sprintf( filename, "%s/%s", path, name ); snprintf( filename, sizeof( filename ), "%s/%s", path, name );
vfsInitPakFile( filename ); vfsInitPakFile( filename );
} }
g_dir_close( dir ); g_dir_close( dir );

View file

@ -1550,7 +1550,7 @@ void CheckName( face_t *fa, char *pname, size_t length ){
if ( strchr( fa->texdef.GetName(), ' ' ) ) { if ( strchr( fa->texdef.GetName(), ' ' ) ) {
char Msg1[1024]; char Msg1[1024];
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.", fa->texdef.GetName() ); snprintf( Msg1, sizeof( Msg1 ), "Can't save texture with spaces in name. Rename %s\nNOTE: This message may popup several times .. once for each buggy face detected.", fa->texdef.GetName() );
Sys_Printf( "%s\n", Msg1 ); Sys_Printf( "%s\n", Msg1 );
gtk_MessageBox( g_pParentWnd->m_pWidget, Msg1, "Error saving map", MB_OK ); gtk_MessageBox( g_pParentWnd->m_pWidget, Msg1, "Error saving map", MB_OK );
@ -3401,7 +3401,7 @@ void Brush_Move( brush_t *b, const vec3_t move, bool bSnap ){
if ( b->owner->eclass->fixedsize ) { if ( b->owner->eclass->fixedsize ) {
char text[64]; char text[64];
VectorAdd( b->owner->origin, move, b->owner->origin ); VectorAdd( b->owner->origin, move, b->owner->origin );
sprintf( text, "%i %i %i", snprintf( text, sizeof( text ), "%i %i %i",
(int)b->owner->origin[0], (int)b->owner->origin[1], (int)b->owner->origin[2] ); (int)b->owner->origin[0], (int)b->owner->origin[1], (int)b->owner->origin[2] );
SetKeyValue( b->owner, "origin", text ); SetKeyValue( b->owner, "origin", text );
//VectorAdd(b->maxs, b->mins, b->owner->origin); //VectorAdd(b->maxs, b->mins, b->owner->origin);

View file

@ -118,7 +118,7 @@ void Dialog::AddModalButton( GtkWidget *widget, int ret ) {
void Dialog::UpdateData( bool retrieve ){ void Dialog::UpdateData( bool retrieve ){
DLG_DATA *data; DLG_DATA *data;
GSList *lst; GSList *lst;
char buf[32]; char buf[64];
if ( retrieve ) { if ( retrieve ) {
for ( lst = m_pDataList; lst != NULL; lst = g_slist_next( lst ) ) for ( lst = m_pDataList; lst != NULL; lst = g_slist_next( lst ) )
@ -224,7 +224,7 @@ void Dialog::UpdateData( bool retrieve ){
gtk_entry_set_text( GTK_ENTRY( data->object ), txt ); gtk_entry_set_text( GTK_ENTRY( data->object ), txt );
} break; } break;
case DLG_ENTRY_FLOAT: case DLG_ENTRY_FLOAT:
sprintf( buf, "%g", ( *(float*)data->buffer ) ); snprintf( buf, sizeof( buf ), "%g", ( *(float*)data->buffer ) );
gtk_entry_set_text( GTK_ENTRY( data->object ), buf ); gtk_entry_set_text( GTK_ENTRY( data->object ), buf );
break; break;
case DLG_ENTRY_INT: case DLG_ENTRY_INT:

View file

@ -286,7 +286,7 @@ void EClass_InitForFileList( GSList *pFiles, _EClassTable *pTable ){
*/ */
eclass_t * EClass_Create( const char *name, float col1, float col2, float col3, const vec3_t *mins, const vec3_t *maxs, const char *comments ){ eclass_t * EClass_Create( const char *name, float col1, float col2, float col3, const vec3_t *mins, const vec3_t *maxs, const char *comments ){
eclass_t *e; eclass_t *e;
char color[128]; char color[256];
e = (eclass_t*)malloc( sizeof( *e ) ); e = (eclass_t*)malloc( sizeof( *e ) );
memset( e, 0, sizeof( *e ) ); memset( e, 0, sizeof( *e ) );

View file

@ -126,7 +126,7 @@ eclass_t *Eclass_InitFromText( char *text ){
int r, i; int r, i;
char parms[256], *p; char parms[256], *p;
eclass_t *e; eclass_t *e;
char color[128]; char color[256];
e = (eclass_t*)malloc( sizeof( *e ) ); e = (eclass_t*)malloc( sizeof( *e ) );
memset( e, 0, sizeof( *e ) ); memset( e, 0, sizeof( *e ) );

View file

@ -2739,7 +2739,7 @@ int DoBSInputDlg( const char *fields[5], float values[5] ){
gtk_box_pack_start( GTK_BOX( vbox ), entries[i], TRUE, TRUE, 0 ); gtk_box_pack_start( GTK_BOX( vbox ), entries[i], TRUE, TRUE, 0 );
gtk_widget_show( entries[i] ); gtk_widget_show( entries[i] );
char buf[32]; char buf[64];
sprintf( buf, "%f", values[i] ); sprintf( buf, "%f", values[i] );
gtk_entry_set_text( GTK_ENTRY( entries[i] ), buf ); gtk_entry_set_text( GTK_ENTRY( entries[i] ), buf );
} }

View file

@ -773,7 +773,7 @@ int main( int argc, char* argv[] ) {
// remove the game prefs files // remove the game prefs files
remove( g_PrefsDlg.m_inipath->str ); remove( g_PrefsDlg.m_inipath->str );
char buf[PATH_MAX]; char buf[PATH_MAX];
sprintf( buf, "%sSavedInfo.bin", g_PrefsDlg.m_rc_path->str ); snprintf( buf, sizeof( buf ), "%sSavedInfo.bin", g_PrefsDlg.m_rc_path->str );
remove( buf ); remove( buf );
// remove the global pref too // remove the global pref too
g_PrefsDlg.mGamesDialog.Reset(); g_PrefsDlg.mGamesDialog.Reset();
@ -962,11 +962,11 @@ void QE_ExpandBspString( char *bspaction, GPtrArray *out_array, char *mapname ){
if ( g_pGameDescription->mGameFile != "hl.game" && if ( g_pGameDescription->mGameFile != "hl.game" &&
*ValueForKey( g_qeglobals.d_project_entity,"gamename" ) != '\0' ) { *ValueForKey( g_qeglobals.d_project_entity,"gamename" ) != '\0' ) {
// set with fs_game // set with fs_game
sprintf( src, "-fs_game %s \"%s\"", ValueForKey( g_qeglobals.d_project_entity,"gamename" ), mapname ); snprintf( src, sizeof( src ), "-fs_game %s \"%s\"", ValueForKey( g_qeglobals.d_project_entity,"gamename" ), mapname );
} }
else else
{ {
sprintf( src, "\"%s\"", mapname ); snprintf( src, sizeof( src ), "\"%s\"", mapname );
} }
rsh[0] = 0; rsh[0] = 0;
@ -1169,7 +1169,7 @@ void RunBsp( char *command ){
#if defined ( __linux__ ) || defined ( __APPLE__ ) #if defined ( __linux__ ) || defined ( __APPLE__ )
// write qe3bsp.sh // write qe3bsp.sh
sprintf( batpath, "%sqe3bsp.sh", temppath ); snprintf( batpath, sizeof( batpath ), "%sqe3bsp.sh", temppath );
Sys_Printf( "Writing the compile script to '%s'\n", batpath ); Sys_Printf( "Writing the compile script to '%s'\n", batpath );
hFile = fopen( batpath, "w" ); hFile = fopen( batpath, "w" );
if ( !hFile ) { if ( !hFile ) {
@ -1182,7 +1182,7 @@ void RunBsp( char *command ){
#endif #endif
#ifdef _WIN32 #ifdef _WIN32
sprintf( batpath, "%sqe3bsp.bat", temppath ); snprintf( batpath, sizeof( batpath ), "%sqe3bsp.bat", temppath );
Sys_Printf( "Writing the compile script to '%s'\n", batpath ); Sys_Printf( "Writing the compile script to '%s'\n", batpath );
Sys_Printf( "The build output will be saved in '%sjunk.txt'\n", temppath ); Sys_Printf( "The build output will be saved in '%sjunk.txt'\n", temppath );
hFile = fopen( batpath, "w" ); hFile = fopen( batpath, "w" );

View file

@ -6242,7 +6242,7 @@ void MainFrame::OnMiscSelectentitycolor(){
} }
if ( inspector_mode == W_ENTITY && ( DoColor( COLOR_ENTITY ) ) ) { if ( inspector_mode == W_ENTITY && ( DoColor( COLOR_ENTITY ) ) ) {
char buffer[100]; char buffer[256];
sprintf( buffer, "%f %f %f", g_qeglobals.d_savedinfo.colors[COLOR_ENTITY][0], sprintf( buffer, "%f %f %f", g_qeglobals.d_savedinfo.colors[COLOR_ENTITY][0],
g_qeglobals.d_savedinfo.colors[COLOR_ENTITY][1], g_qeglobals.d_savedinfo.colors[COLOR_ENTITY][1],
g_qeglobals.d_savedinfo.colors[COLOR_ENTITY][2] ); g_qeglobals.d_savedinfo.colors[COLOR_ENTITY][2] );

View file

@ -291,7 +291,7 @@ void PatchDialog::BuildDialog(){
GtkWidget *dlg, *vbox, *vbox2, *hbox, *hbox2, *frame, *table, *label; GtkWidget *dlg, *vbox, *vbox2, *hbox, *hbox2, *frame, *table, *label;
GtkWidget *button, *entry, *spin, *combo; GtkWidget *button, *entry, *spin, *combo;
GtkAdjustment *adj; GtkAdjustment *adj;
char buf[32]; char buf[64];
dlg = m_pWidget; dlg = m_pWidget;
@ -465,7 +465,7 @@ void PatchDialog::BuildDialog(){
g_object_set_data( G_OBJECT( m_pWidget ), "hshift_entry", entry ); g_object_set_data( G_OBJECT( m_pWidget ), "hshift_entry", entry );
// we fill in this data, if no patch is selected the widgets are unmodified when the inspector is raised // we fill in this data, if no patch is selected the widgets are unmodified when the inspector is raised
// so we need to have at least one initialisation somewhere // so we need to have at least one initialisation somewhere
sprintf( buf, "%g", l_pPIIncrement->shift[0] ); snprintf( buf, sizeof( buf ), "%g", l_pPIIncrement->shift[0] );
gtk_entry_set_text( GTK_ENTRY( entry ), buf ); gtk_entry_set_text( GTK_ENTRY( entry ), buf );
adj = gtk_adjustment_new( 0, -8192, 8192, 1, 1, 0 ); adj = gtk_adjustment_new( 0, -8192, 8192, 1, 1, 0 );
@ -480,7 +480,7 @@ void PatchDialog::BuildDialog(){
entry = gtk_entry_new(); entry = gtk_entry_new();
gtk_grid_attach( GTK_GRID( table ), entry, 0, 1, 1, 1 ); gtk_grid_attach( GTK_GRID( table ), entry, 0, 1, 1, 1 );
gtk_widget_show( entry ); gtk_widget_show( entry );
sprintf( buf, "%g", l_pPIIncrement->shift[1] ); snprintf( buf, sizeof( buf ), "%g", l_pPIIncrement->shift[1] );
gtk_entry_set_text( GTK_ENTRY( entry ), buf ); gtk_entry_set_text( GTK_ENTRY( entry ), buf );
adj = gtk_adjustment_new( 0, -8192, 8192, 1, 1, 0 ); adj = gtk_adjustment_new( 0, -8192, 8192, 1, 1, 0 );
@ -495,7 +495,7 @@ void PatchDialog::BuildDialog(){
entry = gtk_entry_new(); entry = gtk_entry_new();
gtk_grid_attach( GTK_GRID( table ), entry, 0, 2, 1, 1 ); gtk_grid_attach( GTK_GRID( table ), entry, 0, 2, 1, 1 );
gtk_widget_show( entry ); gtk_widget_show( entry );
sprintf( buf, "%g", l_pPIIncrement->scale[0] ); snprintf( buf, sizeof( buf ), "%g", l_pPIIncrement->scale[0] );
gtk_entry_set_text( GTK_ENTRY( entry ), buf ); gtk_entry_set_text( GTK_ENTRY( entry ), buf );
adj = gtk_adjustment_new( 0, -1000, 1000, 1, 1, 0 ); adj = gtk_adjustment_new( 0, -1000, 1000, 1, 1, 0 );
@ -510,7 +510,7 @@ void PatchDialog::BuildDialog(){
entry = gtk_entry_new(); entry = gtk_entry_new();
gtk_grid_attach( GTK_GRID( table ), entry, 0, 3, 1, 1 ); gtk_grid_attach( GTK_GRID( table ), entry, 0, 3, 1, 1 );
gtk_widget_show( entry ); gtk_widget_show( entry );
sprintf( buf, "%g", l_pPIIncrement->scale[1] ); snprintf( buf, sizeof( buf ), "%g", l_pPIIncrement->scale[1] );
gtk_entry_set_text( GTK_ENTRY( entry ), buf ); gtk_entry_set_text( GTK_ENTRY( entry ), buf );
adj = gtk_adjustment_new( 0, -1000, 1000, 1, 1, 0 ); adj = gtk_adjustment_new( 0, -1000, 1000, 1, 1, 0 );
@ -525,7 +525,7 @@ void PatchDialog::BuildDialog(){
entry = gtk_entry_new(); entry = gtk_entry_new();
gtk_grid_attach( GTK_GRID( table ), entry, 0, 4, 1, 1 ); gtk_grid_attach( GTK_GRID( table ), entry, 0, 4, 1, 1 );
gtk_widget_show( entry ); gtk_widget_show( entry );
sprintf( buf, "%g", l_pPIIncrement->rotate ); snprintf( buf, sizeof( buf ), "%g", l_pPIIncrement->rotate );
gtk_entry_set_text( GTK_ENTRY( entry ), buf ); gtk_entry_set_text( GTK_ENTRY( entry ), buf );
adj = gtk_adjustment_new( 0, -1000, 1000, 1, 1, 0 ); // NOTE: Arnout - this really should be 360 but can't change it anymore as it could break existing maps adj = gtk_adjustment_new( 0, -1000, 1000, 1, 1, 0 ); // NOTE: Arnout - this really should be 360 but can't change it anymore as it could break existing maps

View file

@ -53,7 +53,7 @@ int QERApp_EClassScanDir( const char *path, void* hPlug ){
if ( dir != NULL ) { if ( dir != NULL ) {
while ( ( dirlist = readdir( dir ) ) != NULL ) while ( ( dirlist = readdir( dir ) ) != NULL )
{ {
sprintf( filename, "%s/%s", filebase, dirlist->d_name ); snprintf( filename, sizeof( filename ), "%s/%s", filebase, dirlist->d_name );
Eclass_ScanFile( filename ); Eclass_ScanFile( filename );
if ( eclass_found ) { if ( eclass_found ) {

View file

@ -4763,7 +4763,7 @@ void CheckName( patchMesh_t *p, char *pname, size_t length ){
// some manage to get long filename textures (with spaces) in their maps // some manage to get long filename textures (with spaces) in their maps
if ( strchr( p->pShader->getName(), ' ' ) ) { if ( strchr( p->pShader->getName(), ' ' ) ) {
char Msg1[1024]; char Msg1[1024];
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() ); snprintf( Msg1, sizeof( 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 ); Sys_Printf( "%s\n", Msg1 );
gtk_MessageBox( g_pParentWnd->m_pWidget, Msg1, "Error saving map", MB_OK ); gtk_MessageBox( g_pParentWnd->m_pWidget, Msg1, "Error saving map", MB_OK );
Q_strncpyz( pname, SHADER_NOT_FOUND, length ); Q_strncpyz( pname, SHADER_NOT_FOUND, length );

View file

@ -307,7 +307,7 @@ void CXMLPropertyBag::GetPref( const char *name, int *pV, int V ){
} }
else else
{ {
char s[10]; char s[12];
sprintf( s, "%d", V ); sprintf( s, "%d", V );
pNode = xmlNewChild( mpDocNode, NULL, (xmlChar *)"epair", (xmlChar *)s ); pNode = xmlNewChild( mpDocNode, NULL, (xmlChar *)"epair", (xmlChar *)s );
xmlSetProp( pNode, (xmlChar *)"name", (xmlChar *)name ); xmlSetProp( pNode, (xmlChar *)"name", (xmlChar *)name );
@ -347,7 +347,7 @@ void CXMLPropertyBag::GetPref( const char *name, float *pV, float V ){
} }
else else
{ {
char s[10]; char s[64];
sprintf( s, "%f", V ); sprintf( s, "%f", V );
pNode = xmlNewChild( mpDocNode, NULL, (xmlChar *)"epair", (xmlChar *)s ); pNode = xmlNewChild( mpDocNode, NULL, (xmlChar *)"epair", (xmlChar *)s );
xmlSetProp( pNode, (xmlChar *)"name", (xmlChar *)name ); xmlSetProp( pNode, (xmlChar *)"name", (xmlChar *)name );
@ -364,7 +364,7 @@ void CXMLPropertyBag::GetPref( const char *name, float* pV, float* V ){
} }
else else
{ {
char s[128]; char s[256];
sprintf( s, "%f %f %f", V[0], V[1], V[2] ); sprintf( s, "%f %f %f", V[0], V[1], V[2] );
pNode = xmlNewChild( mpDocNode, NULL, (xmlChar *)"epair", (xmlChar *)s ); pNode = xmlNewChild( mpDocNode, NULL, (xmlChar *)"epair", (xmlChar *)s );
xmlSetProp( pNode, (xmlChar *)"name", (xmlChar *)name ); xmlSetProp( pNode, (xmlChar *)"name", (xmlChar *)name );
@ -401,7 +401,7 @@ void CXMLPropertyBag::UpdatePrefTree(){
CPrefAssignment *pPref = &( *iPref ); CPrefAssignment *pPref = &( *iPref );
// look for the node // look for the node
xmlNodePtr pNode; xmlNodePtr pNode;
char s[64]; char s[256];
pNode = EpairForName( pPref->mName.GetBuffer() ); pNode = EpairForName( pPref->mName.GetBuffer() );
// we never expect that the node could not be found, because this is supposed to happen // we never expect that the node could not be found, because this is supposed to happen
@ -564,7 +564,7 @@ static void OnButtonClean( GtkWidget *widget, gpointer data ){
g_qeglobals.disable_ini = true; g_qeglobals.disable_ini = true;
remove( dlg->m_inipath->str ); remove( dlg->m_inipath->str );
char buf[PATH_MAX]; char buf[PATH_MAX];
sprintf( buf, "%sSavedInfo.bin", dlg->m_rc_path->str ); snprintf( buf, sizeof( buf ), "%sSavedInfo.bin", dlg->m_rc_path->str );
remove( buf ); remove( buf );
HandleCommand( NULL, GINT_TO_POINTER( ID_FILE_EXIT ) ); HandleCommand( NULL, GINT_TO_POINTER( ID_FILE_EXIT ) );
_exit( 0 ); _exit( 0 );
@ -2720,19 +2720,19 @@ void PrefsDlg::LoadTexdefPref( texdef_t* pTexdef, const char* pName ){
memset( pTexdef, 0, sizeof( texdef_t ) ); memset( pTexdef, 0, sizeof( texdef_t ) );
sprintf( buffer, "%s%s", pName, TD_SCALE1_KEY ); snprintf( buffer, sizeof( buffer ), "%s%s", pName, TD_SCALE1_KEY );
mLocalPrefs.GetPref( buffer, &pTexdef->scale[0], 0.5f ); mLocalPrefs.GetPref( buffer, &pTexdef->scale[0], 0.5f );
sprintf( buffer, "%s%s", pName, TD_SCALE2_KEY ); snprintf( buffer, sizeof( buffer ), "%s%s", pName, TD_SCALE2_KEY );
mLocalPrefs.GetPref( buffer, &pTexdef->scale[1], 0.5f ); mLocalPrefs.GetPref( buffer, &pTexdef->scale[1], 0.5f );
sprintf( buffer, "%s%s", pName, TD_SHIFT1_KEY ); snprintf( buffer, sizeof( buffer ), "%s%s", pName, TD_SHIFT1_KEY );
mLocalPrefs.GetPref( buffer, &pTexdef->shift[0], 8.f ); mLocalPrefs.GetPref( buffer, &pTexdef->shift[0], 8.f );
sprintf( buffer, "%s%s", pName, TD_SHIFT2_KEY ); snprintf( buffer, sizeof( buffer ), "%s%s", pName, TD_SHIFT2_KEY );
mLocalPrefs.GetPref( buffer, &pTexdef->shift[1], 8.f ); mLocalPrefs.GetPref( buffer, &pTexdef->shift[1], 8.f );
sprintf( buffer, "%s%s", pName, TD_ROTATE_KEY ); snprintf( buffer, sizeof( buffer ), "%s%s", pName, TD_ROTATE_KEY );
mLocalPrefs.GetPref( buffer, &pTexdef->rotate, 45 ); mLocalPrefs.GetPref( buffer, &pTexdef->rotate, 45 );
} }

View file

@ -192,7 +192,7 @@ bool WINAPI profile_save_int( const char *filename, const char *section, const c
} }
bool WINAPI profile_save_float( const char *filename, const char *section, const char *key, float value ){ bool WINAPI profile_save_float( const char *filename, const char *section, const char *key, float value ){
char buf[16]; char buf[64];
sprintf( buf, "%f", value ); sprintf( buf, "%f", value );
return save_var( filename, section, key, buf ); return save_var( filename, section, key, buf );
} }
@ -204,7 +204,7 @@ bool WINAPI profile_save_string( const char * filename, const char *section, con
bool profile_save_buffer( const char * rc_path, const char *name, void *buffer, guint32 size ){ bool profile_save_buffer( const char * rc_path, const char *name, void *buffer, guint32 size ){
bool ret = false; bool ret = false;
char filename[PATH_MAX]; char filename[PATH_MAX];
sprintf( filename, "%s/%s.bin", rc_path, name ); snprintf( filename, sizeof( filename ), "%s/%s.bin", rc_path, name );
FILE *f; FILE *f;
f = fopen( filename, "wb" ); f = fopen( filename, "wb" );
@ -222,7 +222,7 @@ bool profile_save_buffer( const char * rc_path, const char *name, void *buffer,
bool profile_load_buffer( const char * rc_path, const char *name, void *buffer, guint32 *plSize ){ bool profile_load_buffer( const char * rc_path, const char *name, void *buffer, guint32 *plSize ){
char filename[PATH_MAX]; char filename[PATH_MAX];
sprintf( filename, "%s/%s.bin", rc_path, name ); snprintf( filename, sizeof( filename ), "%s/%s.bin", rc_path, name );
bool ret = false; bool ret = false;
guint32 len; guint32 len;
FILE *f; FILE *f;

View file

@ -100,7 +100,7 @@ void WINAPI QE_CheckOpenGLForErrors( void ){
int i = qglGetError(); int i = qglGetError();
if ( i != GL_NO_ERROR ) { if ( i != GL_NO_ERROR ) {
if ( i == GL_OUT_OF_MEMORY ) { if ( i == GL_OUT_OF_MEMORY ) {
sprintf( strMsg, "OpenGL out of memory error %s\nDo you wish to save before exiting?", qgluErrorString( (GLenum)i ) ); snprintf( strMsg, sizeof( strMsg ), "OpenGL out of memory error %s\nDo you wish to save before exiting?", qgluErrorString( (GLenum)i ) );
if ( gtk_MessageBox( g_pParentWnd->m_pWidget, strMsg, "Radiant Error", MB_YESNO ) == IDYES ) { if ( gtk_MessageBox( g_pParentWnd->m_pWidget, strMsg, "Radiant Error", MB_YESNO ) == IDYES ) {
Map_SaveFile( NULL, false ); Map_SaveFile( NULL, false );
} }
@ -126,7 +126,7 @@ char *ExpandReletivePath( char *p ){
} }
base = ValueForKey( g_qeglobals.d_project_entity, "basepath" ); base = ValueForKey( g_qeglobals.d_project_entity, "basepath" );
sprintf( temp, "%s/%s", base, p ); snprintf( temp, sizeof( temp ), "%s/%s", base, p );
return temp; return temp;
} }
@ -197,7 +197,7 @@ void Map_Snapshot(){
char buf[PATH_MAX]; char buf[PATH_MAX];
//sprintf( buf, "%s.%i", strNewPath.GetBuffer(), nCount ); //sprintf( buf, "%s.%i", strNewPath.GetBuffer(), nCount );
// snapshot will now end with a known ext. // snapshot will now end with a known ext.
sprintf( buf, "%s.%i.%s", strNewPath.GetBuffer(), nCount, strOldEXT.GetBuffer() ); snprintf( buf, sizeof( buf ), "%s.%i.%s", strNewPath.GetBuffer(), nCount, strOldEXT.GetBuffer() );
strFile = buf; strFile = buf;
bGo = DoesFileExist( strFile, lSize ); bGo = DoesFileExist( strFile, lSize );
nCount++; nCount++;
@ -645,7 +645,7 @@ bool QE_LoadProject( const char *projectfile ){
if ( IntForKey( g_qeglobals.d_project_entity, "version" ) != PROJECT_VERSION ) { if ( IntForKey( g_qeglobals.d_project_entity, "version" ) != PROJECT_VERSION ) {
char strMsg[2048]; char strMsg[2048];
sprintf( strMsg, snprintf( strMsg, sizeof( strMsg ),
"The template project '%s' has version %d. The editor binary is configured for version %d.\n" "The template project '%s' has version %d. The editor binary is configured for version %d.\n"
"This indicates a problem in your setup.\n" "This indicates a problem in your setup.\n"
"I will keep going with this project till you fix this", "I will keep going with this project till you fix this",
@ -662,7 +662,7 @@ bool QE_LoadProject( const char *projectfile ){
char pUser[PATH_MAX]; char pUser[PATH_MAX];
while ( 1 ) while ( 1 )
{ {
sprintf( pUser, "%suser%d." PROJECT_FILETYPE, buf, counter ); snprintf( pUser, sizeof( pUser ), "%suser%d." PROJECT_FILETYPE, buf, counter );
counter++; counter++;
if ( access( pUser, R_OK ) != 0 ) { if ( access( pUser, R_OK ) != 0 ) {
// this is the one // this is the one
@ -1266,7 +1266,7 @@ void Sys_MarkMapModified( void ){
if ( modified != 1 ) { if ( modified != 1 ) {
modified = true; // mark the map as changed modified = true; // mark the map as changed
sprintf( title, "%s *", currentmap ); snprintf( title, sizeof( title ), "%s *", currentmap );
QE_ConvertDOSToUnixName( title, title ); QE_ConvertDOSToUnixName( title, title );
Sys_SetTitle( title ); Sys_SetTitle( title );

View file

@ -929,11 +929,8 @@ void SurfaceDlg::SetTexMods(){
} }
GtkAdjustment *adjust = gtk_spin_button_get_adjustment( GTK_SPIN_BUTTON( spin ) ); GtkAdjustment *adjust = gtk_spin_button_get_adjustment( GTK_SPIN_BUTTON( spin ) );
gtk_adjustment_set_step_increment( adjust, l_pIncrement->shift[0] ); gtk_adjustment_set_step_increment( adjust, l_pIncrement->shift[0] );
char buf[10]; // got into snprintf paranoia after BoundChecker detected a stack overrun char buf[64]; // got into snprintf paranoia after BoundChecker detected a stack overrun
#if defined(_MSC_VER) && _MSC_VER<1900 && !(defined snprintf) snprintf( buf, sizeof( buf ), "%g", l_pIncrement->shift[0] );
#define snprintf _snprintf
#endif
snprintf( buf, 10, "%g", l_pIncrement->shift[0] );
gtk_entry_set_text( GTK_ENTRY( GetDlgWidget( "hshift_inc" ) ), buf ); gtk_entry_set_text( GTK_ENTRY( GetDlgWidget( "hshift_inc" ) ), buf );
spin = GTK_SPIN_BUTTON( GetDlgWidget( "vshift" ) ); spin = GTK_SPIN_BUTTON( GetDlgWidget( "vshift" ) );
@ -946,7 +943,7 @@ void SurfaceDlg::SetTexMods(){
} }
adjust = gtk_spin_button_get_adjustment( GTK_SPIN_BUTTON( spin ) ); adjust = gtk_spin_button_get_adjustment( GTK_SPIN_BUTTON( spin ) );
gtk_adjustment_set_step_increment( adjust, l_pIncrement->shift[1] ); gtk_adjustment_set_step_increment( adjust, l_pIncrement->shift[1] );
snprintf( buf, 10, "%g", l_pIncrement->shift[1] ); snprintf( buf, sizeof( buf ), "%g", l_pIncrement->shift[1] );
gtk_entry_set_text( GTK_ENTRY( GetDlgWidget( "vshift_inc" ) ), buf ); gtk_entry_set_text( GTK_ENTRY( GetDlgWidget( "vshift_inc" ) ), buf );
spin = GTK_SPIN_BUTTON( GetDlgWidget( "hscale" ) ); spin = GTK_SPIN_BUTTON( GetDlgWidget( "hscale" ) );
@ -955,7 +952,7 @@ void SurfaceDlg::SetTexMods(){
adjust = gtk_spin_button_get_adjustment( GTK_SPIN_BUTTON( spin ) ); adjust = gtk_spin_button_get_adjustment( GTK_SPIN_BUTTON( spin ) );
gtk_adjustment_set_step_increment( adjust, l_pIncrement->scale[0] ); gtk_adjustment_set_step_increment( adjust, l_pIncrement->scale[0] );
snprintf( buf, 10, "%g", l_pIncrement->scale[0] ); snprintf( buf, sizeof( buf ), "%g", l_pIncrement->scale[0] );
gtk_entry_set_text( GTK_ENTRY( GetDlgWidget( "hscale_inc" ) ), buf ); gtk_entry_set_text( GTK_ENTRY( GetDlgWidget( "hscale_inc" ) ), buf );
spin = GTK_SPIN_BUTTON( GetDlgWidget( "vscale" ) ); spin = GTK_SPIN_BUTTON( GetDlgWidget( "vscale" ) );
@ -964,7 +961,7 @@ void SurfaceDlg::SetTexMods(){
adjust = gtk_spin_button_get_adjustment( GTK_SPIN_BUTTON( spin ) ); adjust = gtk_spin_button_get_adjustment( GTK_SPIN_BUTTON( spin ) );
gtk_adjustment_set_step_increment( adjust, l_pIncrement->scale[1] ); gtk_adjustment_set_step_increment( adjust, l_pIncrement->scale[1] );
snprintf( buf, 10, "%g", l_pIncrement->scale[1] ); snprintf( buf, sizeof( buf ), "%g", l_pIncrement->scale[1] );
gtk_entry_set_text( GTK_ENTRY( GetDlgWidget( "vscale_inc" ) ), buf ); gtk_entry_set_text( GTK_ENTRY( GetDlgWidget( "vscale_inc" ) ), buf );
//++timo compute BProtate as int .. //++timo compute BProtate as int ..
@ -974,7 +971,7 @@ void SurfaceDlg::SetTexMods(){
adjust = gtk_spin_button_get_adjustment( GTK_SPIN_BUTTON( spin ) ); adjust = gtk_spin_button_get_adjustment( GTK_SPIN_BUTTON( spin ) );
gtk_adjustment_set_step_increment( adjust, l_pIncrement->rotate ); gtk_adjustment_set_step_increment( adjust, l_pIncrement->rotate );
snprintf( buf, 10, "%g", l_pIncrement->rotate ); snprintf( buf, sizeof( buf ), "%g", l_pIncrement->rotate );
gtk_entry_set_text( GTK_ENTRY( GetDlgWidget( "rotate_inc" ) ), buf ); gtk_entry_set_text( GTK_ENTRY( GetDlgWidget( "rotate_inc" ) ), buf );
g_bListenChanged = true; g_bListenChanged = true;

View file

@ -518,7 +518,7 @@ void BuildShaderList(){
bool found = false; bool found = false;
// each token should be a shader filename // each token should be a shader filename
sprintf( dirstring, "%s.shader", token ); snprintf( dirstring, sizeof( dirstring ), "%s.shader", token );
for ( tmp = l_shaderfiles; tmp != NULL; tmp = tmp->next ) for ( tmp = l_shaderfiles; tmp != NULL; tmp = tmp->next )
{ {
@ -884,7 +884,7 @@ void Texture_ShowDirectory(){
// need this function "GSList *lst SynapseServer::GetMinorList(char *major_name);" // need this function "GSList *lst SynapseServer::GetMinorList(char *major_name);"
sprintf( dirstring, "textures/%s", texture_directory ); snprintf( dirstring, sizeof( dirstring ), "textures/%s", texture_directory );
g_ImageManager.BeginExtensionsScan(); g_ImageManager.BeginExtensionsScan();
const char* ext; const char* ext;
while ( ( ext = g_ImageManager.GetNextExtension() ) != NULL ) while ( ( ext = g_ImageManager.GetNextExtension() ) != NULL )
@ -894,7 +894,7 @@ void Texture_ShowDirectory(){
for ( temp = files; temp; temp = temp->next ) for ( temp = files; temp; temp = temp->next )
{ {
sprintf( name, "%s%s", texture_directory, (char*)temp->data ); snprintf( name, sizeof( name ), "%s%s", texture_directory, (char*)temp->data );
StripExtension( name ); StripExtension( name );
strTemp = name; strTemp = name;
@ -927,7 +927,7 @@ void Texture_ShowDirectory(){
// build a texture name that fits the conventions for qtexture_t::name // build a texture name that fits the conventions for qtexture_t::name
char stdName[1024]; char stdName[1024];
sprintf( stdName, "textures/%s", name ); snprintf( stdName, sizeof( stdName ), "textures/%s", name );
// check if this texture doesn't have a shader // check if this texture doesn't have a shader
if ( !QERApp_ActiveShader_ForTextureName( stdName ) ) { if ( !QERApp_ActiveShader_ForTextureName( stdName ) ) {
QERApp_CreateShader_ForTextureName( stdName ); QERApp_CreateShader_ForTextureName( stdName );
@ -943,7 +943,7 @@ void Texture_ShowDirectory(){
// sort for displaying // sort for displaying
QERApp_SortActiveShaders(); QERApp_SortActiveShaders();
sprintf( name, "Textures: %s", texture_directory ); snprintf( name, sizeof( name ), "Textures: %s", texture_directory );
gtk_window_set_title( GTK_WINDOW( g_qeglobals_gui.d_entity ), name ); gtk_window_set_title( GTK_WINDOW( g_qeglobals_gui.d_entity ), name );
// select the first texture in the list // select the first texture in the list
@ -1158,7 +1158,7 @@ void Texture_ShowStartupShaders(){
bool found = false; bool found = false;
// each token should be a shader filename // each token should be a shader filename
sprintf( dirstring, "%s.shader", token ); snprintf( dirstring, sizeof( dirstring ), "%s.shader", token );
for ( tmp = shaderfiles; tmp != NULL; tmp = tmp->next ) for ( tmp = shaderfiles; tmp != NULL; tmp = tmp->next )
{ {

View file

@ -423,7 +423,7 @@ void CreateEntityFromName( const char* name, const vec3_t origin ){
// prompt.GotoDlgCtrl( pWnd ); // prompt.GotoDlgCtrl( pWnd );
if ( DoLightIntensityDlg( &intensity ) == IDOK ) { if ( DoLightIntensityDlg( &intensity ) == IDOK ) {
g_PrefsDlg.m_iLastLightIntensity = intensity; g_PrefsDlg.m_iLastLightIntensity = intensity;
char buf[10]; char buf[12];
sprintf( buf, "%d", intensity ); sprintf( buf, "%d", intensity );
SetKeyValue( e, "light", buf ); SetKeyValue( e, "light", buf );
} }

View file

@ -473,7 +473,7 @@ static void ASE_KeyMAP_DIFFUSE( const char *token ){
} }
else else
{ {
sprintf( ase.materials[ase.numMaterials].name, "(not converted: '%s')", bitmap ); snprintf( ase.materials[ase.numMaterials].name, sizeof( ase.materials[ase.numMaterials].name ), "(not converted: '%s')", bitmap );
Sys_Printf( "WARNING: illegal material name '%s'\n", bitmap ); Sys_Printf( "WARNING: illegal material name '%s'\n", bitmap );
} }
} }

View file

@ -124,7 +124,7 @@ void ExpandWildcards( int *argc, char ***argv ){
do do
{ {
sprintf( filename, "%s%s", filebase, fileinfo.name ); snprintf( filename, sizeof( filename ), "%s%s", filebase, fileinfo.name );
ex_argv[ex_argc++] = copystring( filename ); ex_argv[ex_argc++] = copystring( filename );
} while ( _findnext( handle, &fileinfo ) != -1 ); } while ( _findnext( handle, &fileinfo ) != -1 );
@ -248,7 +248,7 @@ char *ExpandPath( const char *path ){
Q_strncpyz( full, path, sizeof( full ) ); Q_strncpyz( full, path, sizeof( full ) );
return full; return full;
} }
sprintf( full, "%s%s", qdir, path ); snprintf( full, sizeof( full ), "%s%s", qdir, path );
return full; return full;
} }

View file

@ -150,7 +150,7 @@ void xml_Select( char *msg, int entitynum, int brushnum, qboolean bError ){
char level[2]; char level[2];
// now build a proper "select" XML node // now build a proper "select" XML node
sprintf( buf, "Entity %i, Brush %i: %s", entitynum, brushnum, msg ); snprintf( buf, sizeof( buf ), "Entity %i, Brush %i: %s", entitynum, brushnum, msg );
node = xmlNewNode( NULL, "select" ); node = xmlNewNode( NULL, "select" );
xmlNodeSetContent( node, buf ); xmlNodeSetContent( node, buf );
level[0] = (int)'0' + ( bError ? SYS_ERR : SYS_WRN ) ; level[0] = (int)'0' + ( bError ? SYS_ERR : SYS_WRN ) ;
@ -163,7 +163,7 @@ void xml_Select( char *msg, int entitynum, int brushnum, qboolean bError ){
xmlAddChild( node, select ); xmlAddChild( node, select );
xml_SendNode( node ); xml_SendNode( node );
sprintf( buf, "Entity %i, Brush %i: %s", entitynum, brushnum, msg ); snprintf( buf, sizeof( buf ), "Entity %i, Brush %i: %s", entitynum, brushnum, msg );
if ( bError ) { if ( bError ) {
Error( buf ); Error( buf );
} }
@ -184,13 +184,13 @@ void xml_Point( char *msg, vec3_t pt ){
level[1] = 0; level[1] = 0;
xmlSetProp( node, "level", (char *)&level ); xmlSetProp( node, "level", (char *)&level );
// a 'point' node // a 'point' node
sprintf( buf, "%g %g %g", pt[0], pt[1], pt[2] ); snprintf( buf, sizeof( buf ), "%g %g %g", pt[0], pt[1], pt[2] );
point = xmlNewNode( NULL, "point" ); point = xmlNewNode( NULL, "point" );
xmlNodeSetContent( point, buf ); xmlNodeSetContent( point, buf );
xmlAddChild( node, point ); xmlAddChild( node, point );
xml_SendNode( node ); xml_SendNode( node );
sprintf( buf, "%s (%g %g %g)", msg, pt[0], pt[1], pt[2] ); snprintf( buf, sizeof( buf ), "%s (%g %g %g)", msg, pt[0], pt[1], pt[2] );
Error( buf ); Error( buf );
} }
@ -211,7 +211,7 @@ void xml_Winding( char *msg, vec3_t p[], int numpoints, qboolean die ){
sprintf( buf, "%i ", numpoints ); sprintf( buf, "%i ", numpoints );
for ( i = 0; i < numpoints; i++ ) for ( i = 0; i < numpoints; i++ )
{ {
sprintf( smlbuf, "(%g %g %g)", p[i][0], p[i][1], p[i][2] ); snprintf( smlbuf, sizeof( smlbuf ), "(%g %g %g)", p[i][0], p[i][1], p[i][2] );
// don't overflow // don't overflow
if ( strlen( buf ) + strlen( smlbuf ) > WINDING_BUFSIZE ) { if ( strlen( buf ) + strlen( smlbuf ) > WINDING_BUFSIZE ) {
break; break;
@ -349,7 +349,7 @@ void Error( const char *error, ... ){
vsnprintf( tmp, sizeof( tmp ), error, argptr ); vsnprintf( tmp, sizeof( tmp ), error, argptr );
va_end( argptr ); va_end( argptr );
sprintf( out_buffer, "************ ERROR ************\n%s\n", tmp ); snprintf( out_buffer, sizeof( out_buffer ), "************ ERROR ************\n%s\n", tmp );
FPrintf( SYS_ERR, out_buffer ); FPrintf( SYS_ERR, out_buffer );

View file

@ -201,7 +201,7 @@ void vfsInitDirectory( const char *path ){
} }
} }
sprintf( filename, "%s/%s", path, dirlist ); snprintf( filename, sizeof( filename ), "%s/%s", path, dirlist );
vfsInitPakFile( filename ); vfsInitPakFile( filename );
g_free( dirlist ); g_free( dirlist );

View file

@ -149,7 +149,7 @@ static void LoadMaterialList( FILE *fp, long thisChunkLen, _3DSMaterial_t *pMat
Q_getwd( curdir ); Q_getwd( curdir );
if ( mat.texture[0] ) { if ( mat.texture[0] ) {
sprintf( buffer, "%s%s", curdir, mat.texture ); snprintf( buffer, sizeof( buffer ), "%s%s", curdir, mat.texture );
if ( strstr( buffer, gamedir + 1 ) ) { if ( strstr( buffer, gamedir + 1 ) ) {
strcpy( mat.texture, strstr( buffer, gamedir + 1 ) + strlen( gamedir ) - 1 ); strcpy( mat.texture, strstr( buffer, gamedir + 1 ) + strlen( gamedir ) - 1 );
} }
@ -159,7 +159,7 @@ static void LoadMaterialList( FILE *fp, long thisChunkLen, _3DSMaterial_t *pMat
} }
if ( mat.specular[0] ) { if ( mat.specular[0] ) {
sprintf( buffer, "%s%s", curdir, mat.specular ); snprintf( buffer, sizeof( buffer ), "%s%s", curdir, mat.specular );
if ( strstr( buffer, gamedir + 1 ) ) { if ( strstr( buffer, gamedir + 1 ) ) {
strcpy( mat.specular, strstr( buffer, gamedir + 1 ) + strlen( gamedir ) - 1 ); strcpy( mat.specular, strstr( buffer, gamedir + 1 ) + strlen( gamedir ) - 1 );
} }
@ -169,7 +169,7 @@ static void LoadMaterialList( FILE *fp, long thisChunkLen, _3DSMaterial_t *pMat
} }
if ( mat.bump[0] ) { if ( mat.bump[0] ) {
sprintf( buffer, "%s%s", curdir, mat.bump ); snprintf( buffer, sizeof( buffer ), "%s%s", curdir, mat.bump );
if ( strstr( buffer, gamedir + 1 ) ) { if ( strstr( buffer, gamedir + 1 ) ) {
strcpy( mat.bump, strstr( buffer, gamedir + 1 ) + strlen( gamedir ) - 1 ); strcpy( mat.bump, strstr( buffer, gamedir + 1 ) + strlen( gamedir ) - 1 );
} }
@ -179,7 +179,7 @@ static void LoadMaterialList( FILE *fp, long thisChunkLen, _3DSMaterial_t *pMat
} }
if ( mat.reflection[0] ) { if ( mat.reflection[0] ) {
sprintf( buffer, "%s%s", curdir, mat.reflection ); snprintf( buffer, sizeof( buffer ), "%s%s", curdir, mat.reflection );
if ( strstr( buffer, gamedir + 1 ) ) { if ( strstr( buffer, gamedir + 1 ) ) {
strcpy( mat.reflection, strstr( buffer, gamedir + 1 ) + strlen( gamedir ) - 1 ); strcpy( mat.reflection, strstr( buffer, gamedir + 1 ) + strlen( gamedir ) - 1 );
} }
@ -189,7 +189,7 @@ static void LoadMaterialList( FILE *fp, long thisChunkLen, _3DSMaterial_t *pMat
} }
if ( mat.opacity[0] ) { if ( mat.opacity[0] ) {
sprintf( buffer, "%s%s", curdir, mat.opacity ); snprintf( buffer, sizeof( buffer ), "%s%s", curdir, mat.opacity );
if ( strstr( buffer, gamedir + 1 ) ) { if ( strstr( buffer, gamedir + 1 ) ) {
strcpy( mat.opacity, strstr( buffer, gamedir + 1 ) + strlen( gamedir ) - 1 ); strcpy( mat.opacity, strstr( buffer, gamedir + 1 ) + strlen( gamedir ) - 1 );
} }

View file

@ -851,10 +851,10 @@ cblock_t LoadFrame( char *base, int frame, int digits, byte **palette ){
ten0 = frame % 10; ten0 = frame % 10;
if ( digits == 4 ) { if ( digits == 4 ) {
sprintf( name, "%svideo/%s/%s%i%i%i%i.tga", gamedir, base, base, ten3, ten2, ten1, ten0 ); snprintf( name, sizeof( name ), "%svideo/%s/%s%i%i%i%i.tga", gamedir, base, base, ten3, ten2, ten1, ten0 );
} }
else{ else{
sprintf( name, "%svideo/%s/%s%i%i%i.tga", gamedir, base, base, ten2, ten1, ten0 ); snprintf( name, sizeof( name ), "%svideo/%s/%s%i%i%i.tga", gamedir, base, base, ten2, ten1, ten0 );
} }
f = fopen( name, "rb" ); f = fopen( name, "rb" );

View file

@ -127,7 +127,7 @@ static void ProcessAdvertisements( void ) {
static void SetCloneModelNumbers( void ){ static void SetCloneModelNumbers( void ){
int i, j; int i, j;
int models; int models;
char modelValue[ 10 ]; char modelValue[ 16 ];
const char *value, *value2, *value3; const char *value, *value2, *value3;
@ -420,7 +420,7 @@ void ProcessWorldModel( void ){
/* ydnar: fog hull */ /* ydnar: fog hull */
value = ValueForKey( &entities[ 0 ], "_foghull" ); value = ValueForKey( &entities[ 0 ], "_foghull" );
if ( value[ 0 ] != '\0' ) { if ( value[ 0 ] != '\0' ) {
sprintf( shader, "textures/%s", value ); snprintf( shader, sizeof( shader ), "textures/%s", value );
MakeFogHullSurfs( e, tree, shader ); MakeFogHullSurfs( e, tree, shader );
} }
@ -630,7 +630,7 @@ void OnlyEnts( void ){
/* note it */ /* note it */
Sys_Printf( "--- OnlyEnts ---\n" ); Sys_Printf( "--- OnlyEnts ---\n" );
sprintf( out, "%s.bsp", source ); snprintf( out, sizeof( out ), "%s.bsp", source );
LoadBSPFile( out ); LoadBSPFile( out );
numEntities = 0; numEntities = 0;
@ -864,9 +864,9 @@ int BSPMain( int argc, char **argv ){
SetDefaultSampleSize( sampleSize ); SetDefaultSampleSize( sampleSize );
/* delete portal, line and surface files */ /* delete portal, line and surface files */
sprintf( path, "%s.prt", source ); snprintf( path, sizeof( path ), "%s.prt", source );
remove( path ); remove( path );
sprintf( path, "%s.lin", source ); snprintf( path, sizeof( path ), "%s.lin", source );
remove( path ); remove( path );
//% sprintf( path, "%s.srf", source ); /* ydnar */ //% sprintf( path, "%s.srf", source ); /* ydnar */
//% remove( path ); //% remove( path );
@ -875,7 +875,7 @@ int BSPMain( int argc, char **argv ){
Q_strncpyz( name, ExpandArg( argv[ i ] ), sizeof( name ) ); Q_strncpyz( name, ExpandArg( argv[ i ] ), sizeof( name ) );
if ( strcmp( name + strlen( name ) - 4, ".reg" ) ) { if ( strcmp( name + strlen( name ) - 4, ".reg" ) ) {
/* if we are doing a full map, delete the last saved region map */ /* if we are doing a full map, delete the last saved region map */
sprintf( path, "%s.reg", source ); snprintf( path, sizeof( path ), "%s.reg", source );
remove( path ); remove( path );
DefaultExtension( name, ".map", sizeof( name ) ); /* might be .reg */ DefaultExtension( name, ".map", sizeof( name ) ); /* might be .reg */
} }

View file

@ -391,7 +391,7 @@ void WriteBSPFile( const char *filename ){
/* make fake temp name so existing bsp file isn't damaged in case write process fails */ /* make fake temp name so existing bsp file isn't damaged in case write process fails */
time( &tm ); time( &tm );
sprintf( tempname, "%s.%08X", filename, (int) tm ); snprintf( tempname, sizeof( tempname ), "%s.%08X", filename, (int) tm );
/* byteswap, write the bsp, then swap back so it can be manipulated further */ /* byteswap, write the bsp, then swap back so it can be manipulated further */
SwapBSPFile(); SwapBSPFile();
@ -639,8 +639,8 @@ void UnparseEntities( void ){
StripTrailing( value ); StripTrailing( value );
/* add to buffer */ /* add to buffer */
sprintf( line, "\"%s\" \"%s\"\n", key, value ); snprintf( line, sizeof( line ), "\"%s\" \"%s\"\n", key, value );
strcat( end, line ); strncat( end, line, sizeof( bspEntData ) + bspEntData - end );
end += strlen( line ); end += strlen( line );
} }

View file

@ -251,7 +251,7 @@ static void ConvertShader( FILE *f, bspShader_t *shader, int shaderNum ){
Q_strncpyz( filename, si->shaderImage->filename, sizeof( filename ) ); Q_strncpyz( filename, si->shaderImage->filename, sizeof( filename ) );
} }
else{ else{
sprintf( filename, "%s.tga", si->shader ); snprintf( filename, sizeof( filename ), "%s.tga", si->shader );
} }
for ( c = filename; *c != '\0'; c++ ) for ( c = filename; *c != '\0'; c++ )
if ( *c == '/' ) { if ( *c == '/' ) {

View file

@ -76,7 +76,7 @@ xmlNodePtr LeakFile( tree_t *tree ){
// //
// write the points to the file // write the points to the file
// //
sprintf( filename, "%s.lin", source ); snprintf( filename, sizeof( filename ), "%s.lin", source );
linefile = fopen( filename, "w" ); linefile = fopen( filename, "w" );
if ( !linefile ) { if ( !linefile ) {
Error( "Couldn't open %s\n", filename ); Error( "Couldn't open %s\n", filename );

View file

@ -1527,7 +1527,7 @@ void SetupGrid( void ){
int i, j; int i, j;
vec3_t maxs, oldGridSize; vec3_t maxs, oldGridSize;
const char *value; const char *value;
char temp[ 64 ]; char temp[ 256 ];
/* don't do this if not grid lighting */ /* don't do this if not grid lighting */
@ -1573,7 +1573,7 @@ void SetupGrid( void ){
/* different? */ /* different? */
if ( !VectorCompare( gridSize, oldGridSize ) ) { if ( !VectorCompare( gridSize, oldGridSize ) ) {
sprintf( temp, "%.0f %.0f %.0f", gridSize[ 0 ], gridSize[ 1 ], gridSize[ 2 ] ); snprintf( temp, sizeof( temp ), "%.0f %.0f %.0f", gridSize[ 0 ], gridSize[ 1 ], gridSize[ 2 ] );
SetKeyValue( &entities[ 0 ], "gridsize", (const char*) temp ); SetKeyValue( &entities[ 0 ], "gridsize", (const char*) temp );
Sys_FPrintf( SYS_VRB, "Storing adjusted grid size\n" ); Sys_FPrintf( SYS_VRB, "Storing adjusted grid size\n" );
} }

View file

@ -138,7 +138,7 @@ void ExportLightmaps( void ){
for ( i = 0, lightmap = bspLightBytes; lightmap < ( bspLightBytes + numBSPLightBytes ); i++, lightmap += ( game->lightmapSize * game->lightmapSize * 3 ) ) for ( i = 0, lightmap = bspLightBytes; lightmap < ( bspLightBytes + numBSPLightBytes ); i++, lightmap += ( game->lightmapSize * game->lightmapSize * 3 ) )
{ {
/* write a tga image out */ /* write a tga image out */
sprintf( filename, "%s/lightmap_%04d.tga", dirname, i ); snprintf( filename, sizeof( filename ), "%s/lightmap_%04d.tga", dirname, i );
Sys_Printf( "Writing %s\n", filename ); Sys_Printf( "Writing %s\n", filename );
WriteTGA24( filename, lightmap, game->lightmapSize, game->lightmapSize, qfalse ); WriteTGA24( filename, lightmap, game->lightmapSize, game->lightmapSize, qfalse );
} }
@ -221,7 +221,7 @@ int ImportLightmapsMain( int argc, char **argv ){
for ( i = 0, lightmap = bspLightBytes; lightmap < ( bspLightBytes + numBSPLightBytes ); i++, lightmap += ( game->lightmapSize * game->lightmapSize * 3 ) ) for ( i = 0, lightmap = bspLightBytes; lightmap < ( bspLightBytes + numBSPLightBytes ); i++, lightmap += ( game->lightmapSize * game->lightmapSize * 3 ) )
{ {
/* read a tga image */ /* read a tga image */
sprintf( filename, "%s/lightmap_%04d.tga", dirname, i ); snprintf( filename, sizeof( filename ), "%s/lightmap_%04d.tga", dirname, i );
Sys_Printf( "Loading %s\n", filename ); Sys_Printf( "Loading %s\n", filename );
buffer = NULL; buffer = NULL;
len = vfsLoadFile( filename, (void*) &buffer, -1 ); len = vfsLoadFile( filename, (void*) &buffer, -1 );
@ -2869,14 +2869,14 @@ void StoreSurfaceLightmaps( void ){
olm->extLightmapNum = numExtLightmaps; olm->extLightmapNum = numExtLightmaps;
/* write lightmap */ /* write lightmap */
sprintf( filename, "%s/" EXTERNAL_LIGHTMAP, dirname, numExtLightmaps ); snprintf( filename, sizeof( filename ), "%s/" EXTERNAL_LIGHTMAP, dirname, numExtLightmaps );
Sys_FPrintf( SYS_VRB, "\nwriting %s", filename ); Sys_FPrintf( SYS_VRB, "\nwriting %s", filename );
WriteTGA24( filename, olm->bspLightBytes, olm->customWidth, olm->customHeight, qtrue ); WriteTGA24( filename, olm->bspLightBytes, olm->customWidth, olm->customHeight, qtrue );
numExtLightmaps++; numExtLightmaps++;
/* write deluxemap */ /* write deluxemap */
if ( deluxemap ) { if ( deluxemap ) {
sprintf( filename, "%s/" EXTERNAL_LIGHTMAP, dirname, numExtLightmaps ); snprintf( filename, sizeof( filename ), "%s/" EXTERNAL_LIGHTMAP, dirname, numExtLightmaps );
Sys_FPrintf( SYS_VRB, "\nwriting %s", filename ); Sys_FPrintf( SYS_VRB, "\nwriting %s", filename );
WriteTGA24( filename, olm->bspDirBytes, olm->customWidth, olm->customHeight, qtrue ); WriteTGA24( filename, olm->bspDirBytes, olm->customWidth, olm->customHeight, qtrue );
numExtLightmaps++; numExtLightmaps++;
@ -2896,7 +2896,7 @@ void StoreSurfaceLightmaps( void ){
for ( i = numExtLightmaps; i; i++ ) for ( i = numExtLightmaps; i; i++ )
{ {
/* determine if file exists */ /* determine if file exists */
sprintf( filename, "%s/" EXTERNAL_LIGHTMAP, dirname, i ); snprintf( filename, sizeof( filename ), "%s/" EXTERNAL_LIGHTMAP, dirname, i );
if ( !FileExists( filename ) ) { if ( !FileExists( filename ) ) {
break; break;
} }
@ -3042,7 +3042,7 @@ void StoreSurfaceLightmaps( void ){
/* surfaces with styled lightmaps and a style marker get a custom generated shader (fixme: make this work with external lightmaps) */ /* surfaces with styled lightmaps and a style marker get a custom generated shader (fixme: make this work with external lightmaps) */
if ( olm != NULL && lm != NULL && lm->styles[ 1 ] != LS_NONE && game->load != LoadRBSPFile ) { //% info->si->styleMarker > 0 ) if ( olm != NULL && lm != NULL && lm->styles[ 1 ] != LS_NONE && game->load != LoadRBSPFile ) { //% info->si->styleMarker > 0 )
qboolean dfEqual; qboolean dfEqual;
char key[ 32 ], styleStage[ 512 ], styleStages[ 4096 ], rgbGen[ 128 ], alphaGen[ 128 ]; char key[ 32 ], styleStage[ 512 ], styleStages[ 4096 ], rgbGen[ 256 ], alphaGen[ 256 ];
/* setup */ /* setup */
@ -3074,7 +3074,7 @@ void StoreSurfaceLightmaps( void ){
strcpy( lightmapName, "$lightmap" ); strcpy( lightmapName, "$lightmap" );
} }
else{ else{
sprintf( lightmapName, "maps/%s/" EXTERNAL_LIGHTMAP, mapName, olm->extLightmapNum ); snprintf( lightmapName, sizeof( lightmapName ), "maps/%s/" EXTERNAL_LIGHTMAP, mapName, olm->extLightmapNum );
} }
/* get rgbgen string */ /* get rgbgen string */
@ -3087,7 +3087,7 @@ void StoreSurfaceLightmaps( void ){
} }
rgbGen[ 0 ] = '\0'; rgbGen[ 0 ] = '\0';
if ( rgbGenValues[ style ][ 0 ] != '\0' ) { if ( rgbGenValues[ style ][ 0 ] != '\0' ) {
sprintf( rgbGen, "\t\trgbGen %s // style %d\n", rgbGenValues[ style ], style ); snprintf( rgbGen, sizeof( rgbGen ), "\t\trgbGen %s // style %d\n", rgbGenValues[ style ], style );
} }
else{ else{
rgbGen[ 0 ] = '\0'; rgbGen[ 0 ] = '\0';
@ -3099,7 +3099,7 @@ void StoreSurfaceLightmaps( void ){
alphaGenValues[ style ] = (char*) ValueForKey( &entities[ 0 ], key ); alphaGenValues[ style ] = (char*) ValueForKey( &entities[ 0 ], key );
} }
if ( alphaGenValues[ style ][ 0 ] != '\0' ) { if ( alphaGenValues[ style ][ 0 ] != '\0' ) {
sprintf( alphaGen, "\t\talphaGen %s // style %d\n", alphaGenValues[ style ], style ); snprintf( alphaGen, sizeof( alphaGen ), "\t\talphaGen %s // style %d\n", alphaGenValues[ style ], style );
} }
else{ else{
alphaGen[ 0 ] = '\0'; alphaGen[ 0 ] = '\0';
@ -3111,7 +3111,8 @@ void StoreSurfaceLightmaps( void ){
/* create additional stage */ /* create additional stage */
if ( lmx == 0.0f && lmy == 0.0f ) { if ( lmx == 0.0f && lmy == 0.0f ) {
sprintf( styleStage, "\t{\n" snprintf( styleStage, sizeof( styleStage ),
"\t{\n"
"\t\tmap %s\n" /* lightmap */ "\t\tmap %s\n" /* lightmap */
"\t\tblendFunc GL_SRC_ALPHA GL_ONE\n" "\t\tblendFunc GL_SRC_ALPHA GL_ONE\n"
"%s" /* depthFunc equal */ "%s" /* depthFunc equal */
@ -3126,7 +3127,8 @@ void StoreSurfaceLightmaps( void ){
} }
else else
{ {
sprintf( styleStage, "\t{\n" snprintf( styleStage, sizeof( styleStage ),
"\t{\n"
"\t\tmap %s\n" /* lightmap */ "\t\tmap %s\n" /* lightmap */
"\t\tblendFunc GL_SRC_ALPHA GL_ONE\n" "\t\tblendFunc GL_SRC_ALPHA GL_ONE\n"
"%s" /* depthFunc equal */ "%s" /* depthFunc equal */
@ -3144,7 +3146,7 @@ void StoreSurfaceLightmaps( void ){
} }
/* concatenate */ /* concatenate */
strcat( styleStages, styleStage ); strncat( styleStages, styleStage, sizeof( styleStages ) );
} }
/* create custom shader */ /* create custom shader */
@ -3171,7 +3173,7 @@ void StoreSurfaceLightmaps( void ){
olm = &outLightmaps[ lm->outLightmapNums[ 0 ] ]; olm = &outLightmaps[ lm->outLightmapNums[ 0 ] ];
/* do some name mangling */ /* do some name mangling */
sprintf( lightmapName, "maps/%s/" EXTERNAL_LIGHTMAP, mapName, olm->extLightmapNum ); snprintf( lightmapName, sizeof( lightmapName ), "maps/%s/" EXTERNAL_LIGHTMAP, mapName, olm->extLightmapNum );
/* create custom shader */ /* create custom shader */
csi = CustomShader( info->si, "$lightmap", lightmapName ); csi = CustomShader( info->si, "$lightmap", lightmapName );

View file

@ -747,7 +747,7 @@ brush_t *FinishBrush( void ){
/* origin brushes are removed, but they set the rotation origin for the rest of the brushes in the entity. /* origin brushes are removed, but they set the rotation origin for the rest of the brushes in the entity.
after the entire entity is parsed, the planenums and texinfos will be adjusted for the origin brush */ after the entire entity is parsed, the planenums and texinfos will be adjusted for the origin brush */
if ( buildBrush->compileFlags & C_ORIGIN ) { if ( buildBrush->compileFlags & C_ORIGIN ) {
char string[ 32 ]; char string[ 64 ];
vec3_t origin; vec3_t origin;
if ( numEntities == 1 ) { if ( numEntities == 1 ) {
@ -1036,7 +1036,7 @@ static void ParseRawBrush( qboolean onlyLights ){
} }
/* set default flags and values */ /* set default flags and values */
sprintf( shader, "textures/%s", name ); snprintf( shader, sizeof( shader ), "textures/%s", name );
if ( onlyLights ) { if ( onlyLights ) {
si = &shaderInfo[ 0 ]; si = &shaderInfo[ 0 ];
} }
@ -1697,7 +1697,7 @@ static qboolean ParseMapEntity( qboolean onlyLights ){
value = ValueForKey( &entities[ 0 ], "_celshader" ); value = ValueForKey( &entities[ 0 ], "_celshader" );
} }
if ( value[ 0 ] != '\0' ) { if ( value[ 0 ] != '\0' ) {
sprintf( shader, "textures/%s", value ); snprintf( shader, sizeof( shader ), "textures/%s", value );
celShader = ShaderInfoForShader( shader ); celShader = ShaderInfoForShader( shader );
Sys_Printf( "Entity %d (%s) has cel shader %s\n", mapEnt->mapEntityNum, classname, celShader->shader ); Sys_Printf( "Entity %d (%s) has cel shader %s\n", mapEnt->mapEntityNum, classname, celShader->shader );
} }

View file

@ -701,7 +701,7 @@ void AddTriangleModels( entity_t *e ){
value = ValueForKey( &entities[ 0 ], "_celshader" ); value = ValueForKey( &entities[ 0 ], "_celshader" );
} }
if ( value[ 0 ] != '\0' ) { if ( value[ 0 ] != '\0' ) {
sprintf( shader, "textures/%s", value ); snprintf( shader, sizeof( shader ), "textures/%s", value );
celShader = ShaderInfoForShader( shader ); celShader = ShaderInfoForShader( shader );
} }
else{ else{

View file

@ -355,7 +355,7 @@ void ParsePatch( qboolean onlyLights ){
pm->brushNum = entitySourceBrushes; pm->brushNum = entitySourceBrushes;
/* set shader */ /* set shader */
sprintf( shader, "textures/%s", texture ); snprintf( shader, sizeof( shader ), "textures/%s", texture );
pm->shaderInfo = ShaderInfoForShader( shader ); pm->shaderInfo = ShaderInfoForShader( shader );
/* set mesh */ /* set mesh */

View file

@ -271,11 +271,11 @@ void AddHomeBasePath( char *path ){
basePaths[ i + 1 ] = basePaths[ i ]; basePaths[ i + 1 ] = basePaths[ i ];
/* concatenate home dir and path */ /* concatenate home dir and path */
sprintf( temp, "%s/%s", homePath, path ); snprintf( temp, sizeof( temp ), "%s/%s", homePath, path );
/* add it to the list */ /* add it to the list */
basePaths[ 0 ] = safe_malloc( strlen( temp ) + 1 ); basePaths[ 0 ] = safe_malloc( strlen( temp ) + 1 );
strcpy( basePaths[ 0 ], temp ); Q_strncpyz( basePaths[ 0 ], temp, sizeof( basePaths ) );
CleanPath( basePaths[ 0 ] ); CleanPath( basePaths[ 0 ] );
numBasePaths++; numBasePaths++;
#endif #endif
@ -451,7 +451,7 @@ void InitPaths( int *argc, char **argv ){
for ( i = 0; i < numBasePaths; i++ ) for ( i = 0; i < numBasePaths; i++ )
{ {
/* create a full path and initialize it */ /* create a full path and initialize it */
sprintf( temp, "%s/%s/", basePaths[ i ], gamePaths[ j ] ); snprintf( temp, sizeof( temp ), "%s/%s/", basePaths[ i ], gamePaths[ j ] );
//quick n dirty patch to enable vfs for quakelive //quick n dirty patch to enable vfs for quakelive
if (strcmp(game->arg, "quakelive") == 0 ) { if (strcmp(game->arg, "quakelive") == 0 ) {
unz_GAME_QL = 1; unz_GAME_QL = 1;

View file

@ -273,7 +273,7 @@ void WritePortalFile( tree_t *tree ){
Sys_FPrintf( SYS_VRB,"--- WritePortalFile ---\n" ); Sys_FPrintf( SYS_VRB,"--- WritePortalFile ---\n" );
// write the file // write the file
sprintf( filename, "%s.prt", source ); snprintf( filename, sizeof( filename ), "%s.prt", source );
Sys_Printf( "writing %s\n", filename ); Sys_Printf( "writing %s\n", filename );
pf = fopen( filename, "w" ); pf = fopen( filename, "w" );
if ( !pf ) { if ( !pf ) {

View file

@ -311,7 +311,7 @@ void BeginMapShaderFile( const char *mapFile ){
} }
/* append ../scripts/q3map2_<mapname>.shader */ /* append ../scripts/q3map2_<mapname>.shader */
sprintf( mapShaderFile, "%s/../%s/q3map2_%s.shader", base, game->shaderPath, mapName ); snprintf( mapShaderFile, sizeof( mapShaderFile ), "%s/../%s/q3map2_%s.shader", base, game->shaderPath, mapName );
Sys_FPrintf( SYS_VRB, "Map has shader script %s\n", mapShaderFile ); Sys_FPrintf( SYS_VRB, "Map has shader script %s\n", mapShaderFile );
/* remove it */ /* remove it */
@ -423,7 +423,8 @@ shaderInfo_t *CustomShader( shaderInfo_t *si, char *find, char *replace ){
/* et: implicitMap */ /* et: implicitMap */
if ( si->implicitMap == IM_OPAQUE ) { if ( si->implicitMap == IM_OPAQUE ) {
srcShaderText = temp; srcShaderText = temp;
sprintf( temp, "\n" snprintf( temp, sizeof( temp ),
"\n"
"{ // Q3Map2 defaulted (implicitMap)\n" "{ // Q3Map2 defaulted (implicitMap)\n"
"\t{\n" "\t{\n"
"\t\tmap $lightmap\n" "\t\tmap $lightmap\n"
@ -442,7 +443,8 @@ shaderInfo_t *CustomShader( shaderInfo_t *si, char *find, char *replace ){
/* et: implicitMask */ /* et: implicitMask */
else if ( si->implicitMap == IM_MASKED ) { else if ( si->implicitMap == IM_MASKED ) {
srcShaderText = temp; srcShaderText = temp;
sprintf( temp, "\n" snprintf( temp, sizeof( temp ),
"\n"
"{ // Q3Map2 defaulted (implicitMask)\n" "{ // Q3Map2 defaulted (implicitMask)\n"
"\tcull none\n" "\tcull none\n"
"\t{\n" "\t{\n"
@ -470,7 +472,8 @@ shaderInfo_t *CustomShader( shaderInfo_t *si, char *find, char *replace ){
/* et: implicitBlend */ /* et: implicitBlend */
else if ( si->implicitMap == IM_BLEND ) { else if ( si->implicitMap == IM_BLEND ) {
srcShaderText = temp; srcShaderText = temp;
sprintf( temp, "\n" snprintf( temp, sizeof( temp ),
"\n"
"{ // Q3Map2 defaulted (implicitBlend)\n" "{ // Q3Map2 defaulted (implicitBlend)\n"
"\tcull none\n" "\tcull none\n"
"\t{\n" "\t{\n"
@ -490,7 +493,8 @@ shaderInfo_t *CustomShader( shaderInfo_t *si, char *find, char *replace ){
/* default shader text */ /* default shader text */
else if ( srcShaderText == NULL ) { else if ( srcShaderText == NULL ) {
srcShaderText = temp; srcShaderText = temp;
sprintf( temp, "\n" snprintf( temp, sizeof( temp ),
"\n"
"{ // Q3Map2 defaulted\n" "{ // Q3Map2 defaulted\n"
"\t{\n" "\t{\n"
"\t\tmap $lightmap\n" "\t\tmap $lightmap\n"
@ -533,7 +537,7 @@ shaderInfo_t *CustomShader( shaderInfo_t *si, char *find, char *replace ){
md5_finish( &mh, digest ); md5_finish( &mh, digest );
/* mangle hash into a shader name */ /* mangle hash into a shader name */
sprintf( shader, "%s/%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X", mapName, snprintf( shader, sizeof( shader ), "%s/%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X", mapName,
digest[ 0 ], digest[ 1 ], digest[ 2 ], digest[ 3 ], digest[ 4 ], digest[ 5 ], digest[ 6 ], digest[ 7 ], digest[ 0 ], digest[ 1 ], digest[ 2 ], digest[ 3 ], digest[ 4 ], digest[ 5 ], digest[ 6 ], digest[ 7 ],
digest[ 8 ], digest[ 9 ], digest[ 10 ], digest[ 11 ], digest[ 12 ], digest[ 13 ], digest[ 14 ], digest[ 15 ] ); digest[ 8 ], digest[ 9 ], digest[ 10 ], digest[ 11 ], digest[ 12 ], digest[ 13 ], digest[ 14 ], digest[ 15 ] );
@ -578,7 +582,7 @@ void EmitVertexRemapShader( char *from, char *to ){
} }
/* build value */ /* build value */
sprintf( value, "%s;%s", from, to ); snprintf( value, sizeof( value ), "%s;%s", from, to );
/* make md5 hash */ /* make md5 hash */
md5_init( &mh ); md5_init( &mh );
@ -587,7 +591,7 @@ void EmitVertexRemapShader( char *from, char *to ){
/* make key (this is annoying, as vertexremapshader is precisely 17 characters, /* make key (this is annoying, as vertexremapshader is precisely 17 characters,
which is one too long, so we leave off the last byte of the md5 digest) */ which is one too long, so we leave off the last byte of the md5 digest) */
sprintf( key, "vertexremapshader%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X", snprintf( key, sizeof( key ), "vertexremapshader%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X",
digest[ 0 ], digest[ 1 ], digest[ 2 ], digest[ 3 ], digest[ 4 ], digest[ 5 ], digest[ 6 ], digest[ 7 ], digest[ 0 ], digest[ 1 ], digest[ 2 ], digest[ 3 ], digest[ 4 ], digest[ 5 ], digest[ 6 ], digest[ 7 ],
digest[ 8 ], digest[ 9 ], digest[ 10 ], digest[ 11 ], digest[ 12 ], digest[ 13 ], digest[ 14 ] ); /* no: digest[ 15 ] */ digest[ 8 ], digest[ 9 ], digest[ 10 ], digest[ 11 ], digest[ 12 ], digest[ 13 ], digest[ 14 ] ); /* no: digest[ 15 ] */
@ -1129,7 +1133,7 @@ static void ParseShaderFile( const char *filename ){
GetTokenAppend( shaderText, qfalse ); GetTokenAppend( shaderText, qfalse );
if ( token[ 0 ] != '\0' ) { if ( token[ 0 ] != '\0' ) {
si->damageShader = safe_malloc( strlen( token ) + 1 ); si->damageShader = safe_malloc( strlen( token ) + 1 );
strcpy( si->damageShader, token ); Q_strncpyz( si->damageShader, token, sizeof( si->damageShader ) );
} }
GetTokenAppend( shaderText, qfalse ); /* don't do anything with health */ GetTokenAppend( shaderText, qfalse ); /* don't do anything with health */
} }
@ -1139,10 +1143,10 @@ static void ParseShaderFile( const char *filename ){
si->implicitMap = IM_OPAQUE; si->implicitMap = IM_OPAQUE;
GetTokenAppend( shaderText, qfalse ); GetTokenAppend( shaderText, qfalse );
if ( token[ 0 ] == '-' && token[ 1 ] == '\0' ) { if ( token[ 0 ] == '-' && token[ 1 ] == '\0' ) {
sprintf( si->implicitImagePath, "%s.tga", si->shader ); snprintf( si->implicitImagePath, sizeof( si->implicitImagePath ), "%s.tga", si->shader );
} }
else{ else{
strcpy( si->implicitImagePath, token ); Q_strncpyz( si->implicitImagePath, token, sizeof( si->implicitImagePath ) );
} }
} }
@ -1150,10 +1154,10 @@ static void ParseShaderFile( const char *filename ){
si->implicitMap = IM_MASKED; si->implicitMap = IM_MASKED;
GetTokenAppend( shaderText, qfalse ); GetTokenAppend( shaderText, qfalse );
if ( token[ 0 ] == '-' && token[ 1 ] == '\0' ) { if ( token[ 0 ] == '-' && token[ 1 ] == '\0' ) {
sprintf( si->implicitImagePath, "%s.tga", si->shader ); snprintf( si->implicitImagePath, sizeof( si->implicitImagePath ), "%s.tga", si->shader );
} }
else{ else{
strcpy( si->implicitImagePath, token ); Q_strncpyz( si->implicitImagePath, token, sizeof( si->implicitImagePath ) );
} }
} }
@ -1161,10 +1165,10 @@ static void ParseShaderFile( const char *filename ){
si->implicitMap = IM_MASKED; si->implicitMap = IM_MASKED;
GetTokenAppend( shaderText, qfalse ); GetTokenAppend( shaderText, qfalse );
if ( token[ 0 ] == '-' && token[ 1 ] == '\0' ) { if ( token[ 0 ] == '-' && token[ 1 ] == '\0' ) {
sprintf( si->implicitImagePath, "%s.tga", si->shader ); snprintf( si->implicitImagePath, sizeof( si->implicitImagePath ), "%s.tga", si->shader );
} }
else{ else{
strcpy( si->implicitImagePath, token ); Q_strncpyz( si->implicitImagePath, token, sizeof( si->implicitImagePath ) );
} }
} }
@ -1176,21 +1180,21 @@ static void ParseShaderFile( const char *filename ){
/* qer_editorimage <image> */ /* qer_editorimage <image> */
else if ( !Q_stricmp( token, "qer_editorImage" ) ) { else if ( !Q_stricmp( token, "qer_editorImage" ) ) {
GetTokenAppend( shaderText, qfalse ); GetTokenAppend( shaderText, qfalse );
strcpy( si->editorImagePath, token ); Q_strncpyz( si->editorImagePath, token, sizeof( si->implicitImagePath ) );
DefaultExtension( si->editorImagePath, ".tga", sizeof( si->editorImagePath ) ); DefaultExtension( si->editorImagePath, ".tga", sizeof( si->editorImagePath ) );
} }
/* ydnar: q3map_normalimage <image> (bumpmapping normal map) */ /* ydnar: q3map_normalimage <image> (bumpmapping normal map) */
else if ( !Q_stricmp( token, "q3map_normalImage" ) ) { else if ( !Q_stricmp( token, "q3map_normalImage" ) ) {
GetTokenAppend( shaderText, qfalse ); GetTokenAppend( shaderText, qfalse );
strcpy( si->normalImagePath, token ); Q_strncpyz( si->normalImagePath, token, sizeof( si->normalImagePath ) );
DefaultExtension( si->normalImagePath, ".tga", sizeof( si->normalImagePath ) ); DefaultExtension( si->normalImagePath, ".tga", sizeof( si->normalImagePath ) );
} }
/* q3map_lightimage <image> */ /* q3map_lightimage <image> */
else if ( !Q_stricmp( token, "q3map_lightImage" ) ) { else if ( !Q_stricmp( token, "q3map_lightImage" ) ) {
GetTokenAppend( shaderText, qfalse ); GetTokenAppend( shaderText, qfalse );
strcpy( si->lightImagePath, token ); Q_strncpyz( si->lightImagePath, token, sizeof( si->lightImagePath ) );
DefaultExtension( si->lightImagePath, ".tga", sizeof( si->lightImagePath ) ); DefaultExtension( si->lightImagePath, ".tga", sizeof( si->lightImagePath ) );
} }
@ -1201,11 +1205,11 @@ static void ParseShaderFile( const char *filename ){
/* ignore bogus paths */ /* ignore bogus paths */
if ( Q_stricmp( token, "-" ) && Q_stricmp( token, "full" ) ) { if ( Q_stricmp( token, "-" ) && Q_stricmp( token, "full" ) ) {
strcpy( si->skyParmsImageBase, token ); Q_strncpyz( si->skyParmsImageBase, token, sizeof( si->skyParmsImageBase ) );
/* use top image as sky light image */ /* use top image as sky light image */
if ( si->lightImagePath[ 0 ] == '\0' ) { if ( si->lightImagePath[ 0 ] == '\0' ) {
sprintf( si->lightImagePath, "%s_up.tga", si->skyParmsImageBase ); snprintf( si->lightImagePath, sizeof( si->implicitImagePath ), "%s_up.tga", si->skyParmsImageBase );
} }
} }
@ -1846,7 +1850,7 @@ static void ParseShaderFile( const char *filename ){
/* q3map_material (sof2) */ /* q3map_material (sof2) */
else if ( !Q_stricmp( token, "q3map_material" ) ) { else if ( !Q_stricmp( token, "q3map_material" ) ) {
GetTokenAppend( shaderText, qfalse ); GetTokenAppend( shaderText, qfalse );
sprintf( temp, "*mat_%s", token ); snprintf( temp, sizeof( temp ), "*mat_%s", token );
if ( ApplySurfaceParm( temp, &si->contentFlags, &si->surfaceFlags, &si->compileFlags ) == qfalse ) { if ( ApplySurfaceParm( temp, &si->contentFlags, &si->surfaceFlags, &si->compileFlags ) == qfalse ) {
Sys_Printf( "WARNING: Unknown material \"%s\"\n", token ); Sys_Printf( "WARNING: Unknown material \"%s\"\n", token );
} }
@ -1988,14 +1992,14 @@ void LoadShaderInfo( void ){
numShaderFiles = 0; numShaderFiles = 0;
/* we can pile up several shader files, the one in baseq3 and ones in the mod dir or other spots */ /* we can pile up several shader files, the one in baseq3 and ones in the mod dir or other spots */
sprintf( filename, "%s/shaderlist.txt", game->shaderPath ); snprintf( filename, sizeof( filename ), "%s/shaderlist.txt", game->shaderPath );
count = vfsGetFileCount( filename ); count = vfsGetFileCount( filename );
/* load them all */ /* load them all */
for ( i = 0; i < count; i++ ) for ( i = 0; i < count; i++ )
{ {
/* load shader list */ /* load shader list */
sprintf( filename, "%s/shaderlist.txt", game->shaderPath ); snprintf( filename, sizeof( filename ), "%s/shaderlist.txt", game->shaderPath );
LoadScriptFile( filename, i ); LoadScriptFile( filename, i );
/* parse it */ /* parse it */
@ -2024,7 +2028,7 @@ void LoadShaderInfo( void ){
/* parse the shader files */ /* parse the shader files */
for ( i = 0; i < numShaderFiles; i++ ) for ( i = 0; i < numShaderFiles; i++ )
{ {
sprintf( filename, "%s/%s.shader", game->shaderPath, shaderFiles[ i ] ); snprintf( filename, sizeof( filename ), "%s/%s.shader", game->shaderPath, shaderFiles[ i ] );
ParseShaderFile( filename ); ParseShaderFile( filename );
free( shaderFiles[ i ] ); free( shaderFiles[ i ] );
} }

View file

@ -818,10 +818,10 @@ shaderInfo_t *GetIndexedShader( shaderInfo_t *parent, indexMap_t *im, int numPoi
/* make a shader name */ /* make a shader name */
if ( minShaderIndex == maxShaderIndex ) { if ( minShaderIndex == maxShaderIndex ) {
sprintf( shader, "textures/%s_%d", im->shader, maxShaderIndex ); snprintf( shader, sizeof( shader ), "textures/%s_%d", im->shader, maxShaderIndex );
} }
else{ else{
sprintf( shader, "textures/%s_%dto%d", im->shader, minShaderIndex, maxShaderIndex ); snprintf( shader, sizeof( shader ), "textures/%s_%dto%d", im->shader, minShaderIndex, maxShaderIndex );
} }
/* get the shader */ /* get the shader */
@ -917,17 +917,17 @@ mapDrawSurface_t *DrawSurfaceForSide( entity_t *e, brush_t *b, side_t *s, windin
/* ydnar: sky hack/fix for GL_CLAMP borders on ati cards */ /* ydnar: sky hack/fix for GL_CLAMP borders on ati cards */
if ( skyFixHack && si->skyParmsImageBase[ 0 ] != '\0' ) { if ( skyFixHack && si->skyParmsImageBase[ 0 ] != '\0' ) {
//% Sys_FPrintf( SYS_VRB, "Enabling sky hack for shader %s using env %s\n", si->shader, si->skyParmsImageBase ); //% Sys_FPrintf( SYS_VRB, "Enabling sky hack for shader %s using env %s\n", si->shader, si->skyParmsImageBase );
sprintf( tempShader, "%s_lf", si->skyParmsImageBase ); snprintf( tempShader, sizeof( tempShader ), "%s_lf", si->skyParmsImageBase );
DrawSurfaceForShader( tempShader ); DrawSurfaceForShader( tempShader );
sprintf( tempShader, "%s_rt", si->skyParmsImageBase ); snprintf( tempShader, sizeof( tempShader ), "%s_rt", si->skyParmsImageBase );
DrawSurfaceForShader( tempShader ); DrawSurfaceForShader( tempShader );
sprintf( tempShader, "%s_ft", si->skyParmsImageBase ); snprintf( tempShader, sizeof( tempShader ), "%s_ft", si->skyParmsImageBase );
DrawSurfaceForShader( tempShader ); DrawSurfaceForShader( tempShader );
sprintf( tempShader, "%s_bk", si->skyParmsImageBase ); snprintf( tempShader, sizeof( tempShader ), "%s_bk", si->skyParmsImageBase );
DrawSurfaceForShader( tempShader ); DrawSurfaceForShader( tempShader );
sprintf( tempShader, "%s_up", si->skyParmsImageBase ); snprintf( tempShader, sizeof( tempShader ), "%s_up", si->skyParmsImageBase );
DrawSurfaceForShader( tempShader ); DrawSurfaceForShader( tempShader );
sprintf( tempShader, "%s_dn", si->skyParmsImageBase ); snprintf( tempShader, sizeof( tempShader ), "%s_dn", si->skyParmsImageBase );
DrawSurfaceForShader( tempShader ); DrawSurfaceForShader( tempShader );
} }

View file

@ -1123,16 +1123,16 @@ int VisMain( int argc, char **argv ){
/* load the bsp */ /* load the bsp */
sprintf( source, "%s%s", inbase, ExpandArg( argv[ i ] ) ); snprintf( source, sizeof( source ), "%s%s", inbase, ExpandArg( argv[ i ] ) );
StripExtension( source ); StripExtension( source );
strcat( source, ".bsp" ); strncat( source, ".bsp", sizeof( source ) );
Sys_Printf( "Loading %s\n", source ); Sys_Printf( "Loading %s\n", source );
LoadBSPFile( source ); LoadBSPFile( source );
/* load the portal file */ /* load the portal file */
sprintf( portalfile, "%s%s", inbase, ExpandArg( argv[ i ] ) ); snprintf( portalfile, sizeof( portalfile ), "%s%s", inbase, ExpandArg( argv[ i ] ) );
StripExtension( portalfile ); StripExtension( portalfile );
strcat( portalfile, ".prt" ); strncat( portalfile, ".prt", sizeof( portalfile ) );
Sys_Printf( "Loading %s\n", portalfile ); Sys_Printf( "Loading %s\n", portalfile );
LoadPortals( portalfile ); LoadPortals( portalfile );

View file

@ -257,7 +257,7 @@ int EmitDrawNode_r( node_t *node ){
void SetModelNumbers( void ){ void SetModelNumbers( void ){
int i; int i;
int models; int models;
char value[10]; char value[16];
models = 1; models = 1;
for ( i = 1 ; i < numEntities ; i++ ) { for ( i = 1 ; i < numEntities ; i++ ) {
@ -284,7 +284,7 @@ void SetLightStyles( void ){
const char *t; const char *t;
entity_t *e; entity_t *e;
epair_t *ep, *next; epair_t *ep, *next;
char value[ 10 ]; char value[ 16 ];
char lightTargets[ MAX_SWITCHED_LIGHTS ][ 64 ]; char lightTargets[ MAX_SWITCHED_LIGHTS ][ 64 ];
int lightStyles[ MAX_SWITCHED_LIGHTS ]; int lightStyles[ MAX_SWITCHED_LIGHTS ];
@ -412,7 +412,7 @@ void EndBSPFile( void ){
WriteSurfaceExtraFile( source ); WriteSurfaceExtraFile( source );
/* write the bsp */ /* write the bsp */
sprintf( path, "%s.bsp", source ); snprintf( path, sizeof( path ), "%s.bsp", source );
Sys_Printf( "Writing %s\n", path ); Sys_Printf( "Writing %s\n", path );
WriteBSPFile( path ); WriteBSPFile( path );
} }

View file

@ -54,7 +54,7 @@
static void SetCloneModelNumbers( void ){ static void SetCloneModelNumbers( void ){
int i, j; int i, j;
int models; int models;
char modelValue[ 10 ]; char modelValue[ 16 ];
const char *value, *value2, *value3; const char *value, *value2, *value3;
@ -352,7 +352,7 @@ void ProcessWorldModel( void ){
/* ydnar: fog hull */ /* ydnar: fog hull */
value = ValueForKey( &entities[ 0 ], "_foghull" ); value = ValueForKey( &entities[ 0 ], "_foghull" );
if ( value[ 0 ] != '\0' ) { if ( value[ 0 ] != '\0' ) {
sprintf( shader, "textures/%s", value ); snprintf( shader, sizeof( shader ), "textures/%s", value );
MakeFogHullSurfs( e, tree, shader ); MakeFogHullSurfs( e, tree, shader );
} }
@ -566,7 +566,7 @@ void OnlyEnts( void ){
/* note it */ /* note it */
Sys_Printf( "--- OnlyEnts ---\n" ); Sys_Printf( "--- OnlyEnts ---\n" );
sprintf( out, "%s.bsp", source ); snprintf( out, sizeof( out ), "%s.bsp", source );
LoadBSPFile( out ); LoadBSPFile( out );
numEntities = 0; numEntities = 0;
@ -793,27 +793,27 @@ int BSPMain( int argc, char **argv ){
} }
/* copy source name */ /* copy source name */
strcpy( source, ExpandArg( argv[ i ] ) ); Q_strncpyz( source, ExpandArg( argv[ i ] ), sizeof( source ) );
StripExtension( source ); StripExtension( source );
/* ydnar: set default sample size */ /* ydnar: set default sample size */
SetDefaultSampleSize( sampleSize ); SetDefaultSampleSize( sampleSize );
/* delete portal, line and surface files */ /* delete portal, line and surface files */
sprintf( path, "%s.prt", source ); snprintf( path, sizeof( path ), "%s.prt", source );
remove( path ); remove( path );
sprintf( path, "%s.lin", source ); snprintf( path, sizeof( path ), "%s.lin", source );
remove( path ); remove( path );
//% sprintf( path, "%s.srf", source ); /* ydnar */ //% sprintf( path, "%s.srf", source ); /* ydnar */
//% remove( path ); //% remove( path );
/* expand mapname */ /* expand mapname */
strcpy( name, ExpandArg( argv[ i ] ) ); Q_strncpyz( name, ExpandArg( argv[ i ] ), sizeof( name ) );
if ( strcmp( name + strlen( name ) - 4, ".reg" ) ) { if ( strcmp( name + strlen( name ) - 4, ".reg" ) ) {
/* if we are doing a full map, delete the last saved region map */ /* if we are doing a full map, delete the last saved region map */
sprintf( path, "%s.reg", source ); snprintf( path, sizeof( path ), "%s.reg", source );
remove( path ); remove( path );
DefaultExtension( name, ".map" ); /* might be .reg */ DefaultExtension( name, ".map", sizeof( name ) ); /* might be .reg */
} }
/* if onlyents, just grab the entites and resave */ /* if onlyents, just grab the entites and resave */

View file

@ -373,7 +373,7 @@ void WriteBSPFile( const char *filename ){
/* make fake temp name so existing bsp file isn't damaged in case write process fails */ /* make fake temp name so existing bsp file isn't damaged in case write process fails */
time( &tm ); time( &tm );
sprintf( tempname, "%s.%08X", filename, (int) tm ); snprintf( tempname, sizeof( tempname ), "%s.%08X", filename, (int) tm );
/* byteswap, write the bsp, then swap back so it can be manipulated further */ /* byteswap, write the bsp, then swap back so it can be manipulated further */
SwapBSPFile(); SwapBSPFile();
@ -621,7 +621,7 @@ void UnparseEntities( void ){
StripTrailing( value ); StripTrailing( value );
/* add to buffer */ /* add to buffer */
sprintf( line, "\"%s\" \"%s\"\n", key, value ); snprintf( line, sizeof( line ), "\"%s\" \"%s\"\n", key, value );
strcat( end, line ); strcat( end, line );
end += strlen( line ); end += strlen( line );
} }

View file

@ -248,10 +248,10 @@ static void ConvertShader( FILE *f, bspShader_t *shader, int shaderNum ){
/* set bitmap filename */ /* set bitmap filename */
if ( si->shaderImage->filename[ 0 ] != '*' ) { if ( si->shaderImage->filename[ 0 ] != '*' ) {
strcpy( filename, si->shaderImage->filename ); Q_strncpyz( filename, si->shaderImage->filename, sizeof( filename ) );
} }
else{ else{
sprintf( filename, "%s.tga", si->shader ); snprintf( filename, sizeof( filename ), "%s.tga", si->shader );
} }
for ( c = filename; *c != '\0'; c++ ) for ( c = filename; *c != '\0'; c++ )
if ( *c == '/' ) { if ( *c == '/' ) {
@ -301,13 +301,13 @@ int ConvertBSPToASE( char *bspName ){
Sys_Printf( "--- Convert BSP to ASE ---\n" ); Sys_Printf( "--- Convert BSP to ASE ---\n" );
/* create the ase filename from the bsp name */ /* create the ase filename from the bsp name */
strcpy( name, bspName ); Q_strncpyz( name, bspName, sizeof( name ) );
StripExtension( name ); StripExtension( name );
strcat( name, ".ase" ); strncat( name, ".ase", sizeof( name ) );
Sys_Printf( "writing %s\n", name ); Sys_Printf( "writing %s\n", name );
ExtractFileBase( bspName, base ); ExtractFileBase( bspName, base );
strcat( base, ".bsp" ); strncat( base, ".bsp", sizeof( base ) );
/* open it */ /* open it */
f = fopen( name, "wb" ); f = fopen( name, "wb" );

View file

@ -76,7 +76,7 @@ xmlNodePtr LeakFile( tree_t *tree ){
// //
// write the points to the file // write the points to the file
// //
sprintf( filename, "%s.lin", source ); snprintf( filename, sizeof( filename ), "%s.lin", source );
linefile = fopen( filename, "w" ); linefile = fopen( filename, "w" );
if ( !linefile ) { if ( !linefile ) {
Error( "Couldn't open %s\n", filename ); Error( "Couldn't open %s\n", filename );

View file

@ -1723,11 +1723,11 @@ void WriteRadbumpChunk(){
/* note it */ /* note it */
Sys_Printf( "--- WriteRadbumpChunk ---\n" ); Sys_Printf( "--- WriteRadbumpChunk ---\n" );
strcpy( dirname, source ); Q_strncpyz( dirname, source, sizeof( dirname ) );
StripExtension( dirname ); StripExtension( dirname );
//Check to see if the chunk exists //Check to see if the chunk exists
sprintf( filename, "%s.rad", dirname ); snprintf( filename, sizeof( filename ), "%s.rad", dirname );
file = fopen( filename, "wb" ); file = fopen( filename, "wb" );
@ -2484,10 +2484,10 @@ int LightMain( int argc, char **argv ){
/* clean up map name */ /* clean up map name */
strcpy( source, ExpandArg( argv[ i ] ) ); strcpy( source, ExpandArg( argv[ i ] ) );
StripExtension( source ); StripExtension( source );
DefaultExtension( source, ".bsp" ); DefaultExtension( source, ".bsp", sizeof( source ) );
strcpy( mapSource, ExpandArg( argv[ i ] ) ); strcpy( mapSource, ExpandArg( argv[ i ] ) );
StripExtension( mapSource ); StripExtension( mapSource );
DefaultExtension( mapSource, ".map" ); DefaultExtension( mapSource, ".map", sizeof( mapSource ) );
/* ydnar: set default sample size */ /* ydnar: set default sample size */
SetDefaultSampleSize( sampleSize ); SetDefaultSampleSize( sampleSize );

View file

@ -120,7 +120,7 @@ void ExportLightmaps( void ){
Sys_FPrintf( SYS_VRB, "--- ExportLightmaps ---\n" ); Sys_FPrintf( SYS_VRB, "--- ExportLightmaps ---\n" );
/* do some path mangling */ /* do some path mangling */
strcpy( dirname, source ); Q_strncpyz( dirname, source, sizeof( dirname ) );
StripExtension( dirname ); StripExtension( dirname );
/* sanity check */ /* sanity check */
@ -136,7 +136,7 @@ void ExportLightmaps( void ){
for ( i = 0, lightmap = bspLightBytes; lightmap < ( bspLightBytes + numBSPLightBytes ); i++, lightmap += ( game->lightmapSize * game->lightmapSize * 3 ) ) for ( i = 0, lightmap = bspLightBytes; lightmap < ( bspLightBytes + numBSPLightBytes ); i++, lightmap += ( game->lightmapSize * game->lightmapSize * 3 ) )
{ {
/* write a tga image out */ /* write a tga image out */
sprintf( filename, "%s/lightmap_%04d.tga", dirname, i ); snprintf( filename, sizeof( filename ), "%s/lightmap_%04d.tga", dirname, i );
Sys_Printf( "Writing %s\n", filename ); Sys_Printf( "Writing %s\n", filename );
WriteTGA24( filename, lightmap, game->lightmapSize, game->lightmapSize, qfalse ); WriteTGA24( filename, lightmap, game->lightmapSize, game->lightmapSize, qfalse );
} }
@ -159,7 +159,7 @@ int ExportLightmapsMain( int argc, char **argv ){
/* do some path mangling */ /* do some path mangling */
strcpy( source, ExpandArg( argv[ argc - 1 ] ) ); strcpy( source, ExpandArg( argv[ argc - 1 ] ) );
StripExtension( source ); StripExtension( source );
DefaultExtension( source, ".bsp" ); DefaultExtension( source, ".bsp", sizeof( source ) );
/* load the bsp */ /* load the bsp */
Sys_Printf( "Loading %s\n", source ); Sys_Printf( "Loading %s\n", source );
@ -192,9 +192,9 @@ int ImportLightmapsMain( int argc, char **argv ){
} }
/* do some path mangling */ /* do some path mangling */
strcpy( source, ExpandArg( argv[ argc - 1 ] ) ); Q_strncpyz( source, ExpandArg( argv[ argc - 1 ] ), sizeof( source ) );
StripExtension( source ); StripExtension( source );
DefaultExtension( source, ".bsp" ); DefaultExtension( source, ".bsp", sizeof( source ) );
/* load the bsp */ /* load the bsp */
Sys_Printf( "Loading %s\n", source ); Sys_Printf( "Loading %s\n", source );
@ -204,7 +204,7 @@ int ImportLightmapsMain( int argc, char **argv ){
Sys_FPrintf( SYS_VRB, "--- ImportLightmaps ---\n" ); Sys_FPrintf( SYS_VRB, "--- ImportLightmaps ---\n" );
/* do some path mangling */ /* do some path mangling */
strcpy( dirname, source ); Q_strncpyz( dirname, source, sizeof( dirname ) );
StripExtension( dirname ); StripExtension( dirname );
/* sanity check */ /* sanity check */
@ -219,7 +219,7 @@ int ImportLightmapsMain( int argc, char **argv ){
for ( i = 0, lightmap = bspLightBytes; lightmap < ( bspLightBytes + numBSPLightBytes ); i++, lightmap += ( game->lightmapSize * game->lightmapSize * 3 ) ) for ( i = 0, lightmap = bspLightBytes; lightmap < ( bspLightBytes + numBSPLightBytes ); i++, lightmap += ( game->lightmapSize * game->lightmapSize * 3 ) )
{ {
/* read a tga image */ /* read a tga image */
sprintf( filename, "%s/lightmap_%04d.tga", dirname, i ); snprintf( filename, sizeof( filename ), "%s/lightmap_%04d.tga", dirname, i );
Sys_Printf( "Loading %s\n", filename ); Sys_Printf( "Loading %s\n", filename );
buffer = NULL; buffer = NULL;
len = vfsLoadFile( filename, (void*) &buffer, -1 ); len = vfsLoadFile( filename, (void*) &buffer, -1 );
@ -2813,12 +2813,12 @@ void StoreSurfaceLightmaps( void ){
olm->extLightmapNum = numExtLightmaps; olm->extLightmapNum = numExtLightmaps;
if ( radbump ) { if ( radbump ) {
sprintf( filename, "%s/" EXTERNAL_LIGHTMAP_RAD, dirname, numExtLightmaps,radbumppass ); snprintf( filename, sizeof( filename ), "%s/" EXTERNAL_LIGHTMAP_RAD, dirname, numExtLightmaps,radbumppass );
} }
else else
{ {
sprintf( filename, "%s/" EXTERNAL_LIGHTMAP, dirname, numExtLightmaps ); snprintf( filename, sizeof( filename ), "%s/" EXTERNAL_LIGHTMAP, dirname, numExtLightmaps );
} }
Sys_FPrintf( SYS_VRB, "\nwriting %s", filename ); Sys_FPrintf( SYS_VRB, "\nwriting %s", filename );
@ -2828,7 +2828,7 @@ void StoreSurfaceLightmaps( void ){
/* write deluxemap */ /* write deluxemap */
if ( deluxemap ) { if ( deluxemap ) {
sprintf( filename, "%s/" EXTERNAL_LIGHTMAP, dirname, numExtLightmaps ); snprintf( filename, sizeof( filename ), "%s/" EXTERNAL_LIGHTMAP, dirname, numExtLightmaps );
Sys_FPrintf( SYS_VRB, "\nwriting %s", filename ); Sys_FPrintf( SYS_VRB, "\nwriting %s", filename );
WriteTGA24( filename, olm->bspDirBytes, olm->customWidth, olm->customHeight, qtrue ); WriteTGA24( filename, olm->bspDirBytes, olm->customWidth, olm->customHeight, qtrue );
numExtLightmaps++; numExtLightmaps++;
@ -2848,7 +2848,7 @@ void StoreSurfaceLightmaps( void ){
for ( i = numExtLightmaps; i; i++ ) for ( i = numExtLightmaps; i; i++ )
{ {
/* determine if file exists */ /* determine if file exists */
sprintf( filename, "%s/" EXTERNAL_LIGHTMAP, dirname, i ); snprintf( filename, sizeof( filename ), "%s/" EXTERNAL_LIGHTMAP, dirname, i );
if ( !FileExists( filename ) ) { if ( !FileExists( filename ) ) {
break; break;
} }
@ -2995,7 +2995,7 @@ void StoreSurfaceLightmaps( void ){
/* surfaces with styled lightmaps and a style marker get a custom generated shader (fixme: make this work with external lightmaps) */ /* surfaces with styled lightmaps and a style marker get a custom generated shader (fixme: make this work with external lightmaps) */
if ( olm != NULL && lm != NULL && lm->styles[ 1 ] != LS_NONE && game->load != LoadRBSPFile ) { //% info->si->styleMarker > 0 ) if ( olm != NULL && lm != NULL && lm->styles[ 1 ] != LS_NONE && game->load != LoadRBSPFile ) { //% info->si->styleMarker > 0 )
qboolean dfEqual; qboolean dfEqual;
char key[ 32 ], styleStage[ 512 ], styleStages[ 4096 ], rgbGen[ 128 ], alphaGen[ 128 ]; char key[ 32 ], styleStage[ 512 ], styleStages[ 4096 ], rgbGen[ 256 ], alphaGen[ 256 ];
/* setup */ /* setup */
@ -3027,7 +3027,7 @@ void StoreSurfaceLightmaps( void ){
strcpy( lightmapName, "$lightmap" ); strcpy( lightmapName, "$lightmap" );
} }
else{ else{
sprintf( lightmapName, "maps/%s/" EXTERNAL_LIGHTMAP, mapName, olm->extLightmapNum ); snprintf( lightmapName, sizeof( lightmapName ), "maps/%s/" EXTERNAL_LIGHTMAP, mapName, olm->extLightmapNum );
} }
/* get rgbgen string */ /* get rgbgen string */
@ -3040,7 +3040,7 @@ void StoreSurfaceLightmaps( void ){
} }
rgbGen[ 0 ] = '\0'; rgbGen[ 0 ] = '\0';
if ( rgbGenValues[ style ][ 0 ] != '\0' ) { if ( rgbGenValues[ style ][ 0 ] != '\0' ) {
sprintf( rgbGen, "\t\trgbGen %s // style %d\n", rgbGenValues[ style ], style ); snprintf( rgbGen, sizeof( rgbGen ), "\t\trgbGen %s // style %d\n", rgbGenValues[ style ], style );
} }
else{ else{
rgbGen[ 0 ] = '\0'; rgbGen[ 0 ] = '\0';
@ -3052,7 +3052,7 @@ void StoreSurfaceLightmaps( void ){
alphaGenValues[ style ] = (char*) ValueForKey( &entities[ 0 ], key ); alphaGenValues[ style ] = (char*) ValueForKey( &entities[ 0 ], key );
} }
if ( alphaGenValues[ style ][ 0 ] != '\0' ) { if ( alphaGenValues[ style ][ 0 ] != '\0' ) {
sprintf( alphaGen, "\t\talphaGen %s // style %d\n", alphaGenValues[ style ], style ); snprintf( alphaGen, sizeof( alphaGen ), "\t\talphaGen %s // style %d\n", alphaGenValues[ style ], style );
} }
else{ else{
alphaGen[ 0 ] = '\0'; alphaGen[ 0 ] = '\0';
@ -3064,7 +3064,8 @@ void StoreSurfaceLightmaps( void ){
/* create additional stage */ /* create additional stage */
if ( lmx == 0.0f && lmy == 0.0f ) { if ( lmx == 0.0f && lmy == 0.0f ) {
sprintf( styleStage, "\t{\n" snprintf( styleStage, sizeof( styleStage ),
"\t{\n"
"\t\tmap %s\n" /* lightmap */ "\t\tmap %s\n" /* lightmap */
"\t\tblendFunc GL_SRC_ALPHA GL_ONE\n" "\t\tblendFunc GL_SRC_ALPHA GL_ONE\n"
"%s" /* depthFunc equal */ "%s" /* depthFunc equal */
@ -3079,7 +3080,8 @@ void StoreSurfaceLightmaps( void ){
} }
else else
{ {
sprintf( styleStage, "\t{\n" snprintf( styleStage, sizeof( styleStage ),
"\t{\n"
"\t\tmap %s\n" /* lightmap */ "\t\tmap %s\n" /* lightmap */
"\t\tblendFunc GL_SRC_ALPHA GL_ONE\n" "\t\tblendFunc GL_SRC_ALPHA GL_ONE\n"
"%s" /* depthFunc equal */ "%s" /* depthFunc equal */
@ -3097,7 +3099,7 @@ void StoreSurfaceLightmaps( void ){
} }
/* concatenate */ /* concatenate */
strcat( styleStages, styleStage ); strncat( styleStages, styleStage, sizeof( styleStages ) );
} }
/* create custom shader */ /* create custom shader */
@ -3124,7 +3126,7 @@ void StoreSurfaceLightmaps( void ){
olm = &outLightmaps[ lm->outLightmapNums[ 0 ] ]; olm = &outLightmaps[ lm->outLightmapNums[ 0 ] ];
/* do some name mangling */ /* do some name mangling */
sprintf( lightmapName, "maps/%s/" EXTERNAL_LIGHTMAP, mapName, olm->extLightmapNum ); snprintf( lightmapName, sizeof( lightmapName ), "maps/%s/" EXTERNAL_LIGHTMAP, mapName, olm->extLightmapNum );
/* create custom shader */ /* create custom shader */
csi = CustomShader( info->si, "$lightmap", lightmapName ); csi = CustomShader( info->si, "$lightmap", lightmapName );

View file

@ -587,7 +587,7 @@ brush_t *FinishBrush( void ){
/* origin brushes are removed, but they set the rotation origin for the rest of the brushes in the entity. /* origin brushes are removed, but they set the rotation origin for the rest of the brushes in the entity.
after the entire entity is parsed, the planenums and texinfos will be adjusted for the origin brush */ after the entire entity is parsed, the planenums and texinfos will be adjusted for the origin brush */
if ( buildBrush->compileFlags & C_ORIGIN ) { if ( buildBrush->compileFlags & C_ORIGIN ) {
char string[ 32 ]; char string[ 64 ];
vec3_t origin; vec3_t origin;
if ( numEntities == 1 ) { if ( numEntities == 1 ) {
@ -599,7 +599,7 @@ brush_t *FinishBrush( void ){
VectorAdd( buildBrush->mins, buildBrush->maxs, origin ); VectorAdd( buildBrush->mins, buildBrush->maxs, origin );
VectorScale( origin, 0.5, origin ); VectorScale( origin, 0.5, origin );
sprintf( string, "%i %i %i", (int) origin[ 0 ], (int) origin[ 1 ], (int) origin[ 2 ] ); snprintf( string, sizeof( string ), "%i %i %i", (int) origin[ 0 ], (int) origin[ 1 ], (int) origin[ 2 ] );
SetKeyValue( &entities[ numEntities - 1 ], "origin", string ); SetKeyValue( &entities[ numEntities - 1 ], "origin", string );
VectorCopy( origin, entities[ numEntities - 1 ].origin ); VectorCopy( origin, entities[ numEntities - 1 ].origin );
@ -876,7 +876,7 @@ static void ParseRawBrush( qboolean onlyLights ){
} }
/* set default flags and values */ /* set default flags and values */
sprintf( shader, "textures/%s", name ); snprintf( shader, sizeof( shader ), "textures/%s", name );
if ( onlyLights ) { if ( onlyLights ) {
si = &shaderInfo[ 0 ]; si = &shaderInfo[ 0 ];
} }
@ -1266,7 +1266,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 ); Sys_FPrintf( SYS_VRB, "Entity %d (%s) has shader index map \"%s\"\n", mapEnt->mapEntityNum, ValueForKey( e, "classname" ), indexMapFilename );
/* get index map file extension */ /* get index map file extension */
ExtractFileExtension( indexMapFilename, ext ); ExtractFileExtension( indexMapFilename, ext, sizeof( ext ) );
/* handle tga image */ /* handle tga image */
if ( !Q_stricmp( ext, "tga" ) ) { if ( !Q_stricmp( ext, "tga" ) ) {
@ -1537,7 +1537,7 @@ static qboolean ParseMapEntity( qboolean onlyLights ){
value = ValueForKey( &entities[ 0 ], "_celshader" ); value = ValueForKey( &entities[ 0 ], "_celshader" );
} }
if ( value[ 0 ] != '\0' ) { if ( value[ 0 ] != '\0' ) {
sprintf( shader, "textures/%s", value ); snprintf( shader, sizeof( shader ), "textures/%s", value );
celShader = ShaderInfoForShader( shader ); celShader = ShaderInfoForShader( shader );
Sys_Printf( "Entity %d (%s) has cel shader %s\n", mapEnt->mapEntityNum, classname, celShader->shader ); Sys_Printf( "Entity %d (%s) has cel shader %s\n", mapEnt->mapEntityNum, classname, celShader->shader );
} }

View file

@ -768,7 +768,7 @@ void AddTriangleModels( entity_t *e ){
value = ValueForKey( &entities[ 0 ], "_celshader" ); value = ValueForKey( &entities[ 0 ], "_celshader" );
} }
if ( value[ 0 ] != '\0' ) { if ( value[ 0 ] != '\0' ) {
sprintf( shader, "textures/%s", value ); snprintf( shader, sizeof( shader ), "textures/%s", value );
celShader = ShaderInfoForShader( shader ); celShader = ShaderInfoForShader( shader );
} }
else{ else{

View file

@ -355,7 +355,7 @@ void ParsePatch( qboolean onlyLights ){
pm->brushNum = entitySourceBrushes; pm->brushNum = entitySourceBrushes;
/* set shader */ /* set shader */
sprintf( shader, "textures/%s", texture ); snprintf( shader, sizeof( shader ), "textures/%s", texture );
pm->shaderInfo = ShaderInfoForShader( shader ); pm->shaderInfo = ShaderInfoForShader( shader );
/* set mesh */ /* set mesh */

View file

@ -281,11 +281,11 @@ void AddHomeBasePath( char *path ){
basePaths[ i + 1 ] = basePaths[ i ]; basePaths[ i + 1 ] = basePaths[ i ];
/* concatenate home dir and path */ /* concatenate home dir and path */
sprintf( temp, "%s/%s", homePath, path ); snprintf( temp, sizeof( temp ), "%s/%s", homePath, path );
/* add it to the list */ /* add it to the list */
basePaths[ 0 ] = safe_malloc( strlen( temp ) + 1 ); basePaths[ 0 ] = safe_malloc( strlen( temp ) + 1 );
strcpy( basePaths[ 0 ], temp ); Q_strncpyz( basePaths[ 0 ], temp, sizeof( basePaths ) );
CleanPath( basePaths[ 0 ] ); CleanPath( basePaths[ 0 ] );
numBasePaths++; numBasePaths++;
#endif #endif
@ -449,7 +449,7 @@ void InitPaths( int *argc, char **argv ){
for ( i = 0; i < numBasePaths; i++ ) for ( i = 0; i < numBasePaths; i++ )
{ {
/* create a full path and initialize it */ /* create a full path and initialize it */
sprintf( temp, "%s/%s/", basePaths[ i ], gamePaths[ j ] ); snprintf( temp, sizeof( temp ), "%s/%s/", basePaths[ i ], gamePaths[ j ] );
vfsInitDirectory( temp ); vfsInitDirectory( temp );
} }
} }

View file

@ -273,7 +273,7 @@ void WritePortalFile( tree_t *tree ){
Sys_FPrintf( SYS_VRB,"--- WritePortalFile ---\n" ); Sys_FPrintf( SYS_VRB,"--- WritePortalFile ---\n" );
// write the file // write the file
sprintf( filename, "%s.prt", source ); snprintf( filename, sizeof( filename ), "%s.prt", source );
Sys_Printf( "writing %s\n", filename ); Sys_Printf( "writing %s\n", filename );
pf = fopen( filename, "w" ); pf = fopen( filename, "w" );
if ( !pf ) { if ( !pf ) {

View file

@ -297,21 +297,21 @@ void BeginMapShaderFile( const char *mapFile ){
} }
/* copy map name */ /* copy map name */
strcpy( base, mapFile ); Q_strncpyz( base, mapFile, sizeof( base ) );
StripExtension( base ); StripExtension( base );
/* extract map name */ /* extract map name */
len = strlen( base ) - 1; len = strlen( base ) - 1;
while ( len > 0 && base[ len ] != '/' && base[ len ] != '\\' ) while ( len > 0 && base[ len ] != '/' && base[ len ] != '\\' )
len--; len--;
strcpy( mapName, &base[ len + 1 ] ); Q_strncpyz( mapName, &base[ len + 1 ], sizeof( mapName ) );
base[ len ] = '\0'; base[ len ] = '\0';
if ( len <= 0 ) { if ( len <= 0 ) {
return; return;
} }
/* append ../scripts/q3map2_<mapname>.shader */ /* append ../scripts/q3map2_<mapname>.shader */
sprintf( mapShaderFile, "%s/../%s/q3map2_%s.shader", base, game->shaderPath, mapName ); snprintf( mapShaderFile, sizeof( mapShaderFile ), "%s/../%s/q3map2_%s.shader", base, game->shaderPath, mapName );
Sys_FPrintf( SYS_VRB, "Map has shader script %s\n", mapShaderFile ); Sys_FPrintf( SYS_VRB, "Map has shader script %s\n", mapShaderFile );
/* remove it */ /* remove it */
@ -422,7 +422,8 @@ shaderInfo_t *CustomShader( shaderInfo_t *si, char *find, char *replace ){
/* et: implicitMap */ /* et: implicitMap */
if ( si->implicitMap == IM_OPAQUE ) { if ( si->implicitMap == IM_OPAQUE ) {
srcShaderText = temp; srcShaderText = temp;
sprintf( temp, "\n" snprintf( temp, sizeof( temp ),
"\n"
"{ // Q3Map2 defaulted (implicitMap)\n" "{ // Q3Map2 defaulted (implicitMap)\n"
"\t{\n" "\t{\n"
"\t\tmap $lightmap\n" "\t\tmap $lightmap\n"
@ -441,7 +442,8 @@ shaderInfo_t *CustomShader( shaderInfo_t *si, char *find, char *replace ){
/* et: implicitMask */ /* et: implicitMask */
else if ( si->implicitMap == IM_MASKED ) { else if ( si->implicitMap == IM_MASKED ) {
srcShaderText = temp; srcShaderText = temp;
sprintf( temp, "\n" snprintf( temp, sizeof( temp ),
"\n"
"{ // Q3Map2 defaulted (implicitMask)\n" "{ // Q3Map2 defaulted (implicitMask)\n"
"\tcull none\n" "\tcull none\n"
"\t{\n" "\t{\n"
@ -469,7 +471,8 @@ shaderInfo_t *CustomShader( shaderInfo_t *si, char *find, char *replace ){
/* et: implicitBlend */ /* et: implicitBlend */
else if ( si->implicitMap == IM_BLEND ) { else if ( si->implicitMap == IM_BLEND ) {
srcShaderText = temp; srcShaderText = temp;
sprintf( temp, "\n" snprintf( temp, sizeof( temp ),
"\n"
"{ // Q3Map2 defaulted (implicitBlend)\n" "{ // Q3Map2 defaulted (implicitBlend)\n"
"\tcull none\n" "\tcull none\n"
"\t{\n" "\t{\n"
@ -489,7 +492,8 @@ shaderInfo_t *CustomShader( shaderInfo_t *si, char *find, char *replace ){
/* default shader text */ /* default shader text */
else if ( srcShaderText == NULL ) { else if ( srcShaderText == NULL ) {
srcShaderText = temp; srcShaderText = temp;
sprintf( temp, "\n" snprintf( temp, sizeof( temp ),
"\n"
"{ // Q3Map2 defaulted\n" "{ // Q3Map2 defaulted\n"
"\t{\n" "\t{\n"
"\t\tmap $lightmap\n" "\t\tmap $lightmap\n"
@ -532,7 +536,7 @@ shaderInfo_t *CustomShader( shaderInfo_t *si, char *find, char *replace ){
md5_finish( &md5, digest ); md5_finish( &md5, digest );
/* mangle hash into a shader name */ /* mangle hash into a shader name */
sprintf( shader, "%s/%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X", mapName, snprintf( shader, sizeof( shader ), "%s/%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X", mapName,
digest[ 0 ], digest[ 1 ], digest[ 2 ], digest[ 3 ], digest[ 4 ], digest[ 5 ], digest[ 6 ], digest[ 7 ], digest[ 0 ], digest[ 1 ], digest[ 2 ], digest[ 3 ], digest[ 4 ], digest[ 5 ], digest[ 6 ], digest[ 7 ],
digest[ 8 ], digest[ 9 ], digest[ 10 ], digest[ 11 ], digest[ 12 ], digest[ 13 ], digest[ 14 ], digest[ 15 ] ); digest[ 8 ], digest[ 9 ], digest[ 10 ], digest[ 11 ], digest[ 12 ], digest[ 13 ], digest[ 14 ], digest[ 15 ] );
@ -577,7 +581,7 @@ void EmitVertexRemapShader( char *from, char *to ){
} }
/* build value */ /* build value */
sprintf( value, "%s;%s", from, to ); snprintf( value, sizeof( value ), "%s;%s", from, to );
/* make md5 hash */ /* make md5 hash */
md5_init( &md5 ); md5_init( &md5 );
@ -586,7 +590,7 @@ void EmitVertexRemapShader( char *from, char *to ){
/* make key (this is annoying, as vertexremapshader is precisely 17 characters, /* make key (this is annoying, as vertexremapshader is precisely 17 characters,
which is one too long, so we leave off the last byte of the md5 digest) */ which is one too long, so we leave off the last byte of the md5 digest) */
sprintf( key, "vertexremapshader%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X", snprintf( key, sizeof( key ), "vertexremapshader%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X",
digest[ 0 ], digest[ 1 ], digest[ 2 ], digest[ 3 ], digest[ 4 ], digest[ 5 ], digest[ 6 ], digest[ 7 ], digest[ 0 ], digest[ 1 ], digest[ 2 ], digest[ 3 ], digest[ 4 ], digest[ 5 ], digest[ 6 ], digest[ 7 ],
digest[ 8 ], digest[ 9 ], digest[ 10 ], digest[ 11 ], digest[ 12 ], digest[ 13 ], digest[ 14 ] ); /* no: digest[ 15 ] */ digest[ 8 ], digest[ 9 ], digest[ 10 ], digest[ 11 ], digest[ 12 ], digest[ 13 ], digest[ 14 ] ); /* no: digest[ 15 ] */
@ -1026,8 +1030,8 @@ static void ParseShaderFile( const char *filename ){
/* get an image */ /* get an image */
GetTokenAppend( shaderText, qfalse ); GetTokenAppend( shaderText, qfalse );
if ( token[ 0 ] != '*' && token[ 0 ] != '$' ) { if ( token[ 0 ] != '*' && token[ 0 ] != '$' ) {
strcpy( si->lightImagePath, token ); Q_strncpyz( si->lightImagePath, token, sizeof( si->lightImagePath ) );
DefaultExtension( si->lightImagePath, ".tga" ); DefaultExtension( si->lightImagePath, ".tga", sizeof( si->lightImagePath ) );
/* debug code */ /* debug code */
//% Sys_FPrintf( SYS_VRB, "Deduced shader image: %s\n", si->lightImagePath ); //% Sys_FPrintf( SYS_VRB, "Deduced shader image: %s\n", si->lightImagePath );
@ -1133,7 +1137,7 @@ static void ParseShaderFile( const char *filename ){
GetTokenAppend( shaderText, qfalse ); GetTokenAppend( shaderText, qfalse );
if ( token[ 0 ] != '\0' ) { if ( token[ 0 ] != '\0' ) {
si->damageShader = safe_malloc( strlen( token ) + 1 ); si->damageShader = safe_malloc( strlen( token ) + 1 );
strcpy( si->damageShader, token ); Q_strncpyz( si->damageShader, token, sizeof( si->damageShader ) );
} }
GetTokenAppend( shaderText, qfalse ); /* don't do anything with health */ GetTokenAppend( shaderText, qfalse ); /* don't do anything with health */
} }
@ -1143,10 +1147,10 @@ static void ParseShaderFile( const char *filename ){
si->implicitMap = IM_OPAQUE; si->implicitMap = IM_OPAQUE;
GetTokenAppend( shaderText, qfalse ); GetTokenAppend( shaderText, qfalse );
if ( token[ 0 ] == '-' && token[ 1 ] == '\0' ) { if ( token[ 0 ] == '-' && token[ 1 ] == '\0' ) {
sprintf( si->implicitImagePath, "%s.tga", si->shader ); snprintf( si->implicitImagePath, sizeof( si->implicitImagePath ), "%s.tga", si->shader );
} }
else{ else{
strcpy( si->implicitImagePath, token ); Q_strncpyz( si->implicitImagePath, token, sizeof( si->implicitImagePath ) );
} }
} }
@ -1154,10 +1158,10 @@ static void ParseShaderFile( const char *filename ){
si->implicitMap = IM_MASKED; si->implicitMap = IM_MASKED;
GetTokenAppend( shaderText, qfalse ); GetTokenAppend( shaderText, qfalse );
if ( token[ 0 ] == '-' && token[ 1 ] == '\0' ) { if ( token[ 0 ] == '-' && token[ 1 ] == '\0' ) {
sprintf( si->implicitImagePath, "%s.tga", si->shader ); snprintf( si->implicitImagePath, sizeof( si->implicitImagePath ), "%s.tga", si->shader );
} }
else{ else{
strcpy( si->implicitImagePath, token ); Q_strncpyz( si->implicitImagePath, token, sizeof( si->implicitImagePath ) );
} }
} }
@ -1165,10 +1169,10 @@ static void ParseShaderFile( const char *filename ){
si->implicitMap = IM_MASKED; si->implicitMap = IM_MASKED;
GetTokenAppend( shaderText, qfalse ); GetTokenAppend( shaderText, qfalse );
if ( token[ 0 ] == '-' && token[ 1 ] == '\0' ) { if ( token[ 0 ] == '-' && token[ 1 ] == '\0' ) {
sprintf( si->implicitImagePath, "%s.tga", si->shader ); snprintf( si->implicitImagePath, sizeof( si->implicitImagePath ), "%s.tga", si->shader );
} }
else{ else{
strcpy( si->implicitImagePath, token ); Q_strncpyz( si->implicitImagePath, token, sizeof( si->implicitImagePath ) );
} }
} }
@ -1180,22 +1184,22 @@ static void ParseShaderFile( const char *filename ){
/* qer_editorimage <image> */ /* qer_editorimage <image> */
else if ( !Q_stricmp( token, "qer_editorImage" ) ) { else if ( !Q_stricmp( token, "qer_editorImage" ) ) {
GetTokenAppend( shaderText, qfalse ); GetTokenAppend( shaderText, qfalse );
strcpy( si->editorImagePath, token ); Q_strncpyz( si->editorImagePath, token, sizeof( si->editorImagePath ) );
DefaultExtension( si->editorImagePath, ".tga" ); DefaultExtension( si->editorImagePath, ".tga", sizeof( si->editorImagePath ) );
} }
/* ydnar: q3map_normalimage <image> (bumpmapping normal map) */ /* ydnar: q3map_normalimage <image> (bumpmapping normal map) */
else if ( !Q_stricmp( token, "q3map_normalImage" ) ) { else if ( !Q_stricmp( token, "q3map_normalImage" ) ) {
GetTokenAppend( shaderText, qfalse ); GetTokenAppend( shaderText, qfalse );
strcpy( si->normalImagePath, token ); Q_strncpyz( si->normalImagePath, token, sizeof( si->normalImagePath ) );
DefaultExtension( si->normalImagePath, ".tga" ); DefaultExtension( si->normalImagePath, ".tga", sizeof( si->normalImagePath ) );
} }
/* q3map_lightimage <image> */ /* q3map_lightimage <image> */
else if ( !Q_stricmp( token, "q3map_lightImage" ) ) { else if ( !Q_stricmp( token, "q3map_lightImage" ) ) {
GetTokenAppend( shaderText, qfalse ); GetTokenAppend( shaderText, qfalse );
strcpy( si->lightImagePath, token ); Q_strncpyz( si->lightImagePath, token, sizeof( si->lightImagePath ) );
DefaultExtension( si->lightImagePath, ".tga" ); DefaultExtension( si->lightImagePath, ".tga", sizeof( si->lightImagePath ) );
} }
/* ydnar: skyparms <outer image> <cloud height> <inner image> */ /* ydnar: skyparms <outer image> <cloud height> <inner image> */
@ -1205,11 +1209,11 @@ static void ParseShaderFile( const char *filename ){
/* ignore bogus paths */ /* ignore bogus paths */
if ( Q_stricmp( token, "-" ) && Q_stricmp( token, "full" ) ) { if ( Q_stricmp( token, "-" ) && Q_stricmp( token, "full" ) ) {
strcpy( si->skyParmsImageBase, token ); Q_strncpyz( si->skyParmsImageBase, token, sizeof( si->skyParmsImageBase ) );
/* use top image as sky light image */ /* use top image as sky light image */
if ( si->lightImagePath[ 0 ] == '\0' ) { if ( si->lightImagePath[ 0 ] == '\0' ) {
sprintf( si->lightImagePath, "%s_up.tga", si->skyParmsImageBase ); snprintf( si->lightImagePath, sizeof( si->lightImagePath ), "%s_up.tga", si->skyParmsImageBase );
} }
} }
@ -1850,7 +1854,7 @@ static void ParseShaderFile( const char *filename ){
/* q3map_material (sof2) */ /* q3map_material (sof2) */
else if ( !Q_stricmp( token, "q3map_material" ) ) { else if ( !Q_stricmp( token, "q3map_material" ) ) {
GetTokenAppend( shaderText, qfalse ); GetTokenAppend( shaderText, qfalse );
sprintf( temp, "*mat_%s", token ); snprintf( temp, sizeof( temp ), "*mat_%s", token );
if ( ApplySurfaceParm( temp, &si->contentFlags, &si->surfaceFlags, &si->compileFlags ) == qfalse ) { if ( ApplySurfaceParm( temp, &si->contentFlags, &si->surfaceFlags, &si->compileFlags ) == qfalse ) {
Sys_Printf( "WARNING: Unknown material \"%s\"\n", token ); Sys_Printf( "WARNING: Unknown material \"%s\"\n", token );
} }
@ -1994,14 +1998,14 @@ void LoadShaderInfo( void ){
numShaderFiles = 0; numShaderFiles = 0;
/* we can pile up several shader files, the one in baseq3 and ones in the mod dir or other spots */ /* we can pile up several shader files, the one in baseq3 and ones in the mod dir or other spots */
sprintf( filename, "%s/shaderlist.txt", game->shaderPath ); snprintf( filename, sizeof( filename ), "%s/shaderlist.txt", game->shaderPath );
count = vfsGetFileCount( filename ); count = vfsGetFileCount( filename );
/* load them all */ /* load them all */
for ( i = 0; i < count; i++ ) for ( i = 0; i < count; i++ )
{ {
/* load shader list */ /* load shader list */
sprintf( filename, "%s/shaderlist.txt", game->shaderPath ); snprintf( filename, sizeof( filename ), "%s/shaderlist.txt", game->shaderPath );
LoadScriptFile( filename, i ); LoadScriptFile( filename, i );
/* parse it */ /* parse it */
@ -2030,7 +2034,7 @@ void LoadShaderInfo( void ){
/* parse the shader files */ /* parse the shader files */
for ( i = 0; i < numShaderFiles; i++ ) for ( i = 0; i < numShaderFiles; i++ )
{ {
sprintf( filename, "%s/%s.shader", game->shaderPath, shaderFiles[ i ] ); snprintf( filename, sizeof( filename ), "%s/%s.shader", game->shaderPath, shaderFiles[ i ] );
ParseShaderFile( filename ); ParseShaderFile( filename );
free( shaderFiles[ i ] ); free( shaderFiles[ i ] );
} }

View file

@ -818,10 +818,10 @@ shaderInfo_t *GetIndexedShader( shaderInfo_t *parent, indexMap_t *im, int numPoi
/* make a shader name */ /* make a shader name */
if ( minShaderIndex == maxShaderIndex ) { if ( minShaderIndex == maxShaderIndex ) {
sprintf( shader, "textures/%s_%d", im->shader, maxShaderIndex ); snprintf( shader, sizeof( shader ), "textures/%s_%d", im->shader, maxShaderIndex );
} }
else{ else{
sprintf( shader, "textures/%s_%dto%d", im->shader, minShaderIndex, maxShaderIndex ); snprintf( shader, sizeof( shader ), "textures/%s_%dto%d", im->shader, minShaderIndex, maxShaderIndex );
} }
/* get the shader */ /* get the shader */
@ -917,17 +917,17 @@ mapDrawSurface_t *DrawSurfaceForSide( entity_t *e, brush_t *b, side_t *s, windin
/* ydnar: sky hack/fix for GL_CLAMP borders on ati cards */ /* ydnar: sky hack/fix for GL_CLAMP borders on ati cards */
if ( skyFixHack && si->skyParmsImageBase[ 0 ] != '\0' ) { if ( skyFixHack && si->skyParmsImageBase[ 0 ] != '\0' ) {
//% Sys_FPrintf( SYS_VRB, "Enabling sky hack for shader %s using env %s\n", si->shader, si->skyParmsImageBase ); //% Sys_FPrintf( SYS_VRB, "Enabling sky hack for shader %s using env %s\n", si->shader, si->skyParmsImageBase );
sprintf( tempShader, "%s_lf", si->skyParmsImageBase ); snprintf( tempShader, sizeof( tempShader ), "%s_lf", si->skyParmsImageBase );
DrawSurfaceForShader( tempShader ); DrawSurfaceForShader( tempShader );
sprintf( tempShader, "%s_rt", si->skyParmsImageBase ); snprintf( tempShader, sizeof( tempShader ), "%s_rt", si->skyParmsImageBase );
DrawSurfaceForShader( tempShader ); DrawSurfaceForShader( tempShader );
sprintf( tempShader, "%s_ft", si->skyParmsImageBase ); snprintf( tempShader, sizeof( tempShader ), "%s_ft", si->skyParmsImageBase );
DrawSurfaceForShader( tempShader ); DrawSurfaceForShader( tempShader );
sprintf( tempShader, "%s_bk", si->skyParmsImageBase ); snprintf( tempShader, sizeof( tempShader ), "%s_bk", si->skyParmsImageBase );
DrawSurfaceForShader( tempShader ); DrawSurfaceForShader( tempShader );
sprintf( tempShader, "%s_up", si->skyParmsImageBase ); snprintf( tempShader, sizeof( tempShader ), "%s_up", si->skyParmsImageBase );
DrawSurfaceForShader( tempShader ); DrawSurfaceForShader( tempShader );
sprintf( tempShader, "%s_dn", si->skyParmsImageBase ); snprintf( tempShader, sizeof( tempShader ), "%s_dn", si->skyParmsImageBase );
DrawSurfaceForShader( tempShader ); DrawSurfaceForShader( tempShader );
} }

View file

@ -1129,16 +1129,16 @@ int VisMain( int argc, char **argv ){
/* load the bsp */ /* load the bsp */
sprintf( source, "%s%s", inbase, ExpandArg( argv[ i ] ) ); snprintf( source, sizeof( source ), "%s%s", inbase, ExpandArg( argv[ i ] ) );
StripExtension( source ); StripExtension( source );
strcat( source, ".bsp" ); strncat( source, ".bsp", sizeof( source ) );
Sys_Printf( "Loading %s\n", source ); Sys_Printf( "Loading %s\n", source );
LoadBSPFile( source ); LoadBSPFile( source );
/* load the portal file */ /* load the portal file */
sprintf( portalfile, "%s%s", inbase, ExpandArg( argv[ i ] ) ); snprintf( portalfile, sizeof( portalfile ), "%s%s", inbase, ExpandArg( argv[ i ] ) );
StripExtension( portalfile ); StripExtension( portalfile );
strcat( portalfile, ".prt" ); strncat( portalfile, ".prt", sizeof( portalfile ) );
Sys_Printf( "Loading %s\n", portalfile ); Sys_Printf( "Loading %s\n", portalfile );
LoadPortals( portalfile ); LoadPortals( portalfile );

View file

@ -260,7 +260,7 @@ int EmitDrawNode_r( node_t *node ){
void SetModelNumbers( void ){ void SetModelNumbers( void ){
int i; int i;
int models; int models;
char value[10]; char value[16];
models = 1; models = 1;
for ( i = 1 ; i < numEntities ; i++ ) { for ( i = 1 ; i < numEntities ; i++ ) {
@ -287,7 +287,7 @@ void SetLightStyles( void ){
const char *t; const char *t;
entity_t *e; entity_t *e;
epair_t *ep, *next; epair_t *ep, *next;
char value[ 10 ]; char value[ 16 ];
char lightTargets[ MAX_SWITCHED_LIGHTS ][ 64 ]; char lightTargets[ MAX_SWITCHED_LIGHTS ][ 64 ];
int lightStyles[ MAX_SWITCHED_LIGHTS ]; int lightStyles[ MAX_SWITCHED_LIGHTS ];
@ -413,7 +413,7 @@ void EndBSPFile( void ){
WriteSurfaceExtraFile( source ); WriteSurfaceExtraFile( source );
/* write the bsp */ /* write the bsp */
sprintf( path, "%s.bsp", source ); snprintf( path, sizeof( path ), "%s.bsp", source );
Sys_Printf( "Writing %s\n", path ); Sys_Printf( "Writing %s\n", path );
WriteBSPFile( path ); WriteBSPFile( path );
} }