From: NHOrus Date: Sun, 13 Aug 2017 14:16:09 +0000 (+0100) Subject: Verify sanity of location arrays X-Git-Tag: 1.5~33 X-Git-Url: https://jxself.org/git/?a=commitdiff_plain;h=f0dc3d3b7c8c169ae0581b7e9c5e209dd28c682a;p=open-adventure.git Verify sanity of location arrays --- diff --git a/saveresume.c b/saveresume.c index 8897945..ecfc643 100644 --- a/saveresume.c +++ b/saveresume.c @@ -144,7 +144,21 @@ bool is_valid(struct game_t valgame) valgame.oldloc < -1 || valgame.oldloc > NLOCATIONS) { return false; } + /* Bounds check for location arrays + */ + for (int i = 0; i <= NDWARVES; i++) { + if (valgame.dloc[i] < -1 || valgame.dloc[i] > NLOCATIONS || + valgame.odloc[i] < -1 || valgame.odloc[i] > NLOCATIONS) { + return false; + } + } + for (int i = 0; i <= NOBJECTS; i++) { + if (valgame.place[i] < -1 || valgame.place[i] > NLOCATIONS || + valgame.fixed[i] < -1 || valgame.fixed[i] > NLOCATIONS) { + return false; + } + } return true; }