CID 22571: Copy into fixed size buffer (STRING_OVERFLOW)

replace strcat with strlcat
This commit is contained in:
Enno Rehling 2015-10-30 10:55:06 +01:00
parent 05ef6deb26
commit 2f82cccea1
1 changed files with 9 additions and 7 deletions

View File

@ -1108,7 +1108,7 @@ static void cycle_route(order * ord, unit * u, int gereist)
{
int cm = 0;
char tail[1024], *bufp = tail;
char neworder[2048];
char neworder[2048], *obuf = neworder;
char token[128];
direction_t d = NODIRECTION;
bool paused = false;
@ -1163,14 +1163,16 @@ static void cycle_route(order * ord, unit * u, int gereist)
/* da PAUSE nicht in ein shortdirections[d] umgesetzt wird (ist
* hier keine normale direction), muss jede PAUSE einzeln
* herausgefiltert und explizit gesetzt werden */
if (neworder[0])
strcat(neworder, " ");
strcat(neworder, LOC(lang, parameters[P_PAUSE]));
if (neworder != obuf) {
obuf += strlcat(obuf, " ", sizeof(neworder)-(obuf-neworder));
}
obuf += strlcat(obuf, LOC(lang, parameters[P_PAUSE]), sizeof(neworder) - (obuf - neworder));
}
else {
if (neworder[0])
strcat(neworder, " ");
strcat(neworder, LOC(lang, shortdirections[d]));
if (neworder != obuf) {
obuf += strlcat(obuf, " ", sizeof(neworder) - (obuf - neworder));
}
obuf += strlcat(obuf, LOC(lang, shortdirections[d]), sizeof(neworder) - (obuf - neworder));
}
}