]> git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - prvm_edict.c
Removed all calls to strcpy; most of them are now calls to strlcpy or memcpy.
[xonotic/darkplaces.git] / prvm_edict.c
index 747e33c7a72abc70c1c3cf9b5c280b37ea7ccfd3..98b1b9824581801779914fc5e388a1537ead9832 100644 (file)
@@ -607,10 +607,10 @@ void PRVM_ED_Print(prvm_edict_t *ed)
                        tempstring2[sizeof(tempstring2)-1] = 0;
                        name = tempstring2;
                }
-               strcat(tempstring, name);
+               strlcat(tempstring, name, sizeof(tempstring));
                for (l = strlen(name);l < 14;l++)
-                       strcat(tempstring, " ");
-               strcat(tempstring, " ");
+                       strlcat(tempstring, " ", sizeof(tempstring));
+               strlcat(tempstring, " ", sizeof(tempstring));
 
                name = PRVM_ValueString((etype_t)d->type, (prvm_eval_t *)v);
                if (strlen(name) > sizeof(tempstring2)-4)
@@ -620,8 +620,8 @@ void PRVM_ED_Print(prvm_edict_t *ed)
                        tempstring2[sizeof(tempstring2)-1] = 0;
                        name = tempstring2;
                }
-               strcat(tempstring, name);
-               strcat(tempstring, "\n");
+               strlcat(tempstring, name, sizeof(tempstring));
+               strlcat(tempstring, "\n", sizeof(tempstring));
                if (strlen(tempstring) >= sizeof(tempstring)/2)
                {
                        Con_Print(tempstring);
@@ -848,7 +848,7 @@ void PRVM_ED_ParseGlobals (const char *data)
                if (com_token[0] == '}')
                        break;
 
-               strcpy (keyname, com_token);
+               strlcpy (keyname, com_token, sizeof(keyname));
 
                // parse value
                if (!COM_ParseTokenConsole(&data))
@@ -1047,7 +1047,7 @@ const char *PRVM_ED_ParseEdict (const char *data, prvm_edict_t *ent)
                // and allow them to be turned into vectors. (FIXME...)
                if (!strcmp(com_token, "angle"))
                {
-                       strcpy (com_token, "angles");
+                       strlcpy (com_token, "angles", sizeof(com_token));
                        anglehack = true;
                }
                else
@@ -1055,9 +1055,9 @@ const char *PRVM_ED_ParseEdict (const char *data, prvm_edict_t *ent)
 
                // FIXME: change light to _light to get rid of this hack
                if (!strcmp(com_token, "light"))
-                       strcpy (com_token, "light_lev");        // hack for single light def
+                       strlcpy (com_token, "light_lev", sizeof(com_token));    // hack for single light def
 
-               strcpy (keyname, com_token);
+               strlcpy (keyname, com_token, sizeof(keyname));
 
                // another hack to fix keynames with trailing spaces
                n = strlen(keyname);
@@ -1097,7 +1097,7 @@ const char *PRVM_ED_ParseEdict (const char *data, prvm_edict_t *ent)
                if (anglehack)
                {
                        char    temp[32];
-                       strcpy (temp, com_token);
+                       strlcpy (temp, com_token, sizeof(temp));
                        sprintf (com_token, "0 %s 0", temp);
                }
 
@@ -1616,32 +1616,32 @@ void PRVM_Fields_f (void)
                switch(d->type & ~DEF_SAVEGLOBAL)
                {
                case ev_string:
-                       strcat(tempstring, "string   ");
+                       strlcat(tempstring, "string   ", sizeof(tempstring));
                        break;
                case ev_entity:
-                       strcat(tempstring, "entity   ");
+                       strlcat(tempstring, "entity   ", sizeof(tempstring));
                        break;
                case ev_function:
-                       strcat(tempstring, "function ");
+                       strlcat(tempstring, "function ", sizeof(tempstring));
                        break;
                case ev_field:
-                       strcat(tempstring, "field    ");
+                       strlcat(tempstring, "field    ", sizeof(tempstring));
                        break;
                case ev_void:
-                       strcat(tempstring, "void     ");
+                       strlcat(tempstring, "void     ", sizeof(tempstring));
                        break;
                case ev_float:
-                       strcat(tempstring, "float    ");
+                       strlcat(tempstring, "float    ", sizeof(tempstring));
                        break;
                case ev_vector:
-                       strcat(tempstring, "vector   ");
+                       strlcat(tempstring, "vector   ", sizeof(tempstring));
                        break;
                case ev_pointer:
-                       strcat(tempstring, "pointer  ");
+                       strlcat(tempstring, "pointer  ", sizeof(tempstring));
                        break;
                default:
                        sprintf (tempstring2, "bad type %i ", d->type & ~DEF_SAVEGLOBAL);
-                       strcat(tempstring, tempstring2);
+                       strlcat(tempstring, tempstring2, sizeof(tempstring));
                        break;
                }
                if (strlen(name) > sizeof(tempstring2)-4)
@@ -1651,12 +1651,12 @@ void PRVM_Fields_f (void)
                        tempstring2[sizeof(tempstring2)-1] = 0;
                        name = tempstring2;
                }
-               strcat(tempstring, name);
+               strlcat(tempstring, name, sizeof(tempstring));
                for (j = (int)strlen(name);j < 25;j++)
-                       strcat(tempstring, " ");
+                       strlcat(tempstring, " ", sizeof(tempstring));
                sprintf(tempstring2, "%5d", counts[i]);
-               strcat(tempstring, tempstring2);
-               strcat(tempstring, "\n");
+               strlcat(tempstring, tempstring2, sizeof(tempstring));
+               strlcat(tempstring, "\n", sizeof(tempstring));
                if (strlen(tempstring) >= sizeof(tempstring)/2)
                {
                        Con_Print(tempstring);