View Issue Details

IDProjectCategoryView StatusLast Update
0002795FSSCPBuild systempublic2013-02-16 10:45
Reporterbugmenot Assigned Toniffiwan  
PrioritynormalSeverityminorReproducibilityhave not tried
Status closedResolutionduplicate 
PlatformLinuxOSUbuntuOS Version12.10 amd64
Summary0002795: sprintf expects a format even if only a string is given
Descriptionsprintf expects a format even if only a string is given
TagsNo tags attached.

Relationships

duplicate of 0002776 resolvedniffiwan FTBFS with format-hardening [patch] 

Activities

bugmenot

2013-02-15 18:32

reporter  

ftbfs.patch (12,309 bytes)   
## Description: sprintf expects a format even if only a string is given.
## Origin/Author: Christoph Korn
## Bug: http://scp.indiegames.us/mantis/view.php?id=2795
Index: diaspora-1.0.4/Diaspora/fs2_open/code/cutscene/cutscenes.cpp
===================================================================
--- diaspora-1.0.4.orig/Diaspora/fs2_open/code/cutscene/cutscenes.cpp	2012-11-10 08:37:23.000000000 +0100
+++ diaspora-1.0.4/Diaspora/fs2_open/code/cutscene/cutscenes.cpp	2013-02-15 19:19:25.291340904 +0100
@@ -320,9 +320,9 @@
 		char str[256];
 
 		if (Cmdline_nomovies)
-			sprintf(str, XSTR("Movies are currently disabled.", -1));
+			sprintf(str, "%s", XSTR("Movies are currently disabled.", -1));
 		else
-			sprintf(str, XSTR("Unable to play movie %s.", 204), Cutscenes[which_cutscene].name);
+			sprintf(str, "%s", XSTR("Unable to play movie %s.", 204), Cutscenes[which_cutscene].name);
 
 		popup(0, 1, POPUP_OK, str );
 	}
Index: diaspora-1.0.4/Diaspora/fs2_open/code/gamesnd/eventmusic.cpp
===================================================================
--- diaspora-1.0.4.orig/Diaspora/fs2_open/code/gamesnd/eventmusic.cpp	2012-11-10 08:37:23.000000000 +0100
+++ diaspora-1.0.4/Diaspora/fs2_open/code/gamesnd/eventmusic.cpp	2013-02-15 19:19:25.291340904 +0100
@@ -1686,10 +1686,10 @@
 void event_music_get_info(char *outbuf)
 {
 	if ( Event_music_enabled == FALSE || Event_music_level_inited == FALSE || Current_pattern == -1 ) {
-		sprintf(outbuf,XSTR( "Event music is not playing", 213));
+		sprintf(outbuf,"%s", XSTR( "Event music is not playing", 213));
 	}
 	else {	
-		sprintf(outbuf,XSTR( "soundtrack: %s [%s]", 214), Soundtracks[Current_soundtrack_num].name, Pattern_info[Current_pattern].pattern_desc);
+		sprintf(outbuf, XSTR( "soundtrack: %s [%s]", 214), Soundtracks[Current_soundtrack_num].name, Pattern_info[Current_pattern].pattern_desc);
 	}
 }
 
@@ -1752,7 +1752,7 @@
 		strcpy(outbuf, XSTR( "Event music is not playing", 213));
 	}
 	else {
-		sprintf(outbuf, Soundtracks[Current_soundtrack_num].name);
+		sprintf(outbuf, "%s", Soundtracks[Current_soundtrack_num].name);
 	}
 }
 
Index: diaspora-1.0.4/Diaspora/fs2_open/code/gamehelp/gameplayhelp.cpp
===================================================================
--- diaspora-1.0.4.orig/Diaspora/fs2_open/code/gamehelp/gameplayhelp.cpp	2012-11-10 08:37:23.000000000 +0100
+++ diaspora-1.0.4/Diaspora/fs2_open/code/gamehelp/gameplayhelp.cpp	2013-02-15 19:19:25.291340904 +0100
@@ -120,7 +120,7 @@
 	ci = &Control_config[id];
 
 	if ( ci->key_id >= 0 ) {
-		sprintf(buf, textify_scancode(ci->key_id));
+		sprintf(buf, "%s", textify_scancode(ci->key_id));
 		has_key=1;
 	}
 
@@ -153,7 +153,7 @@
 	buf[0] = 0;
 
 	if ( ci->key_id >= 0 ) {
-		sprintf(buf, textify_scancode(ci->key_id));
+		sprintf(buf, "%s", textify_scancode(ci->key_id));
 		has_key=1;
 	}
 
Index: diaspora-1.0.4/Diaspora/fs2_open/code/hud/hud.cpp
===================================================================
--- diaspora-1.0.4.orig/Diaspora/fs2_open/code/hud/hud.cpp	2012-11-10 08:37:23.000000000 +0100
+++ diaspora-1.0.4/Diaspora/fs2_open/code/hud/hud.cpp	2013-02-15 19:19:25.291340904 +0100
@@ -2850,9 +2850,9 @@
 			}
 
 			if (repairing)
-				sprintf(outstr, XSTR("repairing", 227));
+				sprintf(outstr, "%s", XSTR("repairing", 227));
 			else
-				sprintf(outstr, XSTR("rearming", 228));
+				sprintf(outstr, "%s", XSTR("rearming", 228));
 		}
 		else
 		{
@@ -2874,17 +2874,17 @@
 		renderStringAlignCenter(position[0], position[1] + text_val_offset_y, w, outstr);
 	}
 	else if (Player_ai->ai_flags & AIF_REPAIR_OBSTRUCTED) {
-		sprintf(outstr, XSTR( "obstructed", 229));
+		sprintf(outstr, "%s", XSTR( "obstructed", 229));
 		renderStringAlignCenter(position[0], position[1] + text_val_offset_y, w, outstr);
 	} else {
 		if ( Hud_support_objnum == -1 ) {
 			if (The_mission.support_ships.arrival_location == ARRIVE_FROM_DOCK_BAY)
 			{
-				sprintf(outstr, XSTR( "exiting hangar", -1));
+				sprintf(outstr, "%s", XSTR( "exiting hangar", -1));
 			}
 			else
 			{
-				sprintf(outstr, XSTR( "warping in", 230));
+				sprintf(outstr, "%s", XSTR( "warping in", 230));
 			}
 			renderStringAlignCenter(position[0], position[1] + text_val_offset_y, w, outstr);
 		} else {
@@ -2893,11 +2893,11 @@
 			// Display "busy" when support ship isn't actually enroute to me
 			aip = &Ai_info[Ships[Objects[Hud_support_objnum].instance].ai_index];
 			if ( aip->goal_objnum != OBJ_INDEX(Player_obj) ) {
-				sprintf(outstr, XSTR( "busy", 231));
+				sprintf(outstr, "%s", XSTR( "busy", 231));
 				show_time = 0;
 
 			} else {
-				sprintf(outstr, XSTR( "dock in:", 232));
+				sprintf(outstr, "%s", XSTR( "dock in:", 232));
 				show_time = 1;
 			}		
 
@@ -3858,7 +3858,7 @@
 		if((Netgame.server != NULL) && (Netgame.server->s_info.ping.ping_avg > 0)){
 			// Get the string
 			if(Netgame.server->s_info.ping.ping_avg >= 1000){
-				sprintf(ping_str,XSTR("> 1 sec",628));
+				sprintf(ping_str,"%s", XSTR("> 1 sec",628));
 			} else {
 				sprintf(ping_str,XSTR("%d ms",629),Netgame.server->s_info.ping.ping_avg);
 			}
Index: diaspora-1.0.4/Diaspora/fs2_open/code/hud/hudtargetbox.cpp
===================================================================
--- diaspora-1.0.4.orig/Diaspora/fs2_open/code/hud/hudtargetbox.cpp	2012-11-10 08:37:23.000000000 +0100
+++ diaspora-1.0.4/Diaspora/fs2_open/code/hud/hudtargetbox.cpp	2013-02-15 19:19:25.295340904 +0100
@@ -437,16 +437,16 @@
 	// print out status of ship
 	switch(Current_ts) {
 		case TS_DIS:
-			sprintf(buf,XSTR( "dis", 344));
+			sprintf(buf,"%s", XSTR( "dis", 344));
 			break;
 		case TS_OK:
-			sprintf(buf,XSTR( "ok", 345));
+			sprintf(buf,"%s", XSTR( "ok", 345));
 			break;
 		case TS_DMG:
-			sprintf(buf,XSTR( "dmg", 346));
+			sprintf(buf,"%s", XSTR( "dmg", 346));
 			break;
 		case TS_CRT:
-			sprintf(buf,XSTR( "crt", 347));
+			sprintf(buf,"%s", XSTR( "crt", 347));
 			break;
 	}
 
@@ -879,7 +879,7 @@
 		if ( speed > 0 ) {
 			sprintf(outstr, NOX("impact: %.1f sec"), dist/speed);
 		} else {
-			sprintf(outstr, XSTR( "unknown", 349));
+			sprintf(outstr, "%s", XSTR( "unknown", 349));
 		}
 
 		renderString(position[0] + Class_offsets[0], position[1] + Class_offsets[1], EG_TBOX_CLASS, outstr);		
@@ -1267,7 +1267,7 @@
 		}
 
 		if ( has_orders ) {
-			sprintf(outstr, XSTR( "time to: ", 338));
+			sprintf(outstr, "%s", XSTR( "time to: ", 338));
 			if ( ship_return_time_to_goal(tmpbuf, target_shipp) ) {
 				strcat_s(outstr, tmpbuf);
 				
@@ -1572,9 +1572,9 @@
 	// print out 'disabled' on the monitor if the target is disabled
 	if ( (target_shipp->flags & SF_DISABLED) || (ship_subsys_disrupted(target_shipp, SUBSYSTEM_ENGINE)) ) {
 		if ( target_shipp->flags & SF_DISABLED ) {
-			sprintf(outstr, XSTR( "DISABLED", 342));
+			sprintf(outstr, "%s", XSTR( "DISABLED", 342));
 		} else {
-			sprintf(outstr, XSTR( "DISRUPTED", 343));
+			sprintf(outstr, "%s", XSTR( "DISRUPTED", 343));
 		}
 		gr_get_string_size(&w,&h,outstr);
 
Index: diaspora-1.0.4/Diaspora/fs2_open/code/network/chat_api.cpp
===================================================================
--- diaspora-1.0.4.orig/Diaspora/fs2_open/code/network/chat_api.cpp	2012-11-10 08:37:23.000000000 +0100
+++ diaspora-1.0.4/Diaspora/fs2_open/code/network/chat_api.cpp	2013-02-15 19:19:25.295340904 +0100
@@ -1108,7 +1108,7 @@
 	if(stricmp(szCmd,"432")==0)
 	{
 		//Channel Mode info
-		snprintf(szResponse, SSIZE(szResponse), XSTR("Your nickname contains invalid characters", 640));
+		snprintf(szResponse, SSIZE(szResponse), "%s", XSTR("Your nickname contains invalid characters", 640));
 		AddChatCommandToQueue(CC_DISCONNECTED,NULL,0);
 		return szResponse;
 	}
Index: diaspora-1.0.4/Diaspora/fs2_open/code/object/objectsnd.cpp
===================================================================
--- diaspora-1.0.4.orig/Diaspora/fs2_open/code/object/objectsnd.cpp	2012-11-10 08:37:23.000000000 +0100
+++ diaspora-1.0.4/Diaspora/fs2_open/code/object/objectsnd.cpp	2013-02-15 19:19:25.295340904 +0100
@@ -122,13 +122,13 @@
 				}
 
 				if ( Objects[osp->objnum].type == OBJ_SHIP ) {
-					sprintf(buf2, Ships[Objects[osp->objnum].instance].ship_name);
+					sprintf(buf2, "%s", Ships[Objects[osp->objnum].instance].ship_name);
 				}
 				else if ( Objects[osp->objnum].type == OBJ_DEBRIS ) {
-					sprintf(buf2, "Debris");
+					sprintf(buf2, "%s", "Debris");
 				}
 				else {
-					sprintf(buf2, "Unknown");
+					sprintf(buf2, "%s", "Unknown");
 				}
 
 				vec3d source_pos;
Index: diaspora-1.0.4/Diaspora/fs2_open/code/playerman/playercontrol.cpp
===================================================================
--- diaspora-1.0.4.orig/Diaspora/fs2_open/code/playerman/playercontrol.cpp	2012-11-10 08:37:23.000000000 +0100
+++ diaspora-1.0.4/Diaspora/fs2_open/code/playerman/playercontrol.cpp	2013-02-15 19:19:25.295340904 +0100
@@ -1451,7 +1451,7 @@
 				sprintf(outstr,XSTR("cargo: %s", 84), cargo_name );
 			}
 		} else {
-			sprintf(outstr, XSTR( "Scanned", 85) );
+			sprintf(outstr, "%s", XSTR( "Scanned", 85) );
 		}
 
 		// always bash cargo_inspect_time to 0 since AI ships can reveal cargo that we
@@ -1469,9 +1469,9 @@
 		dot = vm_vec_dot(&vec_to_cargo, &Player_obj->orient.vec.fvec);
 		if ( dot < CARGO_MIN_DOT_TO_REVEAL ) {
 			if ( !(cargo_sp->flags & SF_SCANNABLE) )
-				sprintf(outstr,XSTR( "cargo: <unknown>", 86));
+				sprintf(outstr,"%s", XSTR( "cargo: <unknown>", 86));
 			else
-				sprintf(outstr,XSTR( "not scanned", 87));
+				sprintf(outstr,"%s", XSTR( "not scanned", 87));
 			hud_targetbox_end_flash(TBOX_FLASH_CARGO);
 			Player->cargo_inspect_time = 0;
 			return 1;
@@ -1483,9 +1483,9 @@
 		}
 
 		if ( !(cargo_sp->flags & SF_SCANNABLE) )
-			sprintf(outstr,XSTR( "cargo: inspecting", 88));
+			sprintf(outstr,"%s", XSTR( "cargo: inspecting", 88));
 		else
-			sprintf(outstr,XSTR( "scanning", 89));
+			sprintf(outstr,"%s", XSTR( "scanning", 89));
 
 		if ( Player->cargo_inspect_time > cargo_sip->scan_time ) {
 			ship_do_cargo_revealed( cargo_sp );
@@ -1494,9 +1494,9 @@
 		}
 	} else {
 		if ( !(cargo_sp->flags & SF_SCANNABLE) )
-			sprintf(outstr,XSTR( "cargo: <unknown>", 86));
+			sprintf(outstr,"%s", XSTR( "cargo: <unknown>", 86));
 		else
-			sprintf(outstr,XSTR( "not scanned", 87));
+			sprintf(outstr,"%s", XSTR( "not scanned", 87));
 	}
 
 	return 1;
@@ -1548,7 +1548,7 @@
 				sprintf(outstr,XSTR("cargo: %s", 84), cargo_name );
 			}
 		} else {
-			sprintf(outstr, XSTR( "Scanned", 85) );
+			sprintf(outstr, "%s", XSTR( "Scanned", 85) );
 		}
 	
 		// always bash cargo_inspect_time to 0 since AI ships can reveal cargo that we
@@ -1584,9 +1584,9 @@
 
 		if ( (dot < CARGO_MIN_DOT_TO_REVEAL) || (!subsys_in_view) ) {
 			if ( !(cargo_sp->flags & SF_SCANNABLE) )
-				sprintf(outstr,XSTR( "cargo: <unknown>", 86));
+				sprintf(outstr,"%s", XSTR( "cargo: <unknown>", 86));
 			else
-				sprintf(outstr,XSTR( "not scanned", 87));
+				sprintf(outstr,"%s", XSTR( "not scanned", 87));
 			hud_targetbox_end_flash(TBOX_FLASH_CARGO);
 			Player->cargo_inspect_time = 0;
 			return 1;
@@ -1598,9 +1598,9 @@
 		}
 
 		if ( !(cargo_sp->flags & SF_SCANNABLE) )
-			sprintf(outstr,XSTR( "cargo: inspecting", 88));
+			sprintf(outstr,"%s", XSTR( "cargo: inspecting", 88));
 		else
-			sprintf(outstr,XSTR( "scanning", 89));
+			sprintf(outstr,"%s", XSTR( "scanning", 89));
 
 		if ( Player->cargo_inspect_time > cargo_sip->scan_time ) {
 			ship_do_cap_subsys_cargo_revealed( cargo_sp, subsys, 0);
@@ -1609,9 +1609,9 @@
 		}
 	} else {
 		if ( !(cargo_sp->flags & SF_SCANNABLE) )
-			sprintf(outstr,XSTR( "cargo: <unknown>", 86));
+			sprintf(outstr,"%s", XSTR( "cargo: <unknown>", 86));
 		else
-			sprintf(outstr,XSTR( "not scanned", 87));
+			sprintf(outstr,"%s", XSTR( "not scanned", 87));
 	}
 
 	return 1;
Index: diaspora-1.0.4/Diaspora/fs2_open/code/ship/ship.cpp
===================================================================
--- diaspora-1.0.4.orig/Diaspora/fs2_open/code/ship/ship.cpp	2012-11-10 08:37:23.000000000 +0100
+++ diaspora-1.0.4/Diaspora/fs2_open/code/ship/ship.cpp	2013-02-15 19:19:25.303340905 +0100
@@ -14181,7 +14181,7 @@
 		}
 		sprintf(outbuf, NOX("%02d:%02d"), minutes, seconds);
 	} else {
-		sprintf( outbuf, XSTR( "Unknown", 497) );
+		sprintf( outbuf, "%s", XSTR( "Unknown", 497) );
 	}
 
 	return outbuf;
ftbfs.patch (12,309 bytes)   

niffiwan

2013-02-16 10:45

developer   ~0014715

I've done a side by side comparison of the patch in this issue and the one in 2776, and the one in 2776 appears to be a (slight) superset of this one. i.e. current trunk should not have these issues.

Issue History

Date Modified Username Field Change
2013-02-15 18:31 bugmenot New Issue
2013-02-15 18:31 bugmenot Status new => assigned
2013-02-15 18:31 bugmenot Assigned To => chief1983
2013-02-15 18:32 bugmenot File Added: ftbfs.patch
2013-02-16 05:44 Echelon9 Status assigned => code review
2013-02-16 10:43 niffiwan Relationship added duplicate of 0002776
2013-02-16 10:45 niffiwan Note Added: 0014715
2013-02-16 10:45 niffiwan Status code review => closed
2013-02-16 10:45 niffiwan Assigned To chief1983 => niffiwan
2013-02-16 10:45 niffiwan Resolution open => duplicate