summaryrefslogtreecommitdiff
path: root/apps/plugins/chessbox/gnuchess.h
diff options
context:
space:
mode:
authorWilliam Wilgus <me.theuser@yahoo.com>2017-01-31 04:28:02 +0100
committerWilliam Wilgus <me.theuser@yahoo.com>2017-02-01 01:33:48 +0100
commit1fa7c5635184e3a8c16b696a658c027fcc0862d8 (patch)
treedebeb03ca2da9a20ccfae5ece4fc512847046014 /apps/plugins/chessbox/gnuchess.h
parent37522ec63ae8fd2f88a66ed3d7020ebe95e9980e (diff)
downloadrockbox-1fa7c5635184e3a8c16b696a658c027fcc0862d8.tar.gz
rockbox-1fa7c5635184e3a8c16b696a658c027fcc0862d8.zip
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
Diffstat (limited to 'apps/plugins/chessbox/gnuchess.h')
-rw-r--r--apps/plugins/chessbox/gnuchess.h7
1 files changed, 4 insertions, 3 deletions
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 @@
1 1
2#ifndef _GNUCHESS_H_ 2#ifndef _GNUCHESS_H_
3#define _GNUCHESS_H_ 3#define _GNUCHESS_H_
4 4#define MAX_GAME_CNT 256
5#define neutral 2 5#define neutral 2
6#define white 0 6#define white 0
7#define black 1 7#define black 1
@@ -39,9 +39,10 @@ extern bool withbook;
39extern long Level; 39extern long Level;
40extern short TCflag,TCmoves,TCminutes; 40extern short TCflag,TCmoves,TCminutes;
41extern short timeout; 41extern short timeout;
42extern short GameCnt,Game50,castld[2],kingmoved[2],OperatorTime; 42extern unsigned char GameCnt; /* Bug fix rolls over at 255 instead of overflow */
43extern short Game50,castld[2],kingmoved[2],OperatorTime;
43extern struct TimeControlRec TimeControl; 44extern struct TimeControlRec TimeControl;
44extern struct GameRec GameList[240]; 45extern struct GameRec GameList[MAX_GAME_CNT];
45 46
46/* ---- The beginning of a GNUChess v2 APIfication ---- */ 47/* ---- The beginning of a GNUChess v2 APIfication ---- */
47void SetTimeControl(void); 48void SetTimeControl(void);