forked from github/server
CID 22571: Copy into fixed size buffer (STRING_OVERFLOW)
replace strcat with strlcat
This commit is contained in:
parent
05ef6deb26
commit
2f82cccea1
1 changed files with 9 additions and 7 deletions
16
src/move.c
16
src/move.c
|
@ -1108,7 +1108,7 @@ static void cycle_route(order * ord, unit * u, int gereist)
|
||||||
{
|
{
|
||||||
int cm = 0;
|
int cm = 0;
|
||||||
char tail[1024], *bufp = tail;
|
char tail[1024], *bufp = tail;
|
||||||
char neworder[2048];
|
char neworder[2048], *obuf = neworder;
|
||||||
char token[128];
|
char token[128];
|
||||||
direction_t d = NODIRECTION;
|
direction_t d = NODIRECTION;
|
||||||
bool paused = false;
|
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
|
/* da PAUSE nicht in ein shortdirections[d] umgesetzt wird (ist
|
||||||
* hier keine normale direction), muss jede PAUSE einzeln
|
* hier keine normale direction), muss jede PAUSE einzeln
|
||||||
* herausgefiltert und explizit gesetzt werden */
|
* herausgefiltert und explizit gesetzt werden */
|
||||||
if (neworder[0])
|
if (neworder != obuf) {
|
||||||
strcat(neworder, " ");
|
obuf += strlcat(obuf, " ", sizeof(neworder)-(obuf-neworder));
|
||||||
strcat(neworder, LOC(lang, parameters[P_PAUSE]));
|
}
|
||||||
|
obuf += strlcat(obuf, LOC(lang, parameters[P_PAUSE]), sizeof(neworder) - (obuf - neworder));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (neworder[0])
|
if (neworder != obuf) {
|
||||||
strcat(neworder, " ");
|
obuf += strlcat(obuf, " ", sizeof(neworder) - (obuf - neworder));
|
||||||
strcat(neworder, LOC(lang, shortdirections[d]));
|
}
|
||||||
|
obuf += strlcat(obuf, LOC(lang, shortdirections[d]), sizeof(neworder) - (obuf - neworder));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue