mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-08-29 01:19:11 +00:00
Fix: Check ID for name is within bounds.
This commit is contained in:
@@ -6108,7 +6108,7 @@ static void FeatureNewName(ByteReader *buf)
|
||||
|
||||
switch (GB(id, 8, 8)) {
|
||||
case 0xC4: // Station class name
|
||||
if (_cur.grffile->stations == nullptr || _cur.grffile->stations[GB(id, 0, 8)] == nullptr) {
|
||||
if (GB(id, 0, 8) >= NUM_STATIONS_PER_GRF || _cur.grffile->stations == nullptr || _cur.grffile->stations[GB(id, 0, 8)] == nullptr) {
|
||||
grfmsg(1, "FeatureNewName: Attempt to name undefined station 0x%X, ignoring", GB(id, 0, 8));
|
||||
} else {
|
||||
StationClassID cls_id = _cur.grffile->stations[GB(id, 0, 8)]->cls_id;
|
||||
@@ -6117,7 +6117,7 @@ static void FeatureNewName(ByteReader *buf)
|
||||
break;
|
||||
|
||||
case 0xC5: // Station name
|
||||
if (_cur.grffile->stations == nullptr || _cur.grffile->stations[GB(id, 0, 8)] == nullptr) {
|
||||
if (GB(id, 0, 8) >= NUM_STATIONS_PER_GRF || _cur.grffile->stations == nullptr || _cur.grffile->stations[GB(id, 0, 8)] == nullptr) {
|
||||
grfmsg(1, "FeatureNewName: Attempt to name undefined station 0x%X, ignoring", GB(id, 0, 8));
|
||||
} else {
|
||||
_cur.grffile->stations[GB(id, 0, 8)]->name = AddGRFString(_cur.grffile->grfid, id, lang, new_scheme, false, name, STR_UNDEFINED);
|
||||
@@ -6125,7 +6125,7 @@ static void FeatureNewName(ByteReader *buf)
|
||||
break;
|
||||
|
||||
case 0xC7: // Airporttile name
|
||||
if (_cur.grffile->airtspec == nullptr || _cur.grffile->airtspec[GB(id, 0, 8)] == nullptr) {
|
||||
if (GB(id, 0, 8) >= NUM_AIRPORTTILES_PER_GRF || _cur.grffile->airtspec == nullptr || _cur.grffile->airtspec[GB(id, 0, 8)] == nullptr) {
|
||||
grfmsg(1, "FeatureNewName: Attempt to name undefined airport tile 0x%X, ignoring", GB(id, 0, 8));
|
||||
} else {
|
||||
_cur.grffile->airtspec[GB(id, 0, 8)]->name = AddGRFString(_cur.grffile->grfid, id, lang, new_scheme, false, name, STR_UNDEFINED);
|
||||
@@ -6133,7 +6133,7 @@ static void FeatureNewName(ByteReader *buf)
|
||||
break;
|
||||
|
||||
case 0xC9: // House name
|
||||
if (_cur.grffile->housespec == nullptr || _cur.grffile->housespec[GB(id, 0, 8)] == nullptr) {
|
||||
if (GB(id, 0, 8) >= NUM_HOUSES_PER_GRF || _cur.grffile->housespec == nullptr || _cur.grffile->housespec[GB(id, 0, 8)] == nullptr) {
|
||||
grfmsg(1, "FeatureNewName: Attempt to name undefined house 0x%X, ignoring.", GB(id, 0, 8));
|
||||
} else {
|
||||
_cur.grffile->housespec[GB(id, 0, 8)]->building_name = AddGRFString(_cur.grffile->grfid, id, lang, new_scheme, false, name, STR_UNDEFINED);
|
||||
|
Reference in New Issue
Block a user