summaryrefslogtreecommitdiff
blob: 97be35498e68e3c8764126db2ede51edaab91ad3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
diff -ru icebreaker-1.9.5.orig/dialog.c icebreaker-1.9.5/dialog.c
--- icebreaker-1.9.5.orig/dialog.c	2002-05-26 16:13:00.000000000 -0400
+++ icebreaker-1.9.5/dialog.c	2010-10-11 13:23:24.829480644 -0400
@@ -384,12 +384,12 @@
 
 	if (strlen(commandline.theme)>0)
 	{
-		snprintf(originaltheme,MAXTHEMENAMELENGTH+1,"%s",commandline.theme);
+		snprintf(originaltheme,sizeof(originaltheme),"%s",commandline.theme);
 		originalthemecl=true;
 	}
 	else
 	{
-		snprintf(originaltheme,MAXTHEMENAMELENGTH+1,"%s",options.theme);
+		snprintf(originaltheme,sizeof(originaltheme),"%s",options.theme);
 		originalthemecl=false;	
 	}
 				
@@ -662,7 +662,7 @@
 		{ // "random", at the end of the list
 			
 			strncpy(val,"random",MAXMENUVALUELENGTH);
-			snprintf(options.theme,MAXMENUVALUELENGTH,"random");
+			strcpy(options.theme,"random");
 			
 			settheme("linux"); // just for pretty
 			
@@ -676,7 +676,7 @@
 		else
 		{
 			strncpy(val,themelist[(t+1)%themecount],MAXMENUVALUELENGTH);
-			snprintf(options.theme,MAXMENUVALUELENGTH,themelist[(t+1)%themecount]);
+			snprintf(options.theme,sizeof(options.theme),"%s",themelist[(t+1)%themecount]);
 			
 			settheme(options.theme);
 			
@@ -729,10 +729,10 @@
 
 	for (i=0;i<HISCORENUM;i++)
 	{
-		snprintf(buf,4,"%d.",i+1);
+		snprintf(buf,sizeof(buf),"%d.",i+1);
 		puttext(scorelistrect.x+BLOCKWIDTH,scorelistrect.y+45+i*(CHARHEIGHT*2+5),2,color.normaltext,buf);		
 		puttext(scorelistrect.x+BLOCKWIDTH*4,scorelistrect.y+45+i*(CHARHEIGHT*2+5),2,color.normaltext,hiscorename[i]);		
-		snprintf(buf,30,"%ld",hiscoreval[i]);		
+		snprintf(buf,sizeof(buf),"%ld",hiscoreval[i]);		
 		puttext(scorelistrect.x+scorelistrect.w-(BLOCKWIDTH*5),scorelistrect.y+45+i*(CHARHEIGHT*2+5),2,color.normaltext,buf);
 	}
 	
@@ -814,7 +814,7 @@
 	{
 		puttext(helprect.x+BLOCKWIDTH/2,helprect.y+BLOCKHEIGHT/2+i*(CHARHEIGHT*2+4),2,color.normaltext,helptext[i]);		
 	}
-	snprintf(buf,80,"v%d.%d.%d   %s",VERMAJOR,VERMINOR,VERSUB,"Copyright (c) 2000-2002 Matthew Miller. Released under the GPL.");
+	snprintf(buf,sizeof(buf),"v%d.%d.%d   %s",VERMAJOR,VERMINOR,VERSUB,"Copyright (c) 2000-2002 Matthew Miller. Released under the GPL.");
 	puttext(helprect.x+BLOCKWIDTH/2,helprect.y+helprect.h-CHARHEIGHT*3,1,color.copyrighttext,buf);		
 	puttext(helprect.x+BLOCKWIDTH/2,helprect.y+helprect.h-CHARHEIGHT*1-3,1,color.copyrighttext,"Thanks to my wonderful wife Karen for inspiration (and for patience)!");		
 	
diff -ru icebreaker-1.9.5.orig/hiscore.c icebreaker-1.9.5/hiscore.c
--- icebreaker-1.9.5.orig/hiscore.c	2002-05-26 16:13:00.000000000 -0400
+++ icebreaker-1.9.5/hiscore.c	2010-10-11 13:27:19.007140342 -0400
@@ -72,7 +72,7 @@
 	// make sure all entries are zeroed out to start.
 	for (i=0;i<HISCORENUM;i++)
 	{
-		snprintf(temphiscorename[i],7,"Nobody");
+		strcpy(temphiscorename[i],"Nobody");
 		temphiscoreval[i]=100; //100 is better than 0. :)
 	}
 
@@ -103,7 +103,7 @@
 	// ok, so now, we can copy things over in the proper sorted order
 	for (i=0;i<HISCORENUM;i++)
 	{
-		snprintf(hiscorename[i],50,temphiscorename[arrayindex[i]]);
+		snprintf(hiscorename[i],50,"%s",temphiscorename[arrayindex[i]]);
 		hiscoreval[i]=temphiscoreval[arrayindex[i]];
 	}
 
@@ -201,13 +201,13 @@
 	// make sure the temp array contains the right data
 	for (i=0;i<HISCORENUM;i++)
 	{
-		snprintf(temphiscorename[i],50,hiname[i]);
+		snprintf(temphiscorename[i],50,"%s",hiname[i]);
 		temphiscoreval[i]=hival[i];
 	}
 	
 	// and toss in the new data 
 	//(this is why these arrays are size HISCORENUM+1)
-	snprintf(temphiscorename[HISCORENUM],50,username);
+	snprintf(temphiscorename[HISCORENUM],50,"%s",username);
 	temphiscoreval[HISCORENUM]=score;
 
 	// fill the "helper" array. 
@@ -221,7 +221,7 @@
 	// and take the top ones back.
 	for (i=0;i<HISCORENUM;i++)
 	{
-		snprintf(hiname[i],50,temphiscorename[arrayindex[i]]); 
+		snprintf(hiname[i],50,"%s",temphiscorename[arrayindex[i]]); 
 		hival[i]=temphiscoreval[arrayindex[i]];
 	}
 }
diff -ru icebreaker-1.9.5.orig/line.c icebreaker-1.9.5/line.c
--- icebreaker-1.9.5.orig/line.c	2002-05-25 14:15:22.000000000 -0400
+++ icebreaker-1.9.5/line.c	2010-10-11 13:25:03.833197122 -0400
@@ -30,8 +30,9 @@
 
 Line createline(int linenum)
 {
-	Line l;
+	static Line l;
 
+	memset(&l, 0, sizeof(l));
 	switch (linenum)
 	{
 		case 1: 
diff -ru icebreaker-1.9.5.orig/options.c icebreaker-1.9.5/options.c
--- icebreaker-1.9.5.orig/options.c	2002-05-23 00:52:35.000000000 -0400
+++ icebreaker-1.9.5/options.c	2010-10-11 13:21:51.247600060 -0400
@@ -66,7 +66,7 @@
 	options.autopause=AUTOPAUSEOFF;	
 	options.difficulty=NORMAL;
 	options.fullscreen=FULLSCREENOFF;
-	snprintf(options.theme,MAXTHEMENAMELENGTH+1,"linux");
+	strcpy(options.theme,"linux");
 }
 
 int readoptions(void)
@@ -81,7 +81,7 @@
 
 	setdefaultoptions();
 	
-	snprintf(filename,255,"%s/%s",homedir,OPTIONFILE);
+	snprintf(filename,sizeof(filename),"%s/%s",homedir,OPTIONFILE);
 	
 	optionfile=fopen(filename,"r");
 	if (optionfile==NULL)
@@ -135,7 +135,7 @@
 			}
 			else if (!strcmp(optbuf,"theme"))
 			{
-				snprintf(options.theme,MAXTHEMENAMELENGTH+1,"%s",valbuf);
+				snprintf(options.theme,sizeof(options.theme),"%s",valbuf);
 			}
 			// FIX: add username
 		}
@@ -150,7 +150,7 @@
 {
 	FILE * optionfile;
 	char filename[255];
-	snprintf(filename,255,"%s/%s",homedir,OPTIONFILE);
+	snprintf(filename,sizeof(filename),"%s/%s",homedir,OPTIONFILE);
 	
 	optionfile=fopen(filename,"w");
 	if (optionfile==NULL)
@@ -292,7 +292,7 @@
 			else
 			{
 				// fix -- we should probably search for malicious characters here.
-				snprintf(commandline.theme,MAXTHEMENAMELENGTH+1,"%s",argv[i]+strlen(FLAGTHEME));
+				snprintf(commandline.theme,sizeof(commandline.theme),"%s",argv[i]+strlen(FLAGTHEME));
 			}	
 		}
 		else if (strncmp(argv[i],FLAGTHEMELONG "=" ,strlen(FLAGTHEMELONG "=")) == 0)
@@ -312,7 +312,7 @@
 			else
 			{
 				// fix -- we should probably search for malicious characters here.
-				snprintf(commandline.theme,MAXTHEMENAMELENGTH+1,"%s",argv[i]+strlen(FLAGTHEMELONG "="));
+				snprintf(commandline.theme,sizeof(commandline.theme),"%s",argv[i]+strlen(FLAGTHEMELONG "="));
 			}	
 		}
 		else if (strncmp(argv[i],FLAGTHEMELONG,strlen(FLAGTHEMELONG)) == 0)
diff -ru icebreaker-1.9.5.orig/penguin.c icebreaker-1.9.5/penguin.c
--- icebreaker-1.9.5.orig/penguin.c	2002-05-26 16:13:00.000000000 -0400
+++ icebreaker-1.9.5/penguin.c	2010-10-11 13:26:03.789308697 -0400
@@ -40,8 +40,9 @@
 
 Penguin createpenguinxy(int x, int y)
 {
-	Penguin p;
+	static Penguin p;
 
+	memset(&p, 0, sizeof(p));
 	switch (random() % 4)
 	{
 		case 0:
diff -ru icebreaker-1.9.5.orig/themes.c icebreaker-1.9.5/themes.c
--- icebreaker-1.9.5.orig/themes.c	2002-05-26 16:13:00.000000000 -0400
+++ icebreaker-1.9.5/themes.c	2010-10-11 13:17:41.360331223 -0400
@@ -183,7 +183,7 @@
 
 	foundcolor.spritetransparent = 0;
 	
-	snprintf(themefilename, 256,"%s/%s%s",DATAPREFIX,themename,THEMEFILEEXTENSION);
+	snprintf(themefilename, sizeof(themefilename),"%s/%s%s",DATAPREFIX,themename,THEMEFILEEXTENSION);
 	
 	themefile=fopen(themefilename,"r");
 	if (themefile==NULL)
@@ -329,7 +329,7 @@
 						               "We'll try to load it anyway, but don't be surpised if there's a problem.\n"
 						               "(Filename is %s)\n",themename,valbuf);
 					}
-					snprintf(loadfilebuf, 256,"%s/%s",DATAPREFIX,valbuf);
+					snprintf(loadfilebuf, sizeof(loadfilebuf),"%s/%s",DATAPREFIX,valbuf);
 					spriteimage=loadsprite(themename,loadfilebuf);
 				}
 				else if (!strcmp(optbuf,"spritemirrorbitmap"))
@@ -340,7 +340,7 @@
 						               "We'll try to load it anyway, but don't be surpised if there's a problem.\n"
 						               "(Filename is %s)\n",themename,valbuf);
 					}
-					snprintf(loadfilebuf, 256,"%s/%s",DATAPREFIX,valbuf);
+					snprintf(loadfilebuf, sizeof(loadfilebuf),"%s/%s",DATAPREFIX,valbuf);
 					spritemirrorimage=loadsprite(themename,loadfilebuf);
 				}
 				else if (!strcmp(optbuf,"soundouch"))
@@ -351,7 +351,7 @@
 						               "We'll try to load it anyway, but don't be surpised if there's a problem.\n"
 						               "(Filename is %s)\n",themename,valbuf);
 					}
-					snprintf(loadfilebuf, 256,"%s/%s",DATAPREFIX,valbuf);
+					snprintf(loadfilebuf, sizeof(loadfilebuf),"%s/%s",DATAPREFIX,valbuf);
 					loadsounds(themename,loadfilebuf,NULL);
 				}
 				else if (!strcmp(optbuf,"soundcrash"))
@@ -362,7 +362,7 @@
 						               "We'll try to load it anyway, but don't be surpised if there's a problem.\n"
 						               "(Filename is %s)\n",themename,valbuf);
 					}
-					snprintf(loadfilebuf, 256,"%s/%s",DATAPREFIX,valbuf);
+					snprintf(loadfilebuf, sizeof(loadfilebuf),"%s/%s",DATAPREFIX,valbuf);
 					loadsounds(themename,NULL,loadfilebuf);
 				}
 			}
@@ -474,11 +474,11 @@
 	{
 		fprintf(stderr,"Hey! You can't have a theme named random! Please remove the random.ibt\n"
 		        "file from your themes directory.\n");
-		snprintf(themename,MAXTHEMENAMELENGTH+1,"linux");
+		strcpy(themename,"linux");
 	}
 	else
 	{
-		snprintf(themename,MAXTHEMENAMELENGTH+1,themelist[random() %themecount]);
+		snprintf(themename,sizeof(themename),"%s",themelist[random() %themecount]);
 	}
 	freethemenames(&themelist,themecount);
 	return settheme(themename);