]> de.git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
cleaned up many text buffer sizes throughout the engine, most now use MAX_INPUTLINE...
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Wed, 23 Nov 2005 02:54:50 +0000 (02:54 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Wed, 23 Nov 2005 02:54:50 +0000 (02:54 +0000)
increased MAX_INPUTLINE from 256 to 16384, so now console commandlines and many other things can be very large

git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@5816 d7cf8633-e32d-0410-b094-e92efae38249

28 files changed:
cl_demo.c
cl_main.c
cl_parse.c
cl_screen.c
cl_video.c
cmd.c
common.c
common.h
console.c
cvar.c
fs.c
gl_backend.c
host.c
host_cmd.c
keys.c
keys.h
menu.c
model_brush.c
pr_cmds.c
pr_edict.c
prvm_cmds.c
prvm_cmds.h
prvm_edict.c
r_shadow.c
r_sky.c
sys_linux.c
sys_sdl.c
sys_win.c

index 2ab796bcd22418cf891383062d83ed8969f69d2a..3a655ea0aeb7929559535f8d522c1de355172fad 100644 (file)
--- a/cl_demo.c
+++ b/cl_demo.c
@@ -46,7 +46,7 @@ Called to play the next demo in the demo loop
 */
 void CL_NextDemo (void)
 {
-       char    str[1024];
+       char    str[MAX_INPUTLINE];
 
        if (cls.demonum == -1)
                return;         // don't play demos
@@ -313,7 +313,7 @@ play [demoname]
 */
 void CL_PlayDemo_f (void)
 {
-       char    name[256];
+       char    name[MAX_QPATH];
        int c;
        qboolean neg = false;
 
index 13c04f1ea15a1e1d6b732db6237daea4ee0a495a..dd1effc6ee2b9d385cdd7b99ec5c22b65c79fcf1 100644 (file)
--- a/cl_main.c
+++ b/cl_main.c
@@ -1507,6 +1507,7 @@ void CL_Init (void)
        r_refdef.maxentities = MAX_EDICTS + 256 + 512;
        r_refdef.entities = (entity_render_t **)Mem_Alloc(cl_mempool, sizeof(entity_render_t *) * r_refdef.maxentities);
        // 256k drawqueue buffer
+       // TODO: make dynamic
        r_refdef.maxdrawqueuesize = 256 * 1024;
        r_refdef.drawqueue = (unsigned char *)Mem_Alloc(cl_mempool, r_refdef.maxdrawqueuesize);
 
index f32d9b48d3c4b5f09527c6a2f9ff1250249a8a94..7223ce10e753ac4b58a64fcc257526210ee0faf4 100644 (file)
@@ -213,7 +213,7 @@ void CL_KeepaliveMessage (void)
 void CL_ParseEntityLump(char *entdata)
 {
        const char *data;
-       char key[128], value[4096];
+       char key[128], value[MAX_INPUTLINE];
        FOG_clear(); // LordHavoc: no fog until set
        // LordHavoc: default to the map's sky (q3 shader parsing sets this)
        R_SetSkyBox(cl.worldmodel->brush.skybox);
index 9fc16596e4461d6bb5de38d4822e4e33772abfe5..fa9bff8ec078f54f24f7a98ef6abddae296baa48 100644 (file)
@@ -162,7 +162,7 @@ CENTER PRINTING
 ===============================================================================
 */
 
-char           scr_centerstring[1024];
+char           scr_centerstring[MAX_INPUTLINE];
 float          scr_centertime_start;   // for slow victory printing
 float          scr_centertime_off;
 int                    scr_center_lines;
@@ -1198,7 +1198,7 @@ envmapinfo[12] =
 static void R_Envmap_f (void)
 {
        int j, size;
-       char filename[256], basename[256];
+       char filename[MAX_QPATH], basename[MAX_QPATH];
        unsigned char *buffer1;
        unsigned char *buffer2;
        unsigned char *buffer3;
index 1055cf00a1f0be5484278ad4f75247b2fdcfe766..84332390eadc36ed65763d3d713d96bbd2756b62 100644 (file)
@@ -266,7 +266,7 @@ void CL_VideoStop(void)
 
 static void CL_PlayVideo_f(void)
 {
-       char name[1024];
+       char name[MAX_QPATH];
 
        Host_StartVideo();
 
diff --git a/cmd.c b/cmd.c
index 47892f9afb2e9e07a17e049a2a9b8b6a484a7256..9a8a56da40776296ba4a3333e31774917bf0d9b2 100644 (file)
--- a/cmd.c
+++ b/cmd.c
@@ -22,6 +22,13 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 #include "quakedef.h"
 
 #define        MAX_ALIAS_NAME  32
+// this is the largest script file that can be executed in one step
+// LordHavoc: inreased this from 8192 to 32768
+#define CMDBUFSIZE 32768
+// maximum number of parameters to a command
+#define        MAX_ARGS 80
+// maximum tokenizable commandline length (counting NUL terminations)
+#define CMD_TOKENIZELENGTH (MAX_INPUTLINE + 80)
 
 typedef struct cmdalias_s
 {
@@ -36,7 +43,6 @@ static qboolean cmd_wait;
 
 static mempool_t *cmd_mempool;
 
-#define CMD_TOKENIZELENGTH 4096
 static char cmd_tokenizebuffer[CMD_TOKENIZELENGTH];
 static int cmd_tokenizebufferpos = 0;
 
@@ -64,9 +70,8 @@ static void Cmd_Wait_f (void)
 =============================================================================
 */
 
-       // LordHavoc: inreased this from 8192 to 32768
 static sizebuf_t       cmd_text;
-static unsigned char           cmd_text_buf[32768];
+static unsigned char           cmd_text_buf[CMDBUFSIZE];
 
 /*
 ============
@@ -135,11 +140,10 @@ Cbuf_Execute
 static void Cmd_PreprocessString( const char *intext, char *outtext, unsigned maxoutlen, cmdalias_t *alias );
 void Cbuf_Execute (void)
 {
-#define EXECUTESTRING_BUFFER 2048
        int i;
        char *text;
-       char line[1024];
-       char preprocessed[EXECUTESTRING_BUFFER];
+       char line[MAX_INPUTLINE];
+       char preprocessed[MAX_INPUTLINE];
        int quotes;
 
        // LordHavoc: making sure the tokenizebuffer doesn't get filled up by repeated crashes
@@ -178,7 +182,7 @@ void Cbuf_Execute (void)
                }
 
 // execute the command line
-               Cmd_PreprocessString( line, preprocessed, EXECUTESTRING_BUFFER, NULL );
+               Cmd_PreprocessString( line, preprocessed, sizeof(preprocessed), NULL );
                Cmd_ExecuteString (preprocessed, src_command);
 
                if (cmd_wait)
@@ -213,7 +217,7 @@ void Cmd_StuffCmds_f (void)
 {
        int             i, j, l;
        // this is per command, and bounds checked (no buffer overflows)
-       char    build[2048];
+       char    build[MAX_INPUTLINE];
 
        if (Cmd_Argc () != 1)
        {
@@ -308,7 +312,7 @@ Creates a new command that executes a command string (possibly ; seperated)
 static void Cmd_Alias_f (void)
 {
        cmdalias_t      *a;
-       char            cmd[1024];
+       char            cmd[MAX_INPUTLINE];
        int                     i, c;
        const char              *s;
 
@@ -385,9 +389,6 @@ typedef struct cmd_function_s
        xcommand_t function;
 } cmd_function_t;
 
-
-#define        MAX_ARGS                80
-
 static int cmd_argc;
 static const char *cmd_argv[MAX_ARGS];
 static const char *cmd_null_string = "";
@@ -492,9 +493,8 @@ Called for aliases and fills in the alias into the cbuffer
 */
 static void Cmd_ExecuteAlias (cmdalias_t *alias)
 {
-#define ALIAS_BUFFER 1024
-       static char buffer[ ALIAS_BUFFER + 2 ];
-       Cmd_PreprocessString( alias->value, buffer, ALIAS_BUFFER, alias );
+       static char buffer[ MAX_INPUTLINE + 2 ];
+       Cmd_PreprocessString( alias->value, buffer, sizeof(buffer) - 2, alias );
        Cbuf_AddText( buffer );
 }
 
index 00794c986ca14c5fb8ea0316c1dfd80905ff66c5..e7c5accde6bc444b5340d028368702b6de2143e4 100644 (file)
--- a/common.c
+++ b/common.c
@@ -32,13 +32,11 @@ cvar_t cmdline = {0, "cmdline","0"};
 
 extern qboolean fs_modified;   // set true if using non-id files
 
-char com_token[1024];
+char com_token[MAX_INPUTLINE];
 int com_argc;
 const char **com_argv;
 
-// LordHavoc: made commandline 1024 characters instead of 256
-#define CMDLINE_LENGTH 1024
-char com_cmdline[CMDLINE_LENGTH];
+char com_cmdline[MAX_INPUTLINE];
 
 gamemode_t gamemode;
 const char *gamename;
@@ -420,7 +418,7 @@ float MSG_ReadBigFloat (void)
 
 char *MSG_ReadString (void)
 {
-       static char string[2048];
+       static char string[MAX_INPUTLINE];
        int l,c;
        for (l = 0;l < (int) sizeof(string) - 1 && (c = MSG_ReadChar()) != -1 && c != 0;l++)
                string[l] = c;
@@ -879,16 +877,16 @@ void COM_InitArgv (void)
                {
                        // arg contains whitespace, store quotes around it
                        com_cmdline[n++] = '\"';
-                       while ((n < (CMDLINE_LENGTH - 1)) && com_argv[j][i])
+                       while ((n < ((int)sizeof(com_cmdline) - 1)) && com_argv[j][i])
                                com_cmdline[n++] = com_argv[j][i++];
                        com_cmdline[n++] = '\"';
                }
                else
                {
-                       while ((n < (CMDLINE_LENGTH - 1)) && com_argv[j][i])
+                       while ((n < ((int)sizeof(com_cmdline) - 1)) && com_argv[j][i])
                                com_cmdline[n++] = com_argv[j][i++];
                }
-               if (n < (CMDLINE_LENGTH - 1))
+               if (n < ((int)sizeof(com_cmdline) - 1))
                        com_cmdline[n++] = ' ';
                else
                        break;
@@ -1197,8 +1195,8 @@ int COM_ReadAndTokenizeLine(const char **text, char **argv, int maxargc, char *t
 // written by Elric, thanks Elric!
 char *SearchInfostring(const char *infostring, const char *key)
 {
-       static char value [256];
-       char crt_key [256];
+       static char value [MAX_INPUTLINE];
+       char crt_key [MAX_INPUTLINE];
        size_t value_ind, key_ind;
        char c;
 
index 3f6c0ddebe2825dcc9efe3856ca4521e75d1bf1b..ffbcc8c139957f48abb3800c33d32821c19295eb 100644 (file)
--- a/common.h
+++ b/common.h
@@ -21,6 +21,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 #ifndef COMMON_H
 #define COMMON_H
 
+// many buffers use this size
+#define MAX_INPUTLINE 16384
+
 
 // MSVC has a different name for several standard functions
 #ifdef WIN32
@@ -189,7 +192,7 @@ float MSG_ReadAngle (protocolversion_t protocol);
 
 //============================================================================
 
-extern char com_token[1024];
+extern char com_token[MAX_INPUTLINE];
 
 int COM_ParseToken(const char **datapointer, int returnnewline);
 int COM_ParseTokenConsole(const char **datapointer);
index 5eb850314b70140632816227e7b15c6b83c289d8..4b66cd7579555be1cde58f546169c5b450b033a1 100644 (file)
--- a/console.c
+++ b/console.c
@@ -368,7 +368,7 @@ void Con_Init (void)
        con_totallines = CON_TEXTSIZE / con_linewidth;
 
        // Allocate a log queue
-       logq_size = 512;
+       logq_size = MAX_INPUTLINE;
        logqueue = (unsigned char *)Mem_Alloc (tempmempool, logq_size);
        logq_ind = 0;
 
@@ -535,7 +535,7 @@ void Con_Print(const char *msg)
 {
        int mask = 0;
        static int index = 0;
-       static char line[16384];
+       static char line[MAX_INPUTLINE];
 
        for (;*msg;msg++)
        {
@@ -577,7 +577,7 @@ void Con_Print(const char *msg)
                // append the character
                line[index++] = *msg;
                // if this is a newline character, we have a complete line to print
-               if (*msg == '\n' || index >= 16000)
+               if (*msg == '\n' || index >= (int)sizeof(line) / 2)
                {
                        // terminate the line
                        line[index] = 0;
@@ -601,9 +601,6 @@ void Con_Print(const char *msg)
 }
 
 
-// LordHavoc: increased from 4096 to 16384
-#define        MAXPRINTMSG     16384
-
 /*
 ================
 Con_Printf
@@ -614,7 +611,7 @@ Prints to all appropriate console targets
 void Con_Printf(const char *fmt, ...)
 {
        va_list argptr;
-       char msg[MAXPRINTMSG];
+       char msg[MAX_INPUTLINE];
 
        va_start(argptr,fmt);
        dpvsnprintf(msg,sizeof(msg),fmt,argptr);
@@ -647,7 +644,7 @@ A Con_Printf that only shows up if the "developer" cvar is set
 void Con_DPrintf(const char *fmt, ...)
 {
        va_list argptr;
-       char msg[MAXPRINTMSG];
+       char msg[MAX_INPUTLINE];
 
        if (!developer.integer)
                return;                 // don't confuse non-developers with techie stuff...
@@ -681,7 +678,7 @@ void Con_DrawInput (void)
 {
        int             y;
        int             i;
-       char editlinecopy[257], *text;
+       char editlinecopy[MAX_INPUTLINE+1], *text;
 
        if (!key_consoleactive)
                return;         // don't draw anything
@@ -696,7 +693,7 @@ void Con_DrawInput (void)
        y = (int)strlen(text);
 
 // fill out remainder with spaces
-       for (i = y; i < 256; i++)
+       for (i = y; i < (int)sizeof(editlinecopy)-1; i++)
                text[i] = ' ';
 
        // add the cursor frame
@@ -730,8 +727,7 @@ void Con_DrawNotify (void)
        char    *text;
        int             i;
        float   time;
-       extern char chat_buffer[256];
-       char    temptext[256];
+       char    temptext[MAX_INPUTLINE];
        int colorindex = -1; //-1 for default
 
        if (con_notify.integer < 0)
diff --git a/cvar.c b/cvar.c
index 394a83270ac220db05219120c40ddb17770ca00c..655d91d2fd81927bc2541bfbc8f1e135cbd9c25d 100644 (file)
--- a/cvar.c
+++ b/cvar.c
@@ -252,7 +252,7 @@ Cvar_SetValue
 */
 void Cvar_SetValueQuick(cvar_t *var, float value)
 {
-       char val[256];
+       char val[MAX_INPUTLINE];
 
        if ((float)((int)value) == value)
                sprintf(val, "%i", (int)value);
@@ -263,7 +263,7 @@ void Cvar_SetValueQuick(cvar_t *var, float value)
 
 void Cvar_SetValue(const char *var_name, float value)
 {
-       char val[256];
+       char val[MAX_INPUTLINE];
 
        if ((float)((int)value) == value)
                sprintf(val, "%i", (int)value);
diff --git a/fs.c b/fs.c
index 46172798fe28f0a4f91ab0a677d99e14ad654cc1..fd20cdc17a9b689c96817c4fa6fe98e278b533fa 100644 (file)
--- a/fs.c
+++ b/fs.c
@@ -1712,18 +1712,17 @@ Print a string into a file
 int FS_VPrintf (qfile_t* file, const char* format, va_list ap)
 {
        int len;
-       fs_offset_t buff_size;
-       char *tempbuff = NULL;
+       fs_offset_t buff_size = MAX_INPUTLINE;
+       char *tempbuff;
 
-       buff_size = 1024;
-       tempbuff = (char *)Mem_Alloc (tempmempool, buff_size);
-       len = dpvsnprintf (tempbuff, buff_size, format, ap);
-       while (len < 0)
+       for (;;)
        {
-               Mem_Free (tempbuff);
-               buff_size *= 2;
                tempbuff = (char *)Mem_Alloc (tempmempool, buff_size);
                len = dpvsnprintf (tempbuff, buff_size, format, ap);
+               if (len >= 0 && len < buff_size)
+                       break;
+               Mem_Free (tempbuff);
+               buff_size *= 2;
        }
 
        len = write (file->handle, tempbuff, len);
@@ -2219,7 +2218,7 @@ int FS_ListDirectory(const char *pattern, int oneperline)
        int linebufpos;
        int i, j, k, l;
        const char *name;
-       char linebuf[4096];
+       char linebuf[MAX_INPUTLINE];
        fssearch_t *search;
        search = FS_Search(pattern, true, true);
        if (!search)
index 320e7e73cfdd4deb24347bbd17a77b8928fa2931..bb4d3dc039570160aa62142c8f403ccf871f758c 100644 (file)
@@ -757,7 +757,7 @@ unsigned int GL_Backend_CompileProgram(int vertexstrings_count, const char **ver
 {
        GLint vertexshadercompiled, fragmentshadercompiled, programlinked;
        GLuint vertexshaderobject, fragmentshaderobject, programobject = 0;
-       char compilelog[4096];
+       char compilelog[MAX_INPUTLINE];
        CHECKGLERROR
 
        programobject = qglCreateProgramObjectARB();
diff --git a/host.c b/host.c
index eaa3215585ed169962bb6a647166c0fda98cc8e7..69d7547f0ff9e0a7e1ba2623466e95d99392b292 100644 (file)
--- a/host.c
+++ b/host.c
@@ -115,8 +115,8 @@ This shuts down both the client and server
 */
 void Host_Error (const char *error, ...)
 {
-       static char hosterrorstring1[4096];
-       static char hosterrorstring2[4096];
+       static char hosterrorstring1[MAX_INPUTLINE];
+       static char hosterrorstring2[MAX_INPUTLINE];
        static qboolean hosterror = false;
        va_list argptr;
 
@@ -306,7 +306,7 @@ FIXME: make this just a stuffed echo?
 void SV_ClientPrintf(const char *fmt, ...)
 {
        va_list argptr;
-       char msg[4096];
+       char msg[MAX_INPUTLINE];
 
        va_start(argptr,fmt);
        dpvsnprintf(msg,sizeof(msg),fmt,argptr);
@@ -350,7 +350,7 @@ Sends text to all active clients
 void SV_BroadcastPrintf(const char *fmt, ...)
 {
        va_list argptr;
-       char msg[4096];
+       char msg[MAX_INPUTLINE];
 
        va_start(argptr,fmt);
        dpvsnprintf(msg,sizeof(msg),fmt,argptr);
@@ -369,7 +369,7 @@ Send text over to the client to be executed
 void Host_ClientCommands(const char *fmt, ...)
 {
        va_list argptr;
-       char string[1024];
+       char string[MAX_INPUTLINE];
 
        va_start(argptr,fmt);
        dpvsnprintf(string, sizeof(string), fmt, argptr);
index b3fd8db6be8ca8a2eec22bb8b106e8701b603b3a..2ad0a7bc51845c0ae25c018328dc6d98639fd959 100644 (file)
@@ -460,7 +460,7 @@ Host_Savegame_f
 */
 void Host_Savegame_f (void)
 {
-       char    name[256];
+       char    name[MAX_QPATH];
        qfile_t *f;
        int             i;
        char    comment[SAVEGAME_COMMENT_LENGTH+1];
@@ -903,8 +903,8 @@ void Host_Say(qboolean teamonly)
        int j, quoted;
        const char *p1;
        char *p2;
-       // LordHavoc: 256 char say messages
-       char text[256];
+       // LordHavoc: long say messages
+       char text[1024];
        qboolean fromServer = false;
 
        if (cmd_source == src_command)
@@ -978,7 +978,7 @@ void Host_Tell_f(void)
        client_t *save;
        int j;
        const char *p1, *p2;
-       char text[1024]; // LordHavoc: FIXME: temporary buffer overflow fix (was 64)
+       char text[MAX_INPUTLINE]; // LordHavoc: FIXME: temporary buffer overflow fix (was 64)
        qboolean fromServer = false;
 
        if (cmd_source == src_command)
diff --git a/keys.c b/keys.c
index 48d2da9904653e026bc1d4b87b6c2a8bc8ceda08..b908343918ffcc5929b5a49b86e4d0c1bbd4f98a 100644 (file)
--- a/keys.c
+++ b/keys.c
@@ -603,7 +603,7 @@ static void
 Key_In_Bind_f (void)
 {
        int         i, c, b, m;
-       char        cmd[1024];
+       char        cmd[MAX_INPUTLINE];
 
        c = Cmd_Argc ();
 
@@ -705,7 +705,7 @@ static void
 Key_Bind_f (void)
 {
        int         i, c, b;
-       char        cmd[1024];
+       char        cmd[MAX_INPUTLINE];
 
        c = Cmd_Argc ();
 
diff --git a/keys.h b/keys.h
index 70915a9883a3dd4e7fd08c1812bb5901ec989c3f..343b3112fabe00237267897314785df3b52a6aa6 100644 (file)
--- a/keys.h
+++ b/keys.h
@@ -188,7 +188,6 @@ keynum_t;
 typedef enum keydest_e { key_game, key_message, key_menu } keydest_t;
 
 #define MAX_INPUTLINES 32
-#define MAX_INPUTLINE 256
 #define MAX_BINDMAPS 8
 #define MAX_KEYS 1024
 extern int                     edit_line;
@@ -207,7 +206,7 @@ extern      char            *keybindings[MAX_BINDMAPS][MAX_KEYS];
 
 extern void Key_ClearEditLine(int edit_line);
 extern qboolean chat_team;
-extern char chat_buffer[256];
+extern char chat_buffer[MAX_INPUTLINE];
 extern unsigned int chat_bufferlen;
 
 void Key_WriteBindings(qfile_t *f);
diff --git a/menu.c b/menu.c
index 17e65fd22213fd3b5d9c4c661f75d73360e66341..b993058170650cf1a65a5f7542e706e00c9af719 100644 (file)
--- a/menu.c
+++ b/menu.c
@@ -2548,7 +2548,7 @@ void M_Keys_Draw (void)
        int             keys[NUMKEYS];
        int             y;
        cachepic_t      *p;
-       char    keystring[1024];
+       char    keystring[MAX_INPUTLINE];
 
        M_Background(320, 48 + 8 * numcommands);
 
@@ -4618,7 +4618,7 @@ void MR_SetRouting (qboolean forceold);
 void MP_Error(const char *format, ...)
 {
        static qboolean processingError = false;
-       char errorstring[4096];
+       char errorstring[MAX_INPUTLINE];
        va_list argptr;
 
        va_start (argptr, format);
index 26e731a5a0d3717e54fc716fb551810e724c5db0..b581ee2438ce0de8212ef04719ea345cda34d4ca 100644 (file)
@@ -1158,7 +1158,7 @@ static void Mod_Q1BSP_LoadTextures(lump_t *l)
        texture_t *tx, *tx2, *anims[10], *altanims[10];
        dmiptexlump_t *m;
        unsigned char *data, *mtdata;
-       char name[256];
+       char name[MAX_QPATH];
 
        loadmodel->data_textures = NULL;
 
@@ -1620,18 +1620,18 @@ static void Mod_Q1BSP_ParseWadsFromEntityLump(const char *data)
                        key[strlen(key)-1] = 0;
                if (!COM_ParseToken(&data, false))
                        return; // error
-               strcpy(value, com_token);
+               dpsnprintf(value, sizeof(value), "%s", com_token);
                if (!strcmp("wad", key)) // for HalfLife maps
                {
                        if (loadmodel->brush.ishlbsp)
                        {
                                j = 0;
-                               for (i = 0;i < 4096;i++)
+                               for (i = 0;i < (int)sizeof(value);i++)
                                        if (value[i] != ';' && value[i] != '\\' && value[i] != '/' && value[i] != ':')
                                                break;
                                if (value[i])
                                {
-                                       for (;i < 4096;i++)
+                                       for (;i < (int)sizeof(value);i++)
                                        {
                                                // ignore path - the \\ check is for HalfLife... stupid windoze 'programmers'...
                                                if (value[i] == '\\' || value[i] == '/' || value[i] == ':')
@@ -3782,7 +3782,7 @@ static int Mod_Q3BSP_NativeContentsFromSuperContents(model_t *model, int superco
 static void Mod_Q3BSP_LoadEntities(lump_t *l)
 {
        const char *data;
-       char key[128], value[4096];
+       char key[128], value[MAX_INPUTLINE];
        float v[3];
        loadmodel->brushq3.num_lightgrid_cellsize[0] = 64;
        loadmodel->brushq3.num_lightgrid_cellsize[1] = 64;
index 7d994956ef49d24b5e3c8bf21527ebef4fd7d36c..0e84047bedf74446995cfb9a34e4bfa2daf5003a 100644 (file)
--- a/pr_cmds.c
+++ b/pr_cmds.c
@@ -25,7 +25,7 @@ cvar_t pr_zone_min_strings = {0, "pr_zone_min_strings", "64"};
 
 // LordHavoc: added this to semi-fix the problem of using many ftos calls in a print
 #define STRINGTEMP_BUFFERS 16
-#define STRINGTEMP_LENGTH 4096
+#define STRINGTEMP_LENGTH MAX_INPUTLINE
 static char pr_string_temp[STRINGTEMP_BUFFERS][STRINGTEMP_LENGTH];
 static int pr_string_tempindex = 0;
 
@@ -3027,7 +3027,7 @@ void PF_clientcommand (void)
 //this function originally written by KrimZon, made shorter by LordHavoc
 //20040203: rewritten by LordHavoc (no longer uses allocations)
 int num_tokens = 0;
-char *tokens[256], tokenbuf[4096];
+char *tokens[256], tokenbuf[MAX_INPUTLINE];
 void PF_tokenize (void)
 {
        int pos;
index d921f76045fe984623fd8f6dc9cf5937fa2fe107..c05c684e866cb0a859599b4f80244fb22f44d6ba 100644 (file)
@@ -417,7 +417,7 @@ Returns a string describing *data in a type specific manner
 //int NoCrash_NUM_FOR_EDICT(prvm_edict_t *e);
 char *PR_ValueString (etype_t type, prvm_eval_t *val)
 {
-       static char line[1024]; // LordHavoc: enlarged a bit (was 256)
+       static char line[MAX_INPUTLINE];
        ddef_t *def;
        mfunction_t *f;
        int n;
@@ -477,7 +477,7 @@ Easier to parse than PR_ValueString
 */
 char *PR_UglyValueString (etype_t type, prvm_eval_t *val)
 {
-       static char line[4096];
+       static char line[MAX_INPUTLINE];
        int i;
        const char *s;
        ddef_t *def;
@@ -610,7 +610,7 @@ void ED_Print(prvm_edict_t *ed)
        int             i, j;
        const char      *name;
        int             type;
-       char    tempstring[8192], tempstring2[260]; // temporary string buffers
+       char    tempstring[MAX_INPUTLINE], tempstring2[260]; // temporary string buffers
 
        if (ed->priv.server->free)
        {
@@ -638,11 +638,11 @@ void ED_Print(prvm_edict_t *ed)
                if (j == type_size[type])
                        continue;
 
-               if (strlen(name) > 256)
+               if (strlen(name) > sizeof(tempstring2)-4)
                {
-                       memcpy (tempstring2, name, 256);
-                       tempstring2[256] = tempstring2[257] = tempstring2[258] = '.';
-                       tempstring2[259] = 0;
+                       memcpy (tempstring2, name, sizeof(tempstring2)-4);
+                       tempstring2[sizeof(tempstring2)-4] = tempstring2[sizeof(tempstring2)-3] = tempstring2[sizeof(tempstring2)-2] = '.';
+                       tempstring2[sizeof(tempstring2)-1] = 0;
                        name = tempstring2;
                }
                strlcat (tempstring, name, sizeof (tempstring));
@@ -651,16 +651,16 @@ void ED_Print(prvm_edict_t *ed)
                strcat(tempstring, " ");
 
                name = PR_ValueString(d->type, (prvm_eval_t *)v);
-               if (strlen(name) > 256)
+               if (strlen(name) > sizeof(tempstring2)-4)
                {
-                       memcpy(tempstring2, name, 256);
-                       tempstring2[256] = tempstring2[257] = tempstring2[258] = '.';
-                       tempstring2[259] = 0;
+                       memcpy (tempstring2, name, sizeof(tempstring2)-4);
+                       tempstring2[sizeof(tempstring2)-4] = tempstring2[sizeof(tempstring2)-3] = tempstring2[sizeof(tempstring2)-2] = '.';
+                       tempstring2[sizeof(tempstring2)-1] = 0;
                        name = tempstring2;
                }
                strlcat (tempstring, name, sizeof (tempstring));
                strlcat (tempstring, "\n", sizeof (tempstring));
-               if (strlen(tempstring) >= 4096)
+               if (strlen(tempstring) >= sizeof(tempstring)/2)
                {
                        Con_Print(tempstring);
                        tempstring[0] = 0;
@@ -869,7 +869,7 @@ ED_ParseGlobals
 */
 void ED_ParseGlobals (const char *data)
 {
-       char keyname[1024]; // LordHavoc: good idea? bad idea?  was 64
+       char keyname[MAX_INPUTLINE];
        ddef_t *key;
 
        while (1)
@@ -1499,7 +1499,7 @@ void PR_Fields_f (void)
        int i, j, ednum, used, usedamount;
        int *counts;
        const char *name;
-       char tempstring[5000], tempstring2[260];
+       char tempstring[MAX_INPUTLINE], tempstring2[260];
        prvm_edict_t *ed;
        ddef_t *d;
        int *v;
@@ -1572,11 +1572,11 @@ void PR_Fields_f (void)
                        strlcat (tempstring, tempstring2, sizeof (tempstring));
                        break;
                }
-               if (strlen(name) > 256)
+               if (strlen(name) > sizeof(tempstring2)-4)
                {
-                       memcpy(tempstring2, name, 256);
-                       tempstring2[256] = tempstring2[257] = tempstring2[258] = '.';
-                       tempstring2[259] = 0;
+                       memcpy (tempstring2, name, sizeof(tempstring2)-4);
+                       tempstring2[sizeof(tempstring2)-4] = tempstring2[sizeof(tempstring2)-3] = tempstring2[sizeof(tempstring2)-2] = '.';
+                       tempstring2[sizeof(tempstring2)-1] = 0;
                        name = tempstring2;
                }
                strcat (tempstring, name);
@@ -1585,7 +1585,7 @@ void PR_Fields_f (void)
                dpsnprintf (tempstring2, sizeof (tempstring2), "%5d", counts[i]);
                strlcat (tempstring, tempstring2, sizeof (tempstring));
                strlcat (tempstring, "\n", sizeof (tempstring));
-               if (strlen(tempstring) >= 4096)
+               if (strlen(tempstring) >= sizeof(tempstring)/2)
                {
                        Con_Print(tempstring);
                        tempstring[0] = 0;
index cf7caeef92fe10c133bf8cd17772ff64c8f9c910..e82fa7f7442fee53c955fbf01d5c8dcc029c6e1c 100644 (file)
@@ -1854,7 +1854,7 @@ float tokenize(string s)
 //this function originally written by KrimZon, made shorter by LordHavoc
 //20040203: rewritten by LordHavoc (no longer uses allocations)
 int num_tokens = 0;
-char *tokens[256], tokenbuf[4096];
+char *tokens[256], tokenbuf[MAX_INPUTLINE];
 void VM_tokenize (void)
 {
        size_t pos;
index b77b39d6728fa56ad117a797b221a38b19675cd7..51ccd3e32e9e2f0bb8a91180172158556e3d77dd 100644 (file)
@@ -201,7 +201,7 @@ float       getserverlistindexforkey(string key)
 #define e1000 e100,e100,e100,e100,e100,e100,e100,e100,e100,e100
 
 #define VM_STRINGTEMP_BUFFERS 16
-#define VM_STRINGTEMP_LENGTH 4096
+#define VM_STRINGTEMP_LENGTH MAX_INPUTLINE
 
 // builtins and other general functions
 
index b4ab67354ac1e5444c43daae15282534d69a8df4..f51ffcfc7592a5de7fbfb36db86633ff94172105 100644 (file)
@@ -368,7 +368,7 @@ Returns a string describing *data in a type specific manner
 */
 char *PRVM_ValueString (etype_t type, prvm_eval_t *val)
 {
-       static char line[1024]; // LordHavoc: enlarged a bit (was 256)
+       static char line[MAX_INPUTLINE];
        ddef_t *def;
        mfunction_t *f;
        int n;
@@ -427,7 +427,7 @@ Easier to parse than PR_ValueString
 */
 char *PRVM_UglyValueString (etype_t type, prvm_eval_t *val)
 {
-       static char line[4096];
+       static char line[MAX_INPUTLINE];
        int i;
        const char *s;
        ddef_t *def;
@@ -560,7 +560,7 @@ void PRVM_ED_Print(prvm_edict_t *ed)
        int             i, j;
        const char      *name;
        int             type;
-       char    tempstring[8192], tempstring2[260]; // temporary string buffers
+       char    tempstring[MAX_INPUTLINE], tempstring2[260]; // temporary string buffers
 
        if (ed->priv.required->free)
        {
@@ -588,11 +588,11 @@ void PRVM_ED_Print(prvm_edict_t *ed)
                if (j == prvm_type_size[type])
                        continue;
 
-               if (strlen(name) > 256)
+               if (strlen(name) > sizeof(tempstring2)-4)
                {
-                       memcpy (tempstring2, name, 256);
-                       tempstring2[256] = tempstring2[257] = tempstring2[258] = '.';
-                       tempstring2[259] = 0;
+                       memcpy (tempstring2, name, sizeof(tempstring2)-4);
+                       tempstring2[sizeof(tempstring2)-4] = tempstring2[sizeof(tempstring2)-3] = tempstring2[sizeof(tempstring2)-2] = '.';
+                       tempstring2[sizeof(tempstring2)-1] = 0;
                        name = tempstring2;
                }
                strcat(tempstring, name);
@@ -601,16 +601,16 @@ void PRVM_ED_Print(prvm_edict_t *ed)
                strcat(tempstring, " ");
 
                name = PRVM_ValueString((etype_t)d->type, (prvm_eval_t *)v);
-               if (strlen(name) > 256)
+               if (strlen(name) > sizeof(tempstring2)-4)
                {
-                       memcpy (tempstring2, name, 256);
-                       tempstring2[256] = tempstring2[257] = tempstring2[258] = '.';
-                       tempstring2[259] = 0;
+                       memcpy (tempstring2, name, sizeof(tempstring2)-4);
+                       tempstring2[sizeof(tempstring2)-4] = tempstring2[sizeof(tempstring2)-3] = tempstring2[sizeof(tempstring2)-2] = '.';
+                       tempstring2[sizeof(tempstring2)-1] = 0;
                        name = tempstring2;
                }
                strcat(tempstring, name);
                strcat(tempstring, "\n");
-               if (strlen(tempstring) >= 4096)
+               if (strlen(tempstring) >= sizeof(tempstring)/2)
                {
                        Con_Print(tempstring);
                        tempstring[0] = 0;
@@ -825,7 +825,7 @@ PRVM_ED_ParseGlobals
 */
 void PRVM_ED_ParseGlobals (const char *data)
 {
-       char keyname[1024]; // LordHavoc: good idea? bad idea?  was 64
+       char keyname[MAX_INPUTLINE];
        ddef_t *key;
 
        while (1)
@@ -1535,7 +1535,7 @@ void PRVM_Fields_f (void)
 {
        int i, j, ednum, used, usedamount;
        int *counts;
-       char tempstring[5000], tempstring2[260];
+       char tempstring[MAX_INPUTLINE], tempstring2[260];
        const char *name;
        prvm_edict_t *ed;
        ddef_t *d;
@@ -1624,11 +1624,11 @@ void PRVM_Fields_f (void)
                        strcat(tempstring, tempstring2);
                        break;
                }
-               if (strlen(name) > 256)
+               if (strlen(name) > sizeof(tempstring2)-4)
                {
-                       memcpy (tempstring2, name, 256);
-                       tempstring2[256] = tempstring2[257] = tempstring2[258] = '.';
-                       tempstring2[259] = 0;
+                       memcpy (tempstring2, name, sizeof(tempstring2)-4);
+                       tempstring2[sizeof(tempstring2)-4] = tempstring2[sizeof(tempstring2)-3] = tempstring2[sizeof(tempstring2)-2] = '.';
+                       tempstring2[sizeof(tempstring2)-1] = 0;
                        name = tempstring2;
                }
                strcat(tempstring, name);
@@ -1637,7 +1637,7 @@ void PRVM_Fields_f (void)
                sprintf(tempstring2, "%5d", counts[i]);
                strcat(tempstring, tempstring2);
                strcat(tempstring, "\n");
-               if (strlen(tempstring) >= 4096)
+               if (strlen(tempstring) >= sizeof(tempstring)/2)
                {
                        Con_Print(tempstring);
                        tempstring[0] = 0;
index 1b5a8600481ca9c7cfcddf4fd151773d6ef1c414..c1f71e142146456499405ea10ed3a90677a7c983 100644 (file)
@@ -3288,7 +3288,7 @@ void R_Shadow_SaveWorldLights(void)
        size_t bufchars, bufmaxchars;
        char *buf, *oldbuf;
        char name[MAX_QPATH];
-       char line[1024];
+       char line[MAX_INPUTLINE];
        if (!r_shadow_worldlightchain)
                return;
        if (r_refdef.worldmodel == NULL)
@@ -3390,7 +3390,7 @@ void R_Shadow_LoadWorldLightsFromMap_LightArghliteTyrlite(void)
        char *entfiledata;
        const char *data;
        float origin[3], angles[3], radius, color[3], light[4], fadescale, lightscale, originhack[3], overridecolor[3], vec[4];
-       char key[256], value[1024];
+       char key[256], value[MAX_INPUTLINE];
 
        if (r_refdef.worldmodel == NULL)
        {
@@ -3701,7 +3701,7 @@ void R_Shadow_EditLights_Edit_f(void)
        vec3_t origin, angles, color;
        vec_t radius, corona, coronasizescale, ambientscale, diffusescale, specularscale;
        int style, shadows, flags, normalmode, realtimemode;
-       char cubemapname[1024];
+       char cubemapname[MAX_INPUTLINE];
        if (!r_editlights.integer)
        {
                Con_Print("Cannot spawn light when not in editing mode.  Set r_editlights to 1.\n");
@@ -3718,7 +3718,7 @@ void R_Shadow_EditLights_Edit_f(void)
        radius = r_shadow_selectedlight->radius;
        style = r_shadow_selectedlight->style;
        if (r_shadow_selectedlight->cubemapname)
-               strcpy(cubemapname, r_shadow_selectedlight->cubemapname);
+               strlcpy(cubemapname, r_shadow_selectedlight->cubemapname, sizeof(cubemapname));
        else
                cubemapname[0] = 0;
        shadows = r_shadow_selectedlight->shadow;
diff --git a/r_sky.c b/r_sky.c
index 9f5e311fb7ec4c40fe7a8ceace9f391bab255b0c..981ba57c32da2028f9a4370ee84297d0a6c4db2c 100644 (file)
--- a/r_sky.c
+++ b/r_sky.c
@@ -12,7 +12,7 @@ int skyrendermasked;
 static int skyrendersphere;
 static int skyrenderbox;
 static rtexturepool_t *skytexturepool;
-static char skyname[256];
+static char skyname[MAX_QPATH];
 
 typedef struct suffixinfo_s
 {
@@ -88,7 +88,7 @@ int R_LoadSkyBox(void)
 {
        int i, j, success;
        int indices[4] = {0,1,2,3};
-       char name[1024];
+       char name[MAX_INPUTLINE];
        unsigned char *image_rgba;
        unsigned char *temp;
 
index 1d77ae238524bef9dfec71ef94344f65629b42ba..9b6aa09e0c5b58fe594992581dda07ff944a0032 100644 (file)
@@ -32,7 +32,7 @@ void Sys_Shutdown (void)
 void Sys_Error (const char *error, ...)
 {
        va_list argptr;
-       char string[1024];
+       char string[MAX_INPUTLINE];
 
 // change stdin to non blocking
 #ifndef WIN32
@@ -141,7 +141,7 @@ char *Sys_ConsoleInput(void)
 {
        if (cls.state == ca_dedicated)
        {
-               static char text[256];
+               static char text[MAX_INPUTLINE];
                static unsigned int len = 0;
 #ifdef WIN32
                int c;
index 39c57df999a2159099295a4015f7d8cfe4f5df47..4187d529ed9c07792b04465463688eb7be037a31 100644 (file)
--- a/sys_sdl.c
+++ b/sys_sdl.c
@@ -30,7 +30,7 @@ void Sys_Shutdown (void)
 void Sys_Error (const char *error, ...)
 {
        va_list argptr;
-       char string[1024];
+       char string[MAX_INPUTLINE];
 
 // change stdin to non blocking
 #ifndef WIN32
@@ -83,7 +83,7 @@ char *Sys_ConsoleInput(void)
 {
        if (cls.state == ca_dedicated)
        {
-               static char text[256];
+               static char text[MAX_INPUTLINE];
                int len = 0;
 #ifdef WIN32
                int c;
index e48c2616acdf17cc49ddecc816e155a84609bcb3..b9b4cd387de985b9a3359ca78bc23ed6d1b31068 100644 (file)
--- a/sys_win.c
+++ b/sys_win.c
@@ -50,7 +50,7 @@ SYSTEM IO
 void Sys_Error (const char *error, ...)
 {
        va_list         argptr;
-       char            text[1024];
+       char            text[MAX_INPUTLINE];
        static int      in_sys_error0 = 0;
        static int      in_sys_error1 = 0;
        static int      in_sys_error2 = 0;
@@ -196,7 +196,7 @@ double Sys_DoubleTime (void)
 
 char *Sys_ConsoleInput (void)
 {
-       static char text[256];
+       static char text[MAX_INPUTLINE];
        static int len;
        INPUT_RECORD recs[1024];
        int ch;