]> git.pld-linux.org Git - packages/Maelstrom.git/blob - Maelstrom-sec.patch
- release 7: added -sdl_rect.patch
[packages/Maelstrom.git] / Maelstrom-sec.patch
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
4 @@ -83,7 +83,7 @@
5         if ( fname ) {
6                 *fname = datafile;
7         }
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 )
11                 return(NULL);
12         return(data);
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
16 @@ -92,7 +92,7 @@
17                 va_list ap;
18  
19                 va_start(ap, fmt);
20 -               vsprintf(errbuf, fmt, ap);
21 +               vsnprintf(errbuf, sizeof(errbuf), fmt, ap);
22                 va_end(ap);
23                 errstr = errbuf;
24          }
25 @@ -878,7 +878,7 @@
26                 if ( entry->text ) {
27                         Fontserv->FreeText(entry->text);
28                 }
29 -               sprintf(buf, "%d", *entry->variable);
30 +               snprintf(buf, sizeof(buf), "%d", *entry->variable);
31  
32                 if ( entry->hilite ) {
33                         clear = Fg;
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
37 @@ -81,7 +81,7 @@
38         SDL_Surface *bmp, *title;
39         
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));
44         if ( bmp == NULL ) {
45                 return(NULL);
46 @@ -103,7 +103,7 @@
47         Uint16 w, h;
48         
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
58 @@ -135,7 +135,7 @@
59                 va_list ap;
60  
61                 va_start(ap, fmt);
62 -               vsprintf(errbuf, fmt, ap);
63 +               vsnprintf(errbuf, sizeof(errbuf), fmt, ap);
64                 va_end(ap);
65                 errstr = errbuf;
66         }
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
70 @@ -96,7 +96,7 @@
71                 va_list ap;
72  
73                 va_start(ap, fmt);
74 -               vsprintf(errbuf, fmt, ap);
75 +               vsnprintf(errbuf, sizeof(errbuf), fmt, ap);
76                 va_end(ap);
77                 errstr = errbuf;
78         }
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
82 @@ -199,7 +199,7 @@
83                 va_list ap;
84  
85                 va_start(ap, fmt);
86 -               vsprintf(errbuf, fmt, ap);
87 +               vsnprintf(errbuf, sizeof(errbuf), fmt, ap);
88                 va_end(ap);
89                 errstr = errbuf;
90         }
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
94 @@ -108,7 +108,7 @@
95                 va_list ap;
96  
97                 va_start(ap, fmt);
98 -               vsprintf(errbuf, fmt, ap);
99 +               vsnprintf(errbuf, sizeof(errbuf), fmt, ap);
100                 va_end(ap);
101                 errstr = errbuf;
102         }
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
106 @@ -58,8 +58,8 @@
107                                 ids[j], res->ResourceName(types[i], ids[j]));
108                         if ( argv[2] ) {
109                                 char path[23];
110 -                               sprintf(path,"%s/%s:%hu", argv[2],
111 -                                                       types[i], ids[j]);
112 +                               snprintf(path, sizeof(path), "%s/%s:%hu",
113 +                                        argv[2], types[i], ids[j]);
114                                 FILE *output;
115                                 Mac_ResData *D;
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
120 @@ -82,7 +82,7 @@
121                         continue;
122                 }
123                 wave.Load(snd, rate);
124 -               sprintf(wavname, "snd_%d.wav", ids[i]);
125 +               snprintf(wavname, sizeof(wavname), "snd_%d.wav", ids[i]);
126                 wave.Save(wavname);
127         }
128         delete macx;
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
132 @@ -445,7 +445,7 @@
133                 DrawText(xOff+309-7, yOff+240-6, text, geneva, STYLE_BOLD,
134                                                         0x00, 0x00, 0x00);
135         }
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);
140         screen->Update();
141 @@ -547,11 +547,11 @@
142                 }
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);
155 @@ -560,7 +560,7 @@
156  
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
167 @@ -16,7 +16,7 @@
168         va_list ap;
169  
170         va_start(ap, fmt);
171 -       vsprintf(mesg, fmt, ap);
172 +       vsnprintf(mesg, sizeof(mesg), fmt, ap);
173         fputs(mesg, stderr);
174         va_end(ap);
175  }
176 @@ -27,7 +27,7 @@
177         va_list ap;
178  
179         va_start(ap, fmt);
180 -       vsprintf(mesg, fmt, ap);
181 +       vsnprintf(mesg, sizeof(mesg), fmt, ap);
182         fputs(mesg, stdout);
183         va_end(ap);
184  }
185 @@ -37,7 +37,7 @@
186         char buffer[BUFSIZ];
187  
188         if ( *msg ) {
189 -               sprintf(buffer, "%s: %s\n", msg, strerror(errno));
190 +               snprintf(buffer, sizeof(buffer), "%s: %s\n", msg, strerror(errno));
191                 error(buffer);
192         } else
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
197 @@ -232,7 +232,7 @@
198  
199                         lastDisplayed = gDisplayed;
200                         screen->FillRect(0, 0, SCREEN_WIDTH, 12, ourBlack);
201 -                       sprintf(caption,
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,
206 @@ -357,7 +357,7 @@
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,
214                                                         0xFF, 0xFF, 0xFF);
215 @@ -380,7 +380,7 @@
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,
223                                                         0xFF, 0xFF, 0xFF);
224 @@ -391,7 +391,7 @@
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,
232                                                         0xFF, 0xFF, 0xFF);
233 @@ -402,7 +402,7 @@
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,
241                                                         0xFF, 0xFF, 0xFF);
242 @@ -414,7 +414,7 @@
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,
250                                                         0xFF, 0xFF, 0xFF);
251 @@ -747,10 +747,11 @@
252                 for ( i=0; i<gNumPlayers; ++i ) {
253                         char buffer[BUFSIZ], num1[12], num2[12];
254  
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);
266                 }
267 @@ -898,7 +899,7 @@
268         
269  
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);
276 @@ -935,7 +936,7 @@
277                 if (OurShip->GetBonusMult() != 1) {
278                         SDL_Surface *sprite;
279  
280 -                       sprintf(numbuf, "%-5.1d", OurShip->GetBonus());
281 +                       snprintf(numbuf, sizeof(numbuf), "%-5.1d", OurShip->GetBonus());
282                         DrawText(x, 200, numbuf, geneva, STYLE_BOLD,
283                                                         0xFF, 0xFF, 0xFF);
284                         x += 75;
285 @@ -951,10 +952,10 @@
286         Delay(SOUND_DELAY);
287         sound->PlaySound(gFunk, 5);
288  
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,
292                                                         0xFF, 0xFF, 0xFF);
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,
296                                                         0xFF, 0xFF, 0xFF);
297         screen->Update();
298 @@ -997,12 +998,12 @@
299         
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);
312  
313 @@ -1015,7 +1016,7 @@
314         HandleEvents(10);
315  
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
325 @@ -670,7 +670,9 @@
326                 strcpy(message, "Waiting for players:");
327                 for ( i=0; i<gNumPlayers; ++i ) {
328                         if ( ! acked[i] )
329 -                               sprintf(&message[strlen(message)], " %d", i+1);
330 +                               snprintf(&message[strlen(message)],
331 +                                        sizeof(message)-strlen(message),
332 +                                        " %d", i+1);
333                 }
334                 Message(message);
335  
336 @@ -725,7 +727,7 @@
337                         /* Check the player... */
338                         if ( (i != gOurPlayer) && (netbuf[1] == gOurPlayer) ) {
339                                 /* Print message, sleep 3 seconds absolutely */
340 -                               sprintf(message, 
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
348 @@ -59,7 +59,7 @@
349  
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);
356         if ( n > 0 ) {
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
360 @@ -628,7 +628,7 @@
361  
362                 found = 0;
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) ) {
368                                 found = 1;
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
372 @@ -165,7 +165,7 @@
373                 va_list ap;
374  
375                 va_start(ap, fmt);
376 -               vsprintf(errbuf, fmt, ap);
377 +               vsnprintf(errbuf, sizeof(errbuf), fmt, ap);
378                 va_end(ap);
379                 errstr = errbuf;
380          }
381
382
This page took 0.114838 seconds and 3 git commands to generate.