From c4d580d4e1aba16739caa49c7910b54b06e7ab92 Mon Sep 17 00:00:00 2001 From: divverent Date: Tue, 4 Nov 2008 19:16:07 +0000 Subject: [PATCH] fix some format string errors, and return value of read() ignored warnings git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@8546 d7cf8633-e32d-0410-b094-e92efae38249 --- csprogs.c | 2 +- fs.c | 13 +++++++++++-- host_cmd.c | 2 +- prvm_cmds.c | 2 +- sv_user.c | 2 +- 5 files changed, 15 insertions(+), 6 deletions(-) diff --git a/csprogs.c b/csprogs.c index 203e1070..8f15c553 100644 --- a/csprogs.c +++ b/csprogs.c @@ -44,7 +44,7 @@ void CL_VM_Error (const char *format, ...) //[515]: hope it will be never execut Cvar_SetValueQuick(&csqc_progsize, -1); // Host_AbortCurrentFrame(); //[515]: hmmm... if server says it needs csqc then client MUST disconnect - Host_Error(va("CL_VM_Error: %s", errorstring)); + Host_Error("CL_VM_Error: %s", errorstring); } void CL_VM_UpdateDmgGlobals (int dmg_take, int dmg_save, vec3_t dmg_origin) { diff --git a/fs.c b/fs.c index 4d720f36..c83273e4 100644 --- a/fs.c +++ b/fs.c @@ -472,7 +472,11 @@ int PK3_BuildFileList (pack_t *pack, const pk3_endOfCentralDir_t *eocd) // Load the central directory in memory central_dir = (unsigned char *)Mem_Alloc (tempmempool, eocd->cdir_size); lseek (pack->handle, eocd->cdir_offset, SEEK_SET); - read (pack->handle, central_dir, eocd->cdir_size); + if(read (pack->handle, central_dir, eocd->cdir_size) != eocd->cdir_size) + { + Mem_Free (central_dir); + return -1; + } // Extract the files properties // The parsing is done "by hand" because some fields have variable sizes and @@ -808,7 +812,12 @@ pack_t *FS_LoadPackPAK (const char *packfile) #endif if (packhandle < 0) return NULL; - read (packhandle, (void *)&header, sizeof(header)); + if(read (packhandle, (void *)&header, sizeof(header)) != sizeof(header)) + { + Con_Printf ("%s is not a packfile\n", packfile); + close(packhandle); + return NULL; + } if (memcmp(header.id, "PACK", 4)) { Con_Printf ("%s is not a packfile\n", packfile); diff --git a/host_cmd.c b/host_cmd.c index ee974ac6..c0a38fca 100644 --- a/host_cmd.c +++ b/host_cmd.c @@ -2158,7 +2158,7 @@ void Host_SendCvar_f (void) if(svs.clients[i].active && svs.clients[i].netconnection) { host_client = &svs.clients[i]; - Host_ClientCommands(va("sendcvar %s\n", cvarname)); + Host_ClientCommands("sendcvar %s\n", cvarname); } host_client = old; } diff --git a/prvm_cmds.c b/prvm_cmds.c index 812860ba..ccd5b0a0 100644 --- a/prvm_cmds.c +++ b/prvm_cmds.c @@ -23,7 +23,7 @@ void VM_Warning(const char *fmt, ...) dpvsnprintf(msg,sizeof(msg),fmt,argptr); va_end(argptr); - Con_Printf(msg); + Con_Print(msg); // TODO: either add a cvar/cmd to control the state dumping or replace some of the calls with Con_Printf [9/13/2006 Black] if(prvm_backtraceforwarnings.integer && recursive != realtime) // NOTE: this compares to the time, just in case if PRVM_PrintState causes a Host_Error and keeps recursive set diff --git a/sv_user.c b/sv_user.c index 78ff1f9f..882418c6 100644 --- a/sv_user.c +++ b/sv_user.c @@ -860,7 +860,7 @@ clc_stringcmd_invalid: Mem_Free(temp); // calculated crc, send the file info to the client // (so that it can verify the data) - Host_ClientCommands(va("\ncl_downloadfinished %i %i %s\n", size, crc, host_client->download_name)); + Host_ClientCommands("\ncl_downloadfinished %i %i %s\n", size, crc, host_client->download_name); Con_DPrintf("Download of %s by %s has finished\n", host_client->download_name, host_client->name); FS_Close(host_client->download_file); host_client->download_file = NULL; -- 2.39.2