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 | |||
@@ -112,9 +112,9 @@ bool RCheckers::checkCapture1() | |||
112 | if(board[i-5]==MAN2 || board[i-5]==KING2) | 112 | if(board[i-5]==MAN2 || board[i-5]==KING2) |
113 | if(board[i-10]==FREE) return true; | 113 | if(board[i-10]==FREE) return true; |
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; |
119 | case KING1: | 119 | case KING1: |
120 | int k; | 120 | int k; |
@@ -126,13 +126,19 @@ bool RCheckers::checkCapture1() | |||
126 | if(board[k]==MAN2 || board[k]==KING2) | 126 | if(board[k]==MAN2 || board[k]==KING2) |
127 | if(board[k-5]==FREE) return true; | 127 | if(board[k-5]==FREE) return true; |
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 | } |
137 | } | 143 | } |
138 | return false; | 144 | return false; |
@@ -286,9 +292,9 @@ bool RCheckers::checkCapture2() | |||
286 | if(board[i-5]==MAN1 || board[i-5]==KING1) | 292 | if(board[i-5]==MAN1 || board[i-5]==KING1) |
287 | if(board[i-10]==FREE) return true; | 293 | if(board[i-10]==FREE) return true; |
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; |
293 | case KING2: | 299 | case KING2: |
294 | int k; | 300 | int k; |
@@ -300,13 +306,19 @@ bool RCheckers::checkCapture2() | |||
300 | if(board[k]==MAN1 || board[k]==KING1) | 306 | if(board[k]==MAN1 || board[k]==KING1) |
301 | if(board[k-5]==FREE) return true; | 307 | if(board[k-5]==FREE) return true; |
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 | } |
311 | } | 323 | } |
312 | return false; | 324 | return false; |