Mercurial > hg > openttd
changeset 14433:4b436d838659 draft
(svn r18990) -Codechange: [NewGRF] Add rail type map bounds checking to RailType[Change|Reserve]Info().
author | peter1138 <peter1138@openttd.org> |
---|---|
date | Wed, 03 Feb 2010 08:02:07 +0000 |
parents | 6e1f30daf018 |
children | f5a4807b200c |
files | src/newgrf.cpp |
diffstat | 1 files changed, 10 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/src/newgrf.cpp +++ b/src/newgrf.cpp @@ -2494,6 +2494,11 @@ extern RailtypeInfo _railtypes[RAILTYPE_END]; + if (id + numinfo > RAILTYPE_END) { + grfmsg(1, "RailTypeChangeInfo: Rail type %u is invalid, max %u, ignoring", id + numinfo, RAILTYPE_END); + return CIR_INVALID_ID; + } + for (int i = 0; i < numinfo; i++) { RailType rt = _cur_grffile->railtype_map[id + i]; if (rt == INVALID_RAILTYPE) return CIR_INVALID_ID; @@ -2589,6 +2594,11 @@ { ChangeInfoResult ret = CIR_SUCCESS; + if (id + numinfo > RAILTYPE_END) { + grfmsg(1, "RailTypeReserveInfo: Rail type %u is invalid, max %u, ignoring", id + numinfo, RAILTYPE_END); + return CIR_INVALID_ID; + } + for (int i = 0; i < numinfo; i++) { switch (prop) { case 0x08: // Label of rail type