mirror of https://github.com/OpenTTD/OpenTTD
(svn r767) Introduce USERSTRING_LEN (128) and try to make sure we don't overflow it anywhere (as long as we keep USERSTRING_LEN above 7 or so).
parent
d4b723a7c9
commit
3ee0dee12a
3
engine.c
3
engine.c
|
@ -601,7 +601,8 @@ StringID GetCustomEngineName(int engine)
|
||||||
{
|
{
|
||||||
if (!_engine_custom_names[engine])
|
if (!_engine_custom_names[engine])
|
||||||
return _engine_name_strings[engine];
|
return _engine_name_strings[engine];
|
||||||
strcpy(_userstring, _engine_custom_names[engine]);
|
strncpy(_userstring, _engine_custom_names[engine], USERSTRING_LEN);
|
||||||
|
_userstring[USERSTRING_LEN - 1] = '\0';
|
||||||
return STR_SPEC_USERSTRING;
|
return STR_SPEC_USERSTRING;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -53,7 +53,7 @@ static void LandInfoWndProc(Window *w, WindowEvent *e)
|
||||||
}
|
}
|
||||||
DrawStringCentered(140, 38, str, 0);
|
DrawStringCentered(140, 38, str, 0);
|
||||||
|
|
||||||
sprintf(_userstring, "%.4X", lid->tile);
|
snprintf(_userstring, USERSTRING_LEN, "%.4X", lid->tile);
|
||||||
SET_DPARAM16(0, GET_TILE_X(lid->tile));
|
SET_DPARAM16(0, GET_TILE_X(lid->tile));
|
||||||
SET_DPARAM16(1, GET_TILE_Y(lid->tile));
|
SET_DPARAM16(1, GET_TILE_Y(lid->tile));
|
||||||
SET_DPARAM16(2, STR_SPEC_USERSTRING);
|
SET_DPARAM16(2, STR_SPEC_USERSTRING);
|
||||||
|
|
|
@ -375,6 +375,8 @@ static void DrawStationViewWindow(Window *w)
|
||||||
b += 3;
|
b += 3;
|
||||||
|
|
||||||
for(i=0; i!=NUM_CARGO; i++) {
|
for(i=0; i!=NUM_CARGO; i++) {
|
||||||
|
if (b + 5 > USERSTRING_LEN - 1)
|
||||||
|
break;
|
||||||
if (st->goods[i].waiting_acceptance & 0x8000) {
|
if (st->goods[i].waiting_acceptance & 0x8000) {
|
||||||
b[0] = 0x81;
|
b[0] = 0x81;
|
||||||
WRITE_LE_UINT16(b+1, _cargoc.names_s[i]);
|
WRITE_LE_UINT16(b+1, _cargoc.names_s[i]);
|
||||||
|
|
|
@ -431,7 +431,8 @@ extern const TileIndexDiff _tileoffs_by_dir[4];
|
||||||
/* misc */
|
/* misc */
|
||||||
VARDEF byte str_buffr[512];
|
VARDEF byte str_buffr[512];
|
||||||
VARDEF char _screenshot_name[128];
|
VARDEF char _screenshot_name[128];
|
||||||
VARDEF char _userstring[128];
|
#define USERSTRING_LEN 128
|
||||||
|
VARDEF char _userstring[USERSTRING_LEN];
|
||||||
VARDEF byte _vehicle_design_names;
|
VARDEF byte _vehicle_design_names;
|
||||||
|
|
||||||
VARDEF SignStruct _sign_list[40];
|
VARDEF SignStruct _sign_list[40];
|
||||||
|
|
Loading…
Reference in New Issue