hi
attached is a patch that fixes a potential segfault in the powerpc vm
code,
fixed a buffer overflow in g_main.c - level.numteamVotingClients related
a potential ressource leak in the filesystem when that target directory
can't get created
and even if i get flamed again for saying so... it would be nice if some
code formatting could be made - please remove at least the trailing
whitespaces in the sourcecode.
greetings
Martin
--
http://ufoai.sf.net
Index: qcommon/vm_powerpc_asm.c
===================================================================
--- qcommon/vm_powerpc_asm.c (Revision 1788)
+++ qcommon/vm_powerpc_asm.c (Arbeitskopie)
@@ -151,12 +151,14 @@
int argi, argj;
opcode = &powerpc_opcodes[ sname ];
- name = opcode->name;
if ( ! opcode ) {
printf( "Can't find opcode %d\n", sname );
return ASM_ERROR_OPC;
}
+
+ name = opcode->name;
+
if ( ( opcode->flags & PPC_DEST_ARCH ) != PPC_DEST_ARCH ) {
printf( "opcode %s not defined for this arch\n", name );
return ASM_ERROR_OPC;
Index: qcommon/files.c
===================================================================
--- qcommon/files.c (Revision 1788)
+++ qcommon/files.c (Arbeitskopie)
@@ -22,7 +22,7 @@
/*****************************************************************************
* name: files.c
*
- * desc: handle based filesystem for Quake III Arena
+ * desc: handle based filesystem for Quake III Arena
*
* $Archive: /MissionPack/code/qcommon/files.c $
*
@@ -38,7 +38,7 @@
QUAKE3 FILESYSTEM
-All of Quake's data access is through a hierarchical file system, but the contents of
+All of Quake's data access is through a hierarchical file system, but the contents of
the file system can be transparently merged from several sources.
A "qpath" is a reference to game file data. MAX_ZPATH is 256 characters, which must include
@@ -394,7 +394,7 @@
if ( ! fsh[f].handleFiles.file.o ) {
Com_Error( ERR_DROP, "FS_FileForHandle: NULL" );
}
-
+
return fsh[f].handleFiles.file.o;
}
@@ -464,7 +464,7 @@
char temp[MAX_OSPATH];
static char ospath[2][MAX_OSPATH];
static int toggle;
-
+
toggle ^= 1; // flip-flop to allow two returns without clash
if( !game || !game[0] ) {
@@ -474,7 +474,7 @@
Com_sprintf( temp, sizeof(temp), "/%s/%s", game, qpath );
FS_ReplaceSeparators( temp );
Com_sprintf( ospath[toggle], sizeof( ospath[0] ), "%s%s", base, temp );
-
+
return ospath[toggle];
}
@@ -489,7 +489,7 @@
qboolean FS_CreatePath (char *OSPath) {
char *ofs;
char path[MAX_OSPATH];
-
+
// make absolutely sure that it can't back up the path
// FIXME: is c: allowed???
if ( strstr( OSPath, ".." ) || strstr( OSPath, "::" ) ) {
@@ -563,6 +563,11 @@
if ( !f ) {
return;
}
+
+ if( FS_CreatePath( toOSPath ) ) {
+ return;
+ }
+
fseek (f, 0, SEEK_END);
len = ftell (f);
fseek (f, 0, SEEK_SET);
@@ -574,10 +579,6 @@
Com_Error( ERR_FATAL, "Short read in FS_Copyfiles()\n" );
fclose( f );
- if( FS_CreatePath( toOSPath ) ) {
- return;
- }
-
f = fopen( toOSPath, "wb" );
if ( !f ) {
return;
@@ -642,7 +643,7 @@
================
FS_SV_FileExists
-Tests if the file exists
+Tests if the file exists
================
*/
qboolean FS_SV_FileExists( const char *file )
@@ -965,7 +966,7 @@
*/
qboolean FS_FilenameCompare( const char *s1, const char *s2 ) {
int c1, c2;
-
+
do {
c1 = *s1++;
c2 = *s2++;
@@ -983,12 +984,12 @@
if ( c2 == '\\' || c2 == ':' ) {
c2 = '/';
}
-
+
if (c1 != c2) {
return qtrue; // strings not equal
}
} while (c1);
-
+
return qfalse; // strings are equal
}
@@ -1043,7 +1044,7 @@
} while(pakFile != NULL);
} else if ( search->dir ) {
dir = search->dir;
-
+
netpath = FS_BuildOSPath( dir->path, dir->gamedir, filename );
temp = fopen (netpath, "rb");
if ( !temp ) {
@@ -1068,7 +1069,7 @@
// make absolutely sure that it can't back up the path.
// The searchpaths do guarantee that something will always
- // be prepended, so we don't need to worry about "c:" or "//limbo"
+ // be prepended, so we don't need to worry about "c:" or "//limbo"
if ( strstr( filename, ".." ) || strstr( filename, "::" ) ) {
*file = 0;
return -1;
@@ -1109,9 +1110,9 @@
// found it!
// mark the pak as having been referenced and mark specifics on cgame and ui
- // shaders, txt, arena files by themselves do not count as a reference as
- // these are loaded from all pk3s
- // from every pk3 file..
+ // shaders, txt, arena files by themselves do not count as a reference as
+ // these are loaded from all pk3s
+ // from every pk3 file..
l = strlen( filename );
if ( !(pak->referenced & FS_GENERAL_REF)) {
if ( Q_stricmp(filename + l - 7, ".shader") != 0 &&
@@ -1154,7 +1155,7 @@
fsh[*file].zipFilePos = pakFile->pos;
if ( fs_debug->integer ) {
- Com_Printf( "FS_FOpenFileRead: %s (found in '%s')\n",
+ Com_Printf( "FS_FOpenFileRead: %s (found in '%s')\n",
filename, pak->pakFilename );
}
return pakFile->len;
@@ -1184,7 +1185,7 @@
}
dir = search->dir;
-
+
netpath = FS_BuildOSPath( dir->path, dir->gamedir, filename );
fsh[*file].handleFiles.file.o = fopen (netpath, "rb");
if ( !fsh[*file].handleFiles.file.o ) {
@@ -1199,9 +1200,9 @@
}
return FS_filelength (*file);
- }
+ }
}
-
+
#ifdef FS_MISSING
if (missingFiles) {
fprintf(missingFiles, "%s\n", filename);
@@ -1455,7 +1456,7 @@
// make absolutely sure that it can't back up the path.
// The searchpaths do guarantee that something will always
- // be prepended, so we don't need to worry about "c:" or "//limbo"
+ // be prepended, so we don't need to worry about "c:" or "//limbo"
if ( strstr( filename, ".." ) || strstr( filename, "::" ) ) {
return -1;
}
@@ -1578,7 +1579,7 @@
}
return -1;
}
-
+
if ( !buffer ) {
if ( isConfig && com_journal && com_journal->integer == 1 ) {
Com_DPrintf( "Writing len for %s to journal file.\n", qpath );
@@ -1806,21 +1807,21 @@
{
pack_t *thepak;
int index, checksum;
-
+
thepak = FS_LoadZipFile(zipfile, "");
-
+
if(!thepak)
return qfalse;
-
+
checksum = thepak->checksum;
FS_FreePak(thepak);
-
+
for(index = 0; index < fs_numServerReferencedPaks; index++)
{
if(checksum == fs_serverReferencedPaks[index])
return qtrue;
}
-
+
return qfalse;
}
@@ -1995,7 +1996,7 @@
}
Sys_FreeFileList( sysFiles );
}
- }
+ }
}
// return a copy of the list
@@ -2203,7 +2204,7 @@
// we will try each three of them here (yes, it's a bit messy)
path = FS_BuildOSPath( fs_basepath->string, name, "" );
nPaks = 0;
- pPaks = Sys_ListFiles(path, ".pk3", NULL, &nPaks, qfalse);
+ pPaks = Sys_ListFiles(path, ".pk3", NULL, &nPaks, qfalse);
Sys_FreeFileList( pPaks ); // we only use Sys_ListFiles to check wether .pk3 files are present
/* try on home path */
@@ -2338,7 +2339,7 @@
if ( c2 == '\\' || c2 == ':' ) {
c2 = '/';
}
-
+
if (c1 < c2) {
return -1; // strings not equal
}
@@ -2346,7 +2347,7 @@
return 1;
}
} while (c1);
-
+
return 0; // strings are equal
}
@@ -2500,7 +2501,7 @@
return; // we've already got this one
}
}
-
+
Q_strncpyz( fs_gamedir, dir, sizeof( fs_gamedir ) );
//
@@ -2528,7 +2529,7 @@
continue;
// store the game name for downloading
strcpy(pak->pakGamename, dir);
-
+
fs_packFiles += pak->numfiles;
search = Z_Malloc (sizeof(searchpath_t));
@@ -2573,7 +2574,7 @@
{
if(strstr(checkdir, "../") || strstr(checkdir, "..\\"))
return qtrue;
-
+
return qfalse;
}
@@ -2640,7 +2641,7 @@
}
}
- if ( !havepak && fs_serverReferencedPakNames[i] && *fs_serverReferencedPakNames[i] ) {
+ if ( !havepak && fs_serverReferencedPakNames[i] && *fs_serverReferencedPakNames[i] ) {
// Don't got it
if (dlstring)
@@ -2820,14 +2821,14 @@
FS_AddGameDirectory( fs_basepath->string, gameName );
}
// fs_homepath is somewhat particular to *nix systems, only add if relevant
-
+
#ifdef MACOS_X
fs_apppath = Cvar_Get ("fs_apppath", Sys_DefaultAppPath(), CVAR_INIT );
// Make MacOSX also include the base path included with the .app bundle
if (fs_apppath->string[0])
FS_AddGameDirectory(fs_apppath->string, gameName);
#endif
-
+
// NOTE: same filtering below for mods and basegame
if (fs_homepath->string[0] && Q_stricmp(fs_homepath->string,fs_basepath->string)) {
FS_CreatePath ( fs_homepath->string );
@@ -2992,7 +2993,7 @@
Com_Error(ERR_FATAL, "%s", errorText);
}
-
+
if(foundPak & 1)
Cvar_Set("com_standalone", "0");
}
@@ -3038,7 +3039,7 @@
info[0] = 0;
for ( search = fs_searchpaths ; search ; search = search->next ) {
- // is the element a pak file?
+ // is the element a pak file?
if ( !search->pack ) {
continue;
}
@@ -3094,7 +3095,7 @@
info[0] = 0;
for ( search = fs_searchpaths ; search ; search = search->next ) {
- // is the element a pak file?
+ // is the element a pak file?
if ( !search->pack ) {
continue;
}
@@ -3110,7 +3111,7 @@
FS_ReferencedPakChecksums
Returns a space separated string containing the checksums of all referenced pk3 files.
-The server will send this to the clients so they can check which files should be auto-downloaded.
+The server will send this to the clients so they can check which files should be auto-downloaded.
=====================
*/
const char *FS_ReferencedPakChecksums( void ) {
@@ -3137,7 +3138,7 @@
FS_ReferencedPakPureChecksums
Returns a space separated string containing the pure checksums of all referenced pk3 files.
-Servers with sv_pure set will get this string back from clients for pure validation
+Servers with sv_pure set will get this string back from clients for pure validation
The string has a specific order, "cgame ui @ ref1 ref2 ref3 ..."
=====================
@@ -3184,7 +3185,7 @@
FS_ReferencedPakNames
Returns a space separated string containing the names of all referenced pk3 files.
-The server will send this to the clients so they can check which files should be auto-downloaded.
+The server will send this to the clients so they can check which files should be auto-downloaded.
=====================
*/
const char *FS_ReferencedPakNames( void ) {
@@ -3299,7 +3300,7 @@
The checksums and names of the pk3 files referenced at the server
are sent to the client and stored here. The client will use these
-checksums to see if any pk3 files need to be auto-downloaded.
+checksums to see if any pk3 files need to be auto-downloaded.
=====================
*/
void FS_PureServerSetReferencedPaks( const char *pakSums, const char *pakNames ) {
@@ -3336,12 +3337,12 @@
fs_serverReferencedPakNames[i] = CopyString( Cmd_Argv( i ) );
}
}
-
+
// ensure that there are as many checksums as there are pak names.
if(d < c)
c = d;
-
- fs_numServerReferencedPaks = c;
+
+ fs_numServerReferencedPaks = c;
}
/*
@@ -3453,7 +3454,7 @@
FS_Restart(checksumFeed);
return qtrue;
}
-
+
return qfalse;
}
Index: game/g_main.c
===================================================================
--- game/g_main.c (Revision 1788)
+++ game/g_main.c (Arbeitskopie)
@@ -319,11 +319,11 @@
char string[1024];
float f = level.time * 0.001;
Com_sprintf( string, sizeof(string), "team_icon/%s_red", g_redteam.string );
- AddRemap("textures/ctf2/redteam01", string, f);
- AddRemap("textures/ctf2/redteam02", string, f);
+ AddRemap("textures/ctf2/redteam01", string, f);
+ AddRemap("textures/ctf2/redteam02", string, f);
Com_sprintf( string, sizeof(string), "team_icon/%s_blue", g_blueteam.string );
- AddRemap("textures/ctf2/blueteam01", string, f);
- AddRemap("textures/ctf2/blueteam02", string, f);
+ AddRemap("textures/ctf2/blueteam01", string, f);
+ AddRemap("textures/ctf2/blueteam02", string, f);
trap_SetConfigstring(CS_SHADERSTATE, BuildShaderStateConfig());
#endif
}
@@ -381,7 +381,7 @@
cv->modificationCount = cv->vmCvar->modificationCount;
if ( cv->trackChange ) {
- trap_SendServerCommand( -1, va("print \"Server: %s changed to %s\n\"",
+ trap_SendServerCommand( -1, va("print \"Server: %s changed to %s\n\"",
cv->cvarName, cv->vmCvar->string ) );
}
@@ -467,7 +467,7 @@
level.num_entities = MAX_CLIENTS;
// let the server system know where the entites are
- trap_LocateGameData( level.gentities, level.num_entities, sizeof( gentity_t ),
+ trap_LocateGameData( level.gentities, level.num_entities, sizeof( gentity_t ),
&level.clients[0].ps, sizeof( level.clients[0] ) );
// reserve some spots for dead player bodies
@@ -597,7 +597,7 @@
continue;
}
// never select the dedicated follow or scoreboard clients
- if ( client->sess.spectatorState == SPECTATOR_SCOREBOARD ||
+ if ( client->sess.spectatorState == SPECTATOR_SCOREBOARD ||
client->sess.spectatorClient < 0 ) {
continue;
}
@@ -765,9 +765,7 @@
level.numNonSpectatorClients = 0;
level.numPlayingClients = 0;
level.numVotingClients = 0; // don't count bots
- for ( i = 0; i < TEAM_NUM_TEAMS; i++ ) {
- level.numteamVotingClients[i] = 0;
- }
+ memset(level.numteamVotingClients, 0, sizeof(level.numteamVotingClients));
for ( i = 0 ; i < level.maxclients ; i++ ) {
if ( level.clients[i].pers.connected != CON_DISCONNECTED ) {
level.sortedClients[level.numConnectedClients] = i;
@@ -775,7 +773,7 @@
if ( level.clients[i].sess.sessionTeam != TEAM_SPECTATOR ) {
level.numNonSpectatorClients++;
-
+
// decide if this should be auto-followed
if ( level.clients[i].pers.connected == CON_CONNECTED ) {
level.numPlayingClients++;
@@ -796,7 +794,7 @@
}
}
- qsort( level.sortedClients, level.numConnectedClients,
+ qsort( level.sortedClients, level.numConnectedClients,
sizeof(level.sortedClients[0]), SortRanks );
// set the rank value for all clients that are connected and not spectators
@@ -812,7 +810,7 @@
cl->ps.persistant[PERS_RANK] = 1;
}
}
- } else {
+ } else {
rank = -1;
score = 0;
for ( i = 0; i < level.numPlayingClients; i++ ) {
@@ -1007,7 +1005,7 @@
ExitLevel
When the intermission has been exited, the server is either killed
-or moved to a new level based on the "nextmap" cvar
+or moved to a new level based on the "nextmap" cvar
=============
*/
@@ -1030,7 +1028,7 @@
level.changemap = NULL;
level.intermissiontime = 0;
}
- return;
+ return;
}
trap_Cvar_VariableStringBuffer( "nextmap", nextmap, sizeof(nextmap) );
@@ -1277,7 +1275,7 @@
if ( level.numPlayingClients < 2 ) {
return qfalse;
}
-
+
if ( g_gametype.integer >= GT_TEAM ) {
return level.teamScores[TEAM_RED] == level.teamScores[TEAM_BLUE];
}
@@ -1708,7 +1706,7 @@
if (thinktime > level.time) {
return;
}
-
+
ent->nextthink = 0;
if (!ent->think) {
G_Error ( "NULL ent->think");
_______________________________________________
ioquake3 mailing list
[email protected]
http://lists.ioquake.org/listinfo.cgi/ioquake3-ioquake.org
By sending this message I agree to love ioquake3 and libsdl.