1
0
Fork 0

(svn r1104) -Fix: nasty server crash buffer overflow problem when using release build. Big thanks to Truelight for the guidance in fixing this very annoying bug!

-VS.NET now treats warnings as errors too in the release build.
release/0.4.5
darkvater 2004-12-15 20:08:01 +00:00
parent d7d3ff4849
commit d867a845fd
2 changed files with 9 additions and 11 deletions

View File

@ -1186,24 +1186,20 @@ void NetworkPopulateCompanyInfo(void)
ci = NetworkFindClientInfoFromIndex(NETWORK_SERVER_INDEX); ci = NetworkFindClientInfoFromIndex(NETWORK_SERVER_INDEX);
// Register local player (if not dedicated) // Register local player (if not dedicated)
if (ci != NULL && _local_player < MAX_PLAYERS) { if (ci != NULL && ci->client_playas > 0 && ci->client_playas <= MAX_PLAYERS)
snprintf(_network_player_info[ci->client_playas-1].players, sizeof(_network_player_info[ci->client_playas-1].players), "%s", ci->client_name); ttd_strlcpy(_network_player_info[ci->client_playas-1].players, ci->client_name, sizeof(_network_player_info[ci->client_playas-1].players));
}
FOR_ALL_CLIENTS(cs) { FOR_ALL_CLIENTS(cs) {
char client_name[NETWORK_NAME_LENGTH]; char client_name[NETWORK_NAME_LENGTH];
char temp[NETWORK_PLAYERS_LENGTH];
NetworkGetClientName(client_name, sizeof(client_name), cs); NetworkGetClientName(client_name, sizeof(client_name), cs);
ci = DEREF_CLIENT_INFO(cs); ci = DEREF_CLIENT_INFO(cs);
if (ci != NULL && ci->client_playas <= MAX_PLAYERS) { if (ci != NULL && ci->client_playas > 0 && ci->client_playas <= MAX_PLAYERS) {
if (_network_player_info[ci->client_playas-1].players[0] == '\0') if (strlen(_network_player_info[ci->client_playas-1].players) != 0)
snprintf(_network_player_info[ci->client_playas-1].players, sizeof(_network_player_info[ci->client_playas-1].players), "%s", client_name); strncat(_network_player_info[ci->client_playas-1].players, ", ", sizeof(_network_player_info[ci->client_playas-1].players));
else {
snprintf(temp, sizeof(temp), "%s, %s", _network_player_info[ci->client_playas-1].players, client_name); strncat(_network_player_info[ci->client_playas-1].players, client_name, sizeof(_network_player_info[ci->client_playas-1].players));
snprintf(_network_player_info[ci->client_playas-1].players, sizeof(_network_player_info[ci->client_playas-1].players), "%s", temp);
}
} }
} }
} }

View File

@ -45,6 +45,7 @@
ProgramDataBaseFileName=".\Release/" ProgramDataBaseFileName=".\Release/"
BrowseInformation="1" BrowseInformation="1"
WarningLevel="3" WarningLevel="3"
WarnAsError="TRUE"
SuppressStartupBanner="TRUE" SuppressStartupBanner="TRUE"
DebugInformationFormat="3" DebugInformationFormat="3"
CompileAs="1"/> CompileAs="1"/>
@ -118,6 +119,7 @@
ProgramDataBaseFileName=".\Checked/" ProgramDataBaseFileName=".\Checked/"
BrowseInformation="1" BrowseInformation="1"
WarningLevel="3" WarningLevel="3"
WarnAsError="TRUE"
SuppressStartupBanner="TRUE" SuppressStartupBanner="TRUE"
DebugInformationFormat="3" DebugInformationFormat="3"
CallingConvention="1" CallingConvention="1"