author | erik <erik> | 2007-01-24 23:29:42 (UTC) |
---|---|---|
committer | erik <erik> | 2007-01-24 23:29:42 (UTC) |
commit | 0076a11b467dce1233194ce228287a2a127b1f5d (patch) (unidiff) | |
tree | f2136a1a3e9b5fd6bede52251ed7249365838752 /noncore/games/kcheckers/rcheckers.cpp | |
parent | 48d9219a96096cf44df8ac24413b36d1b718b1d5 (diff) | |
download | opie-0076a11b467dce1233194ce228287a2a127b1f5d.zip opie-0076a11b467dce1233194ce228287a2a127b1f5d.tar.gz opie-0076a11b467dce1233194ce228287a2a127b1f5d.tar.bz2 |
Each file in this commit has the issue where it is possible for code to
overrun static buffers. This could lead to serious problems. Granted it
is almost impossible to do that. But it isn't totally impossible. So this
commit makes it impossible to overrun.
Diffstat (limited to 'noncore/games/kcheckers/rcheckers.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/games/kcheckers/rcheckers.cpp | 36 |
1 files changed, 24 insertions, 12 deletions
diff --git a/noncore/games/kcheckers/rcheckers.cpp b/noncore/games/kcheckers/rcheckers.cpp index a1c7afa..d808780 100644 --- a/noncore/games/kcheckers/rcheckers.cpp +++ b/noncore/games/kcheckers/rcheckers.cpp | |||
@@ -114,5 +114,5 @@ bool RCheckers::checkCapture1() | |||
114 | if(board[i+5]==MAN2 || board[i+5]==KING2) | 114 | if(board[i+5]==MAN2 || board[i+5]==KING2) |
115 | if(board[i+10]==FREE) return true; | 115 | if(board[((i+10) < 54) ? i+10 : 53]==FREE) return true; |
116 | if(board[i+6]==MAN2 || board[i+6]==KING2) | 116 | if(board[i+6]==MAN2 || board[i+6]==KING2) |
117 | if(board[i+12]==FREE) return true; | 117 | if(board[((i+12) < 54) ? i+12 : 53]==FREE) return true; |
118 | break; | 118 | break; |
@@ -128,9 +128,15 @@ bool RCheckers::checkCapture1() | |||
128 | 128 | ||
129 | for(k=i+5;board[k]==FREE;k+=5); | 129 | for(k=i+5;board[k]==FREE;k+=5) { |
130 | if (k >= 49) | ||
131 | break; | ||
132 | } | ||
130 | if(board[k]==MAN2 || board[k]==KING2) | 133 | if(board[k]==MAN2 || board[k]==KING2) |
131 | if(board[k+5]==FREE) return true; | 134 | if(board[((k+5) < 54) ? k+5 : 53]==FREE) return true; |
132 | 135 | ||
133 | for(k=i+6;board[k]==FREE;k+=6); | 136 | for(k=i+6;board[k]==FREE;k+=6) { |
137 | if (k >=48) | ||
138 | break; | ||
139 | } | ||
134 | if(board[k]==MAN2 || board[k]==KING2) | 140 | if(board[k]==MAN2 || board[k]==KING2) |
135 | if(board[k+6]==FREE) return true; | 141 | if(board[((k+6) < 54) ? k+6 : 53]==FREE) return true; |
136 | } | 142 | } |
@@ -288,5 +294,5 @@ bool RCheckers::checkCapture2() | |||
288 | if(board[i+5]==MAN1 || board[i+5]==KING1) | 294 | if(board[i+5]==MAN1 || board[i+5]==KING1) |
289 | if(board[i+10]==FREE) return true; | 295 | if(board[((i+10) < 54) ? i+10 : 53]==FREE) return true; |
290 | if(board[i+6]==MAN1 || board[i+6]==KING1) | 296 | if(board[i+6]==MAN1 || board[i+6]==KING1) |
291 | if(board[i+12]==FREE) return true; | 297 | if(board[((i+12) < 54) ? i+12 : 53]==FREE) return true; |
292 | break; | 298 | break; |
@@ -302,9 +308,15 @@ bool RCheckers::checkCapture2() | |||
302 | 308 | ||
303 | for(k=i+5;board[k]==FREE;k+=5); | 309 | for(k=i+5;board[k]==FREE;k+=5) { |
310 | if (k>=49) | ||
311 | break; | ||
312 | } | ||
304 | if(board[k]==MAN1 || board[k]==KING1) | 313 | if(board[k]==MAN1 || board[k]==KING1) |
305 | if(board[k+5]==FREE) return true; | 314 | if(board[((k+5) < 54) ? k+5 : 53]==FREE) return true; |
306 | 315 | ||
307 | for(k=i+6;board[k]==FREE;k+=6); | 316 | for(k=i+6;board[k]==FREE;k+=6) { |
317 | if (k>=48) | ||
318 | break; | ||
319 | } | ||
308 | if(board[k]==MAN1 || board[k]==KING1) | 320 | if(board[k]==MAN1 || board[k]==KING1) |
309 | if(board[k+6]==FREE) return true; | 321 | if(board[((k+6) < 54) ? k+6 : 53]==FREE) return true; |
310 | } | 322 | } |