From 1fa7c5635184e3a8c16b696a658c027fcc0862d8 Mon Sep 17 00:00:00 2001 From: William Wilgus Date: Tue, 31 Jan 2017 04:28:02 +0100 Subject: Fix for Chessbox bug FS#10363 Chessbox was overflowing GameList[240] causing the board to flip + crash GameCnt changed to unsigned char which allows the array to roll over to 0 after 255 define MAX_GAME_CNT 256 and GameList[MAX_GAME_CNT] along with 1 byte GameCnt should fix this issue dbg save routine left in for now to help identify any other problems Added bounds checking to prevent second bug found when loading .pgn files Change-Id: I2b615c8ecbed4368724412f80ce07346f3cf30a7 --- apps/plugins/chessbox/gnuchess.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'apps/plugins/chessbox/gnuchess.h') diff --git a/apps/plugins/chessbox/gnuchess.h b/apps/plugins/chessbox/gnuchess.h index b7a3a309f8..f52e1b1a0a 100644 --- a/apps/plugins/chessbox/gnuchess.h +++ b/apps/plugins/chessbox/gnuchess.h @@ -1,7 +1,7 @@ #ifndef _GNUCHESS_H_ #define _GNUCHESS_H_ - +#define MAX_GAME_CNT 256 #define neutral 2 #define white 0 #define black 1 @@ -39,9 +39,10 @@ extern bool withbook; extern long Level; extern short TCflag,TCmoves,TCminutes; extern short timeout; -extern short GameCnt,Game50,castld[2],kingmoved[2],OperatorTime; +extern unsigned char GameCnt; /* Bug fix rolls over at 255 instead of overflow */ +extern short Game50,castld[2],kingmoved[2],OperatorTime; extern struct TimeControlRec TimeControl; -extern struct GameRec GameList[240]; +extern struct GameRec GameList[MAX_GAME_CNT]; /* ---- The beginning of a GNUChess v2 APIfication ---- */ void SetTimeControl(void); -- cgit v1.2.3