Out of bounds array access #141
Comments
Per commented I think I looked at this some time, and decided it should be fixed one day, but was not critical. I suggest it is only fixed in trunk, and that the usual savegame versioning is used to keep backwards savegame compatibility, even though I know this is really painful. |
Giel commented Replying to Warzone2100/old-trac-import#141 (comment:1):
Considering that asParts[COMP_WEAPON] is only ever written to and never read, should we perhaps just comment the line where it's written to out in [milestone:2.1]? While still looking for a better fix for trunk. |
Giel changed milestone from |
Giel commented Replying to Warzone2100/old-trac-import#141 (comment:2):
Ahum, cough, considering that this bug got introduced in [5014] and the [milestone:2.1] branch got created in [3812] this particular issue doesn't exist in [milestone:2.1]. |
DevUrandom changed status from |
DevUrandom changed resolution from `` to |
DevUrandom commented (In [6523]) Another attempt against #141 (out of bounds access at scriptfuncs:11467) Since the original assignment probably happened out of confusion what asParts[] shall or shall not contain, fixes #141 |
DevUrandom changed status from |
DevUrandom changed resolution from |
DevUrandom changed status from |
DevUrandom changed owner from `` to |
DevUrandom changed status from |
DevUrandom changed resolution from `` to |
Buginator removed milestone (was |
Buginator commented Milestone 2.2 deleted |
resolution_fixed
type_bug
| by GielFrom [5014] and onward we access the array [doxygen:_droid_template DROID_TEMPLATE]->asParts out of its bounds.
This is because that's the first revision to actually access asParts[COMP_WEAPON]. This while asParts is defined as being DROID_MAXCOMP elements large.
And DROID_MAXCOMP has been defined to (COMP_NUMCOMPONENTS - 1). This is fine if you want to determine the highest component number, which it's name suggests that it does, but it's not fine if want to know the number of components.
So there are two issues involved that need to be fixed:
Thus using DROID_MAXCOMP to decide on the size of the asParts array is wrong. Unfortunately, however, this specific wrong usage of DROID_MAXCOMP is used in the save games as well, additionally it is used in map.c too.
Issue migrated from trac:141 at 2022-04-15 17:47:18 -0700
The text was updated successfully, but these errors were encountered: