summaryrefslogtreecommitdiff
path: root/noncore
authorerik <erik>2007-01-24 23:29:42 (UTC)
committer erik <erik>2007-01-24 23:29:42 (UTC)
commit0076a11b467dce1233194ce228287a2a127b1f5d (patch) (unidiff)
treef2136a1a3e9b5fd6bede52251ed7249365838752 /noncore
parent48d9219a96096cf44df8ac24413b36d1b718b1d5 (diff)
downloadopie-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') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/games/backgammon/moveengine.cpp6
-rw-r--r--noncore/games/kbill/UI.cpp31
-rw-r--r--noncore/games/kcheckers/echeckers.cpp12
-rw-r--r--noncore/games/kcheckers/rcheckers.cpp36
-rw-r--r--noncore/settings/sysinfo/contrib/fft.c2
-rw-r--r--noncore/styles/theme/othemebase.cpp2
6 files changed, 51 insertions, 38 deletions
diff --git a/noncore/games/backgammon/moveengine.cpp b/noncore/games/backgammon/moveengine.cpp
index a4145cc..b102258 100644
--- a/noncore/games/backgammon/moveengine.cpp
+++ b/noncore/games/backgammon/moveengine.cpp
@@ -53,7 +53,8 @@ void MoveEngine::position(Pieces& pieces,bool non_qte)
53 { 53 {
54 if(population[a].total>0) //player 1 pieces 54 if(population[a].total>0) //player 1 pieces
55 { 55 {
56 pieces.player1[player1_counter].x=x_coord[a]-offset; 56 if (a < 26)
57 pieces.player1[player1_counter].x=x_coord[a]-offset;
57 if(a>=0 && a<13) 58 if(a>=0 && a<13)
58 { 59 {
59 pieces.player1[player1_counter].y=yup_coord[b]-offset; 60 pieces.player1[player1_counter].y=yup_coord[b]-offset;
@@ -96,7 +97,8 @@ void MoveEngine::position(Pieces& pieces,bool non_qte)
96 97
97 else if(population[a].total<0) //player 2 pieces 98 else if(population[a].total<0) //player 2 pieces
98 { 99 {
99 pieces.player2[player2_counter].x=x_coord[a]-offset; 100 if (a < 26)
101 pieces.player2[player2_counter].x=x_coord[a]-offset;
100 if(a>=0 && a<13) 102 if(a>=0 && a<13)
101 { 103 {
102 pieces.player2[player2_counter].y=yup_coord[b]-offset; 104 pieces.player2[player2_counter].y=yup_coord[b]-offset;
diff --git a/noncore/games/kbill/UI.cpp b/noncore/games/kbill/UI.cpp
index 611cebf..a49c3c1 100644
--- a/noncore/games/kbill/UI.cpp
+++ b/noncore/games/kbill/UI.cpp
@@ -68,28 +68,27 @@ void UI::popup_dialog (int dialog) {
68 kill_timer(); 68 kill_timer();
69 switch (dialog) { 69 switch (dialog) {
70 case Game::ENDGAME: 70 case Game::ENDGAME:
71 QMessageBox::message(("Endgame"), QT_TR_NOOP(endgamestr)); 71 QMessageBox::message(("Endgame"), QT_TR_NOOP(endgamestr));
72 break; 72 break;
73 case Game::HIGHSCORE: 73 case Game::HIGHSCORE:
74 //QMessageBox::message(("HighScore"), highscorestr); 74 break;
75 break; 75 case Game::ENTERNAME:
76 case Game::ENTERNAME: { 76 {
77 InputBox b(main, 0, ("Enter Name"), QT_TR_NOOP(enternamestr)); 77 InputBox b(main, 0, ("Enter Name"), QT_TR_NOOP(enternamestr));
78 bool state = b.exec() == 2; 78 bool state = b.exec() == 2;
79 char str[20], *nl; 79 char str[20], *nl;
80 strcpy(str, b.getText()); 80 strncpy(str, b.getText(), 19);
81 if (!str[0] || state) 81 if (!str[0] || state)
82 strcpy(str, "Anonymous"); 82 strcpy(str, "Anonymous");
83 else if ((nl = strchr(str, '\n'))) 83 else if ((nl = strchr(str, '\n')))
84 *nl = '\0'; 84 *nl = '\0';
85 if (strlen(str) > 20) 85 if (strlen(str) > 19)
86 str[20] = 0; /* truncate string if too long */ 86 str[19] = '\0'; /* truncate/terminate the string if it is too long */
87 // scores.recalc(str); 87 }
88 } 88 break;
89 break;
90 case Game::SCORE: 89 case Game::SCORE:
91 QMessageBox::message(("Score"), scorestr); 90 QMessageBox::message(("Score"), scorestr);
92 break; 91 break;
93 } 92 }
94 restart_timer(); 93 restart_timer();
95} 94}
diff --git a/noncore/games/kcheckers/echeckers.cpp b/noncore/games/kcheckers/echeckers.cpp
index 1146059..afe62eb 100644
--- a/noncore/games/kcheckers/echeckers.cpp
+++ b/noncore/games/kcheckers/echeckers.cpp
@@ -79,9 +79,9 @@ bool ECheckers::checkCapture1()
79 if(board[i-5]==MAN2 || board[i-5]==KING2) 79 if(board[i-5]==MAN2 || board[i-5]==KING2)
80 if(board[i-10]==FREE) return true; 80 if(board[i-10]==FREE) return true;
81 if(board[i+5]==MAN2 || board[i+5]==KING2) 81 if(board[i+5]==MAN2 || board[i+5]==KING2)
82 if(board[i+10]==FREE) return true; 82 if(board[((i+10) < 54) ? i+10 : 53]==FREE) return true;
83 if(board[i+6]==MAN2 || board[i+6]==KING2) 83 if(board[i+6]==MAN2 || board[i+6]==KING2)
84 if(board[i+12]==FREE) return true; 84 if(board[((i+12) < 54) ? i+12 : 53]==FREE) return true;
85 } 85 }
86 } 86 }
87 return false; 87 return false;
@@ -221,9 +221,9 @@ bool ECheckers::checkCapture2()
221 { 221 {
222 case MAN2: 222 case MAN2:
223 if(board[i+5]==MAN1 || board[i+5]==KING1) 223 if(board[i+5]==MAN1 || board[i+5]==KING1)
224 if(board[i+10]==FREE) return true; 224 if(board[((i+10) < 54) ? i+10 : 53]==FREE) return true;
225 if(board[i+6]==MAN1 || board[i+6]==KING1) 225 if(board[i+6]==MAN1 || board[i+6]==KING1)
226 if(board[i+12]==FREE) return true; 226 if(board[((i+12) < 54) ? i+12 : 53]==FREE) return true;
227 break; 227 break;
228 case KING2: 228 case KING2:
229 if(board[i-6]==MAN1 || board[i-6]==KING1) 229 if(board[i-6]==MAN1 || board[i-6]==KING1)
@@ -231,9 +231,9 @@ bool ECheckers::checkCapture2()
231 if(board[i-5]==MAN1 || board[i-5]==KING1) 231 if(board[i-5]==MAN1 || board[i-5]==KING1)
232 if(board[i-10]==FREE) return true; 232 if(board[i-10]==FREE) return true;
233 if(board[i+5]==MAN1 || board[i+5]==KING1) 233 if(board[i+5]==MAN1 || board[i+5]==KING1)
234 if(board[i+10]==FREE) return true; 234 if(board[((i+10) < 54) ? i+10 : 53]==FREE) return true;
235 if(board[i+6]==MAN1 || board[i+6]==KING1) 235 if(board[i+6]==MAN1 || board[i+6]==KING1)
236 if(board[i+12]==FREE) return true; 236 if(board[((i+12) < 54) ? i+12 : 53]==FREE) return true;
237 } 237 }
238 } 238 }
239 return false; 239 return false;
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;
diff --git a/noncore/settings/sysinfo/contrib/fft.c b/noncore/settings/sysinfo/contrib/fft.c
index 01a1b26..60ee27d 100644
--- a/noncore/settings/sysinfo/contrib/fft.c
+++ b/noncore/settings/sysinfo/contrib/fft.c
@@ -29,7 +29,7 @@
29 29
30#include <math.h> 30#include <math.h>
31 31
32#define FFT_TEST_COUNT 500 // Bench FFT 32#define FFT_TEST_COUNT 332 // Bench FFT
33 33
34// ----------------------------------------------------- FFT 34// ----------------------------------------------------- FFT
35#define OBJ_DATA_COUNT 128 35#define OBJ_DATA_COUNT 128
diff --git a/noncore/styles/theme/othemebase.cpp b/noncore/styles/theme/othemebase.cpp
index 4275dd6..7fb12a3 100644
--- a/noncore/styles/theme/othemebase.cpp
+++ b/noncore/styles/theme/othemebase.cpp
@@ -1004,7 +1004,7 @@ void OThemeBase::readResourceGroup( int i, QString *copyfrom, QString *pixnames,
1004 break; 1004 break;
1005 } 1005 }
1006 } 1006 }
1007 if ( loadArray[ sIndex ] ) { 1007 if ( sIndex < 54 && loadArray[ sIndex ] ) {
1008 copyWidgetConfig( sIndex, i, pixnames, brdnames ); 1008 copyWidgetConfig( sIndex, i, pixnames, brdnames );
1009 } 1009 }
1010 else 1010 else