1 diff -ur Maelstrom-3.0.6-orig/controls.cpp Maelstrom-3.0.6/controls.cpp
2 --- Maelstrom-3.0.6-orig/controls.cpp 2001-03-25 03:04:28 +0900
3 +++ Maelstrom-3.0.6/controls.cpp 2003-05-21 11:25:53 +0900
8 - sprintf(datafile, "%s"DIR_SEP"%s", home, MAELSTROM_DATA);
9 + snprintf(datafile, sizeof(datafile), "%s"DIR_SEP"%s", home, MAELSTROM_DATA);
10 if ( (data=fopen(datafile, mode)) == NULL )
13 diff -ur Maelstrom-3.0.6-orig/dialog.h Maelstrom-3.0.6/dialog.h
14 --- Maelstrom-3.0.6-orig/dialog.h 2001-07-21 00:08:10 +0900
15 +++ Maelstrom-3.0.6/dialog.h 2003-05-21 11:24:33 +0900
20 - vsprintf(errbuf, fmt, ap);
21 + vsnprintf(errbuf, sizeof(errbuf), fmt, ap);
27 Fontserv->FreeText(entry->text);
29 - sprintf(buf, "%d", *entry->variable);
30 + snprintf(buf, sizeof(buf), "%d", *entry->variable);
32 if ( entry->hilite ) {
34 diff -ur Maelstrom-3.0.6-orig/load.cpp Maelstrom-3.0.6/load.cpp
35 --- Maelstrom-3.0.6-orig/load.cpp 2000-02-15 11:47:39 +0900
36 +++ Maelstrom-3.0.6/load.cpp 2003-05-21 11:26:18 +0900
38 SDL_Surface *bmp, *title;
40 /* Open the title file -- we know its colormap is our global one */
41 - sprintf(file, "Images"DIR_SEP"Maelstrom_Titles#%d.bmp", title_id);
42 + snprintf(file, sizeof(file), "Images"DIR_SEP"Maelstrom_Titles#%d.bmp", title_id);
43 bmp = SDL_LoadBMP(path.Path(file));
49 /* Open the cicn sprite file.. */
50 - sprintf(file, "Images"DIR_SEP"Maelstrom_Icon#%hd.cicn", cicn_id);
51 + snprintf(file, sizeof(file), "Images"DIR_SEP"Maelstrom_Icon#%hd.cicn", cicn_id);
52 if ( (cicn_src=SDL_RWFromFile(path.Path(file), "r")) == NULL ) {
53 error("GetCIcon(%hd): Can't open CICN %s: ",
54 cicn_id, path.Path(file));
55 diff -ur Maelstrom-3.0.6-orig/maclib/Mac_FontServ.h Maelstrom-3.0.6/maclib/Mac_FontServ.h
56 --- Maelstrom-3.0.6-orig/maclib/Mac_FontServ.h 1999-12-03 02:15:33 +0900
57 +++ Maelstrom-3.0.6/maclib/Mac_FontServ.h 2003-05-21 11:28:43 +0900
62 - vsprintf(errbuf, fmt, ap);
63 + vsnprintf(errbuf, sizeof(errbuf), fmt, ap);
67 diff -ur Maelstrom-3.0.6-orig/maclib/Mac_Resource.h Maelstrom-3.0.6/maclib/Mac_Resource.h
68 --- Maelstrom-3.0.6-orig/maclib/Mac_Resource.h 1999-12-04 03:01:47 +0900
69 +++ Maelstrom-3.0.6/maclib/Mac_Resource.h 2003-05-21 11:28:35 +0900
74 - vsprintf(errbuf, fmt, ap);
75 + vsnprintf(errbuf, sizeof(errbuf), fmt, ap);
79 diff -ur Maelstrom-3.0.6-orig/maclib/Mac_Sound.h Maelstrom-3.0.6/maclib/Mac_Sound.h
80 --- Maelstrom-3.0.6-orig/maclib/Mac_Sound.h 2002-10-20 11:53:34 +0900
81 +++ Maelstrom-3.0.6/maclib/Mac_Sound.h 2003-05-21 11:28:27 +0900
86 - vsprintf(errbuf, fmt, ap);
87 + vsnprintf(errbuf, sizeof(errbuf), fmt, ap);
91 diff -ur Maelstrom-3.0.6-orig/maclib/Mac_Wave.h Maelstrom-3.0.6/maclib/Mac_Wave.h
92 --- Maelstrom-3.0.6-orig/maclib/Mac_Wave.h 2000-01-26 01:44:10 +0900
93 +++ Maelstrom-3.0.6/maclib/Mac_Wave.h 2003-05-21 11:28:20 +0900
98 - vsprintf(errbuf, fmt, ap);
99 + vsnprintf(errbuf, sizeof(errbuf), fmt, ap);
103 diff -ur Maelstrom-3.0.6-orig/maclib/macres.cpp Maelstrom-3.0.6/maclib/macres.cpp
104 --- Maelstrom-3.0.6-orig/maclib/macres.cpp 2000-01-26 01:44:20 +0900
105 +++ Maelstrom-3.0.6/maclib/macres.cpp 2003-05-21 11:30:01 +0900
107 ids[j], res->ResourceName(types[i], ids[j]));
110 - sprintf(path,"%s/%s:%hu", argv[2],
112 + snprintf(path, sizeof(path), "%s/%s:%hu",
113 + argv[2], types[i], ids[j]);
116 if ( (output=fopen(path, "w")) != NULL ) {
117 diff -ur Maelstrom-3.0.6-orig/maclib/snd2wav.cpp Maelstrom-3.0.6/maclib/snd2wav.cpp
118 --- Maelstrom-3.0.6-orig/maclib/snd2wav.cpp 2001-03-28 12:54:50 +0900
119 +++ Maelstrom-3.0.6/maclib/snd2wav.cpp 2003-05-21 11:29:23 +0900
123 wave.Load(snd, rate);
124 - sprintf(wavname, "snd_%d.wav", ids[i]);
125 + snprintf(wavname, sizeof(wavname), "snd_%d.wav", ids[i]);
129 diff -ur Maelstrom-3.0.6-orig/main.cpp Maelstrom-3.0.6/main.cpp
130 --- Maelstrom-3.0.6-orig/main.cpp 2002-10-20 11:53:32 +0900
131 +++ Maelstrom-3.0.6/main.cpp 2003-05-21 11:27:02 +0900
133 DrawText(xOff+309-7, yOff+240-6, text, geneva, STYLE_BOLD,
136 - sprintf(text, "%d", gSoundLevel);
137 + snprintf(text, sizeof(text), "%d", gSoundLevel);
138 DrawText(xOff+309-7, yOff+240-6, text, geneva, STYLE_BOLD,
139 30000>>8, 30000>>8, 0xFF);
141 @@ -547,11 +547,11 @@
143 DrawText(xOff+5, botDiv+42+(index*18), hScores[index].name,
144 font, STYLE_BOLD, R, G, B);
145 - sprintf(buffer, "%u", hScores[index].score);
146 + snprintf(buffer, sizeof(buffer), "%u", hScores[index].score);
147 sw = fontserv->TextWidth(buffer, font, STYLE_BOLD);
148 DrawText(sRt-sw, botDiv+42+(index*18), buffer,
149 font, STYLE_BOLD, R, G, B);
150 - sprintf(buffer, "%u", hScores[index].wave);
151 + snprintf(buffer, sizeof(buffer), "%u", hScores[index].wave);
152 sw = fontserv->TextWidth(buffer, font, STYLE_BOLD);
153 DrawText(wRt-sw, botDiv+42+(index*18), buffer,
154 font, STYLE_BOLD, R, G, B);
157 DrawText(xOff+5, botDiv+46+(10*18)+3, "Last Score: ",
158 bigfont, STYLE_NORM, 0xFF, 0xFF, 0xFF);
159 - sprintf(buffer, "%d", GetScore());
160 + snprintf(buffer, sizeof(buffer), "%d", GetScore());
161 sw = fontserv->TextWidth("Last Score: ", bigfont, STYLE_NORM);
162 DrawText(xOff+5+sw, botDiv+46+(index*18)+3, buffer,
163 bigfont, STYLE_NORM, 0xFF, 0xFF, 0xFF);
164 diff -ur Maelstrom-3.0.6-orig/myerror.cpp Maelstrom-3.0.6/myerror.cpp
165 --- Maelstrom-3.0.6-orig/myerror.cpp 1998-07-14 10:50:17 +0900
166 +++ Maelstrom-3.0.6/myerror.cpp 2003-05-21 11:23:33 +0900
171 - vsprintf(mesg, fmt, ap);
172 + vsnprintf(mesg, sizeof(mesg), fmt, ap);
180 - vsprintf(mesg, fmt, ap);
181 + vsnprintf(mesg, sizeof(mesg), fmt, ap);
189 - sprintf(buffer, "%s: %s\n", msg, strerror(errno));
190 + snprintf(buffer, sizeof(buffer), "%s: %s\n", msg, strerror(errno));
193 error((char *)strerror(errno));
194 diff -ur Maelstrom-3.0.6-orig/netlogic/game.cpp Maelstrom-3.0.6/netlogic/game.cpp
195 --- Maelstrom-3.0.6-orig/netlogic/game.cpp 2001-07-23 11:24:03 +0900
196 +++ Maelstrom-3.0.6/netlogic/game.cpp 2003-05-21 11:33:19 +0900
199 lastDisplayed = gDisplayed;
200 screen->FillRect(0, 0, SCREEN_WIDTH, 12, ourBlack);
202 + snprintf(caption, sizeof(caption),
203 "You are player %d --- displaying player %d",
204 gOurPlayer+1, gDisplayed+1);
205 DrawText(SPRITES_WIDTH, 11, caption, geneva,
207 /* -- Erase old and draw new score */
208 screen->FillRect(45, gStatusLine+1,
209 score_width, text_height, ourBlack);
210 - sprintf(numbuf, "%d", Score);
211 + snprintf(numbuf, sizeof(numbuf), "%d", Score);
212 score_width = DrawText(45, gStatusLine+11,
213 numbuf, geneva, STYLE_BOLD,
216 if (lastWave != gWave) {
217 screen->FillRect(255, gStatusLine+1,
218 wave_width, text_height, ourBlack);
219 - sprintf(numbuf, "%d", gWave);
220 + snprintf(numbuf, sizeof(numbuf), "%d", gWave);
221 wave_width = DrawText(255, gStatusLine+11,
222 numbuf, geneva, STYLE_BOLD,
225 if (lastLives != Lives) {
226 screen->FillRect(319, gStatusLine+1,
227 lives_width, text_height, ourBlack);
228 - sprintf(numbuf, "%-3.1d", Lives);
229 + snprintf(numbuf, sizeof(numbuf), "%-3.1d", Lives);
230 lives_width = DrawText(319, gStatusLine+11,
231 numbuf, geneva, STYLE_BOLD,
234 if (lastBonus != Bonus) {
235 screen->FillRect(384, gStatusLine+1,
236 bonus_width, text_height, ourBlack);
237 - sprintf(numbuf, "%-7.1d", Bonus);
238 + snprintf(numbuf, sizeof(numbuf), "%-7.1d", Bonus);
239 bonus_width = DrawText(384, gStatusLine+11,
240 numbuf, geneva, STYLE_BOLD,
243 if (lastFrags != Frags) {
244 screen->FillRect(fragoff, gStatusLine+1,
245 frags_width, text_height, ourBlack);
246 - sprintf(numbuf, "%-3.1d", Frags);
247 + snprintf(numbuf, sizeof(numbuf), "%-3.1d", Frags);
248 frags_width = DrawText(fragoff, gStatusLine+11,
249 numbuf, geneva, STYLE_BOLD,
251 @@ -747,10 +747,11 @@
252 for ( i=0; i<gNumPlayers; ++i ) {
253 char buffer[BUFSIZ], num1[12], num2[12];
255 - sprintf(num1, "%7.1d", final[i].Score);
256 - sprintf(num2, "%3.1d", final[i].Frags);
257 - sprintf(buffer, "Player %d: %-.7s Points, %-.3s Frags",
258 - final[i].Player, num1, num2);
259 + snprintf(num1, sizeof(num1), "%7.1d", final[i].Score);
260 + snprintf(num2, sizeof(num2), "%3.1d", final[i].Frags);
261 + snprintf(buffer, sizeof(buffer),
262 + "Player %d: %-.7s Points, %-.3s Frags",
263 + final[i].Player, num1, num2);
264 DrawText(160, 380+i*newyork_height, buffer,
265 newyork, STYLE_NORM, 30000>>8, 30000>>8, 0xFF);
270 /* -- Draw the wave completed message */
271 - sprintf(numbuf, "Wave %d completed.", gWave);
272 + snprintf(numbuf, sizeof(numbuf), "Wave %d completed.", gWave);
273 sw = fontserv->TextWidth(numbuf, geneva, STYLE_BOLD);
274 x = (SCREEN_WIDTH - sw) / 2;
275 DrawText(x, 150, numbuf, geneva, STYLE_BOLD, 0xFF, 0xFF, 0x00);
277 if (OurShip->GetBonusMult() != 1) {
280 - sprintf(numbuf, "%-5.1d", OurShip->GetBonus());
281 + snprintf(numbuf, sizeof(numbuf), "%-5.1d", OurShip->GetBonus());
282 DrawText(x, 200, numbuf, geneva, STYLE_BOLD,
285 @@ -951,10 +952,10 @@
287 sound->PlaySound(gFunk, 5);
289 - sprintf(numbuf, "%-5.1d", OurShip->GetBonus());
290 + snprintf(numbuf, sizeof(numbuf), "%-5.1d", OurShip->GetBonus());
291 bonus_width = DrawText(x, 200, numbuf, geneva, STYLE_BOLD,
293 - sprintf(numbuf, "%-5.1d", OurShip->GetScore());
294 + snprintf(numbuf, sizeof(numbuf), "%-5.1d", OurShip->GetScore());
295 score_width = DrawText(xt, 220, numbuf, geneva, STYLE_BOLD,
298 @@ -997,12 +998,12 @@
300 screen->FillRect(x, 200-text_height+2,
301 bonus_width, text_height, ourBlack);
302 - sprintf(numbuf, "%-5.1d", OurShip->GetBonus());
303 + snprintf(numbuf, sizeof(numbuf), "%-5.1d", OurShip->GetBonus());
304 bonus_width = DrawText(x, 200, numbuf,
305 geneva, STYLE_BOLD, 0xFF, 0xFF, 0xFF);
306 screen->FillRect(xt, 220-text_height+2,
307 score_width, text_height, ourBlack);
308 - sprintf(numbuf, "%-5.1d", OurShip->GetScore());
309 + snprintf(numbuf, sizeof(numbuf), "%-5.1d", OurShip->GetScore());
310 score_width = DrawText(xt, 220, numbuf,
311 geneva, STYLE_BOLD, 0xFF, 0xFF, 0xFF);
313 @@ -1015,7 +1016,7 @@
316 /* -- Draw the "next wave" message */
317 - sprintf(numbuf, "Prepare for Wave %d...", gWave+1);
318 + snprintf(numbuf, sizeof(numbuf), "Prepare for Wave %d...", gWave+1);
319 sw = fontserv->TextWidth(numbuf, geneva, STYLE_BOLD);
320 x = (SCREEN_WIDTH - sw)/2;
321 DrawText(x, 259, numbuf, geneva, STYLE_BOLD, 0xFF, 0xFF, 0x00);
322 diff -ur Maelstrom-3.0.6-orig/netlogic/netplay.cpp Maelstrom-3.0.6/netlogic/netplay.cpp
323 --- Maelstrom-3.0.6-orig/netlogic/netplay.cpp 2002-10-20 13:11:52 +0900
324 +++ Maelstrom-3.0.6/netlogic/netplay.cpp 2003-05-21 11:31:43 +0900
326 strcpy(message, "Waiting for players:");
327 for ( i=0; i<gNumPlayers; ++i ) {
329 - sprintf(&message[strlen(message)], " %d", i+1);
330 + snprintf(&message[strlen(message)],
331 + sizeof(message)-strlen(message),
337 /* Check the player... */
338 if ( (i != gOurPlayer) && (netbuf[1] == gOurPlayer) ) {
339 /* Print message, sleep 3 seconds absolutely */
341 + snprintf(message, sizeof(message),
342 "Error: Another player (%d) thinks they are player 1!\r\n", i+1);
343 ErrorMessage(message);
344 /* Suck up retransmission packets */
345 diff -ur Maelstrom-3.0.6-orig/netscore.cpp Maelstrom-3.0.6/netscore.cpp
346 --- Maelstrom-3.0.6-orig/netscore.cpp 2001-07-23 12:25:17 +0900
347 +++ Maelstrom-3.0.6/netscore.cpp 2003-05-21 11:27:18 +0900
350 /* Send the scores */
351 crc = get_checksum(key, KEY_LEN);
352 - sprintf(netbuf, SCOREFMT, crc, high.name, high.score, high.wave);
353 + snprintf(netbuf, sizeof(netbuf), SCOREFMT, crc, high.name, high.score, high.wave);
354 SDLNet_TCP_Send(remote, netbuf, strlen(netbuf));
355 n = SDLNet_TCP_Recv(remote, netbuf, 1024);
357 diff -ur Maelstrom-3.0.6-orig/screenlib/SDL_FrameBuf.cpp Maelstrom-3.0.6/screenlib/SDL_FrameBuf.cpp
358 --- Maelstrom-3.0.6-orig/screenlib/SDL_FrameBuf.cpp 2001-07-23 06:03:13 +0900
359 +++ Maelstrom-3.0.6/screenlib/SDL_FrameBuf.cpp 2003-05-21 11:31:01 +0900
363 for ( which=0; !found; ++which ) {
364 - sprintf(file, "%s%d.bmp", prefix, which);
365 + snprintf(file, sizeof(file), "%s%d.bmp", prefix, which);
366 if ( ((fp=fopen(file, "r")) == NULL) &&
367 ((fp=fopen(file, "w")) != NULL) ) {
369 diff -ur Maelstrom-3.0.6-orig/screenlib/SDL_FrameBuf.h Maelstrom-3.0.6/screenlib/SDL_FrameBuf.h
370 --- Maelstrom-3.0.6-orig/screenlib/SDL_FrameBuf.h 2000-09-25 02:55:39 +0900
371 +++ Maelstrom-3.0.6/screenlib/SDL_FrameBuf.h 2003-05-21 11:27:41 +0900
376 - vsprintf(errbuf, fmt, ap);
377 + vsnprintf(errbuf, sizeof(errbuf), fmt, ap);