use safe strings

(cleanup)
This commit is contained in:
ac-stef
2015-08-21 15:51:36 +02:00
parent cf2a8018ff
commit 06f59e0559
4 changed files with 8 additions and 12 deletions
+1 -1
View File
@@ -1062,7 +1062,7 @@ double dlpackage(package *pck)
const char *tmpname = findfile("tmp", "wb");
FILE *outfile = fopen(tmpname, "wb");
string req, pckname = "";
sprintf(req, "%s/%s%s", pck->source->addr, strreplace(pckname, pck->name, " ", "%20"), (pck->type==PCK_MAP || pck->type==PCK_MAPMODEL || pck->type==PCK_SKYBOX) ? ".zip" : "");
formatstring(req)("%s/%s%s", pck->source->addr, strreplace(pckname, pck->name, " ", "%20"), (pck->type==PCK_MAP || pck->type==PCK_MAPMODEL || pck->type==PCK_SKYBOX) ? ".zip" : "");
conoutf("downloading %s from %s ...", pck->name, pck->source->addr);
if(!outfile)
{
+3 -5
View File
@@ -326,7 +326,7 @@ void teaminfo(const char *team, const char *attr)
int t_deaths = 0;
int t_points = 0;
string teammembers = "", tmp;
string teammembers = "";
loopv(players) if(players[i] && players[i]->team == t)
{
@@ -334,8 +334,7 @@ void teaminfo(const char *team, const char *attr)
t_deaths += players[i]->deaths;
t_points += players[i]->points;
t_flags += players[i]->flagscore;
sprintf(tmp, "%s%d ", teammembers, players[i]->clientnum);
concatstring(teammembers, tmp);
concatformatstring(teammembers, "%d ", players[i]->clientnum);
}
loopv(discscores) if(discscores[i].team == t)
@@ -352,8 +351,7 @@ void teaminfo(const char *team, const char *attr)
t_deaths += player1->deaths;
t_points += player1->points;
t_flags += player1->flagscore;
sprintf(tmp, "%s%d ", teammembers, player1->clientnum);
concatstring(teammembers, tmp);
concatformatstring(teammembers, "%d ", player1->clientnum);
}
ATTR_INT(flags, t_flags);
+2 -2
View File
@@ -778,9 +778,9 @@ void preload_entmodels()
defformatstring(widn)("modmdlpickup%d", i-3);
if (identexists(widn))
strcat(buf, getalias(widn));
concatstring(buf, getalias(widn));
else
strcat(buf, entmdlnames[i]);
concatstring(buf, entmdlnames[i]);
model *mdl = loadmodel(buf);
+2 -4
View File
@@ -1333,8 +1333,7 @@ void retrieveservers(vector<char> &data)
CURL *curl = curl_easy_init();
char *pname = curl_easy_escape(curl, global_name, 0);
string request;
sprintf(request, "http://%s/retrieve.do?action=list&name=%s&version=%d&build=%d", mastername, pname, AC_VERSION, getbuildtype()|(1<<16));
defformatstring(request)("http://%s/retrieve.do?action=list&name=%s&version=%d&build=%d", mastername, pname, AC_VERSION, getbuildtype()|(1<<16));
curl_free(pname);
const char *tmpname = findfile(path("config/servers.cfg", true), "wb");
@@ -1397,8 +1396,7 @@ void retrieveservers(vector<char> &data)
defformatstring(text)("retrieving servers from %s:%d... (esc to abort)", mastername, masterport);
show_out_of_renderloop_progress(0, text);
int starttime = SDL_GetTicks(), timeout = 0;
string request;
sprintf(request, "list %s %d %d\n",global_name,AC_VERSION,getbuildtype());
defformatstring(request)("list %s %d %d\n", global_name, AC_VERSION, getbuildtype());
const char *req = request;
int reqlen = strlen(req);
ENetBuffer buf;