aboutsummaryrefslogtreecommitdiffstats
path: root/code/sys
diff options
context:
space:
mode:
authoricculus <icculus@edf5b092-35ff-0310-97b2-ce42778d08ea>2009-09-15 00:19:22 +0000
committericculus <icculus@edf5b092-35ff-0310-97b2-ce42778d08ea>2009-09-15 00:19:22 +0000
commita3f687b44d22868f91d96bd7c2b9638a2c68277f (patch)
tree6eb4177e277efede03afeb542db96b3d38251243 /code/sys
parent8296a890684cf72ad241b4ad926003d69606c247 (diff)
downloadioquake3-aero-a3f687b44d22868f91d96bd7c2b9638a2c68277f.tar.gz
ioquake3-aero-a3f687b44d22868f91d96bd7c2b9638a2c68277f.zip
Fixed infinite recursion of writing crashlog because we're out of file handles.
Fixes Bugzilla #3772. git-svn-id: svn://svn.icculus.org/quake3/trunk@1602 edf5b092-35ff-0310-97b2-ce42778d08ea
Diffstat (limited to 'code/sys')
-rw-r--r--code/sys/sys_unix.c31
1 files changed, 24 insertions, 7 deletions
diff --git a/code/sys/sys_unix.c b/code/sys/sys_unix.c
index 470c89f..bcbb086 100644
--- a/code/sys/sys_unix.c
+++ b/code/sys/sys_unix.c
@@ -35,6 +35,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#include <sys/time.h>
#include <pwd.h>
#include <libgen.h>
+#include <fcntl.h>
// Used to determine where to store user-specific files
static char homePath[ MAX_OSPATH ] = { 0 };
@@ -501,23 +502,39 @@ void Sys_ErrorDialog( const char *error )
{
char buffer[ 1024 ];
unsigned int size;
- fileHandle_t f;
+ int f = -1;
+ const char *homepath = Cvar_VariableString( "fs_homepath" );
+ const char *gamedir = Cvar_VariableString( "fs_gamedir" );
const char *fileName = "crashlog.txt";
+ char *ospath = FS_BuildOSPath( homepath, gamedir, fileName );
Sys_Print( va( "%s\n", error ) );
- // Write console log to file
- f = FS_FOpenFileWrite( fileName );
- if( !f )
+ /* make sure the write path for the crashlog exists... */
+ if( FS_CreatePath( ospath ) ) {
+ Com_Printf( "ERROR: couldn't create path '%s' for crash log.\n", ospath );
+ return;
+ }
+
+ /* we might be crashing because we maxed out the Quake MAX_FILE_HANDLES,
+ which will come through here, so we don't want to recurse forever by
+ calling FS_FOpenFileWrite()...use the Unix system APIs instead. */
+ f = open(ospath, O_CREAT | O_TRUNC | O_WRONLY, 0640);
+ if( f == -1 )
{
Com_Printf( "ERROR: couldn't open %s\n", fileName );
return;
}
- while( ( size = CON_LogRead( buffer, sizeof( buffer ) ) ) > 0 )
- FS_Write( buffer, size, f );
+ /* We're crashing, so we don't care much if write() or close() fails. */
+ while( ( size = CON_LogRead( buffer, sizeof( buffer ) ) ) > 0 ) {
+ if (write( f, buffer, size ) != size) {
+ Com_Printf( "ERROR: couldn't fully write to %s\n", fileName );
+ break;
+ }
+ }
- FS_FCloseFile( f );
+ close(f);
}
/*