X-Git-Url: http://de.git.xonotic.org/?p=xonotic%2Fdarkplaces.git;a=blobdiff_plain;f=prvm_edict.c;h=5f75aa7b9b37c36f3e42277f64db5968f3bf9241;hp=68f5197aed5ad57c79c72ec0fa87f84acb6d6030;hb=5c77268d0a473dfcf784d69343a3ddabcbd5ab33;hpb=84abed4f5fb96c3812143d967aa065e49e55d19d diff --git a/prvm_edict.c b/prvm_edict.c index 68f5197a..5f75aa7b 100644 --- a/prvm_edict.c +++ b/prvm_edict.c @@ -422,7 +422,7 @@ char *PRVM_ValueString (etype_t type, prvm_eval_t *val) sprintf (line, "pointer"); break; default: - sprintf (line, "bad type %i", type); + sprintf (line, "bad type %i", (int) type); break; } @@ -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); @@ -843,15 +843,15 @@ void PRVM_ED_ParseGlobals (const char *data) while (1) { // parse key - if (!COM_ParseToken(&data, false)) + if (!COM_ParseTokenConsole(&data)) PRVM_ERROR ("PRVM_ED_ParseGlobals: EOF without closing brace"); if (com_token[0] == '}') break; - strcpy (keyname, com_token); + strlcpy (keyname, com_token, sizeof(keyname)); // parse value - if (!COM_ParseToken(&data, false)) + if (!COM_ParseTokenConsole(&data)) PRVM_ERROR ("PRVM_ED_ParseGlobals: EOF without closing brace"); if (com_token[0] == '}') @@ -1036,7 +1036,7 @@ const char *PRVM_ED_ParseEdict (const char *data, prvm_edict_t *ent) while (1) { // parse key - if (!COM_ParseToken(&data, false)) + if (!COM_ParseTokenConsole(&data)) PRVM_ERROR ("PRVM_ED_ParseEdict: EOF without closing brace"); if (developer_entityparsing.integer) Con_Printf("Key: \"%s\"", com_token); @@ -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); @@ -1068,7 +1068,7 @@ const char *PRVM_ED_ParseEdict (const char *data, prvm_edict_t *ent) } // parse value - if (!COM_ParseToken(&data, false)) + if (!COM_ParseTokenConsole(&data)) PRVM_ERROR ("PRVM_ED_ParseEdict: EOF without closing brace"); if (developer_entityparsing.integer) Con_Printf(" \"%s\"\n", com_token); @@ -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); } @@ -1143,7 +1143,7 @@ void PRVM_ED_LoadFromFile (const char *data) while (1) { // parse the opening brace - if (!COM_ParseToken(&data, false)) + if (!COM_ParseTokenConsole(&data)) break; if (com_token[0] != '{') PRVM_ERROR ("PRVM_ED_LoadFromFile: %s: found %s when expecting {", PRVM_NAME, com_token); @@ -1310,7 +1310,7 @@ void PRVM_LoadProgs (const char * filename, int numrequiredfunc, char **required if (prog->progs == NULL || filesize < (fs_offset_t)sizeof(dprograms_t)) PRVM_ERROR ("PRVM_LoadProgs: couldn't load %s for %s", filename, PRVM_NAME); - Con_DPrintf("%s programs occupy %iK.\n", PRVM_NAME, filesize/1024); + Con_DPrintf("%s programs occupy %iK.\n", PRVM_NAME, (int)(filesize/1024)); prog->filecrc = CRC_Block((unsigned char *)prog->progs, filesize); @@ -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);