View | Details | Raw Unified | Return to bug 19925
Collapse All | Expand All

(-)games/sxsame/Makefile (-3 / +3 lines)
Lines 25-36 Link Here
25
BINMODE=	2755
25
BINMODE=	2755
26
MAKE_ENV+=	BINOWN=${BINOWN} BINGRP=${BINGRP} BINMODE=${BINMODE}
26
MAKE_ENV+=	BINOWN=${BINOWN} BINGRP=${BINGRP} BINMODE=${BINMODE}
27
27
28
WRKSRC=         ${WRKDIR}/sxsame-3.02
29
30
post-install:
28
post-install:
29
.if !defined(NOPORTDOCS)
31
	@${MKDIR} ${PREFIX}/share/doc/sxsame
30
	@${MKDIR} ${PREFIX}/share/doc/sxsame
32
.for i in INSTALL.jp README.jp
31
.for i in INSTALL.jp README.jp
33
	@${INSTALL_DATA} ${WRKSRC}/$i ${PREFIX}/share/doc/sxsame
32
	${INSTALL_DATA} ${WRKSRC}/${i} ${PREFIX}/share/doc/sxsame
34
.endfor
33
.endfor
34
.endif
35
35
36
.include <bsd.port.mk>
36
.include <bsd.port.mk>
(-)games/sxsame/patches/patch-aa (-2 / +11 lines)
Lines 1-11 Link Here
1
--- Imakefile.orig	Sun May  5 04:10:27 1996
1
--- Imakefile.orig	Sun May  5 04:10:27 1996
2
+++ Imakefile	Mon Nov  1 02:11:20 1999
2
+++ Imakefile	Tue Jul 11 21:14:48 2000
3
@@ -3,7 +3,7 @@
3
@@ -3,7 +3,7 @@
4
 # * Copyleft  (c) 1994-1996  Software Research Academy         *
4
 # * Copyleft  (c) 1994-1996  Software Research Academy         *
5
 # **************************************************************
5
 # **************************************************************
6
 #
6
 #
7
-SAMEDIR = /usr/local/games/sxsame
7
-SAMEDIR = /usr/local/games/sxsame
8
+SAMEDIR = $(PREFIX)/lib/X11/sxsame
8
+SAMEDIR = $(LIBDIR)/sxsame
9
 
9
 
10
 #BINDIR = /usr/local/bin
10
 #BINDIR = /usr/local/bin
11
 #MANDIR = /usr/local/man/man1
11
 #MANDIR = /usr/local/man/man1
Lines 17-22 Link Here
17
 
17
 
18
 XPMLIB = -lXpm
18
 XPMLIB = -lXpm
19
 LOCAL_LIBRARIES = $(XPMLIB) -lX11
19
 LOCAL_LIBRARIES = $(XPMLIB) -lX11
20
@@ -19,7 +20,7 @@
21
 DEFINES = -DSAME_DIR=\"$(SAMEDIR)\"
22
 
23
 #CDEBUGFLAGS = -O2 -Wall
24
-CDEBUGFLAGS = -g -Wall
25
+#CDEBUGFLAGS = -g -Wall
26
 #CDEBUGFLAGS = -O2
27
 ComplexProgramTarget(sxsame)
28
 InstallManPage(sxsame,$(MANDIR))
20
@@ -29,6 +30,10 @@
29
@@ -29,6 +30,10 @@
21
 #defdata.o:: defdata.c defdata.h
30
 #defdata.o:: defdata.c defdata.h
22
 install.dir::
31
 install.dir::
(-)games/sxsame/patches/patch-ab (-117 lines)
Lines 1-117 Link Here
1
--- hiscore.c.orig	Sun May  5 04:09:25 1996
2
+++ hiscore.c	Sun Oct 31 23:23:42 1999
3
@@ -5,6 +5,9 @@
4
  * Copyleft  (c) 1994-1996  Software Research Academy                   *
5
  ************************************************************************/
6
 #include <stdio.h>
7
+#include <stdlib.h>
8
+#include <string.h>
9
+#include <unistd.h>
10
 #include <sys/types.h>
11
 #include <sys/stat.h>
12
 #include "config.h"
13
@@ -12,7 +15,7 @@
14
 
15
 static struct Hiscore hiscore[4];
16
 
17
-static char *lockf = LOCK_FILE;
18
+static char *lockfn = LOCK_FILE;
19
 static char *hiscoref = HISCORE_FILE;
20
 extern char *same_dir;
21
 static int lock_file(
22
@@ -75,7 +78,7 @@
23
 				break;
24
 			}
25
 		}
26
-		if(i < 10 | new == 1)
27
+		if(i < 10 || new == 1)
28
 		{
29
 			if(lock_file(0) != 0)
30
 				return(-1);
31
@@ -98,7 +101,7 @@
32
 	char lkf[256];
33
 	int i;
34
 
35
-	sprintf(lkf,"%s/%s", same_dir, lockf);
36
+	sprintf(lkf,"%s/%s", same_dir, lockfn);
37
 	if(cmd == 1)
38
 	{
39
 		if(remove(lkf) != 0)
40
--- inifile.c.orig	Sun May  5 04:09:25 1996
41
+++ inifile.c	Sun Oct 31 23:23:42 1999
42
@@ -5,6 +5,8 @@
43
  * Copyleft  (c) 1994-1996  Software Research Academy                   *
44
  ************************************************************************/
45
 #include <stdio.h>
46
+#include <stdlib.h>
47
+#include <string.h>
48
 
49
 #include "sxsame.h"
50
 
51
--- loadbmp.c.orig	Sun May  5 04:09:25 1996
52
+++ loadbmp.c	Sun Oct 31 23:23:42 1999
53
@@ -5,6 +5,8 @@
54
  * Copyleft  (c) 1994-1996  Software Research Academy                   *
55
  ************************************************************************/
56
 #include <stdio.h>
57
+#include <stdlib.h>
58
+#include <string.h>
59
 #include <X11/Xlib.h>
60
 #include "sxsame.h"
61
 
62
--- loaddata.c.orig	Sun May  5 04:09:25 1996
63
+++ loaddata.c	Sun Oct 31 23:24:02 1999
64
@@ -5,6 +5,8 @@
65
  * Copyleft  (c) 1994-1996  Software Research Academy                   *
66
  ************************************************************************/
67
 #include <stdio.h>
68
+#include <stdlib.h>
69
+#include <string.h>
70
 #include "config.h"
71
 #include "sxsame.h"
72
 
73
@@ -94,7 +96,7 @@
74
 	{
75
 		for(j=0;j<5;j++)
76
 		{
77
-			data->xpm_data[i][j] == 0;
78
+			data->xpm_data[i][j] = 0;
79
 		}
80
 	}
81
 	data->bg_data = 0;
82
--- sxsame.c.orig	Sun May  5 04:09:26 1996
83
+++ sxsame.c	Sun Oct 31 23:23:42 1999
84
@@ -12,6 +12,10 @@
85
 char *program_version = "3.02";
86
 
87
 #include <stdio.h>
88
+#include <stdlib.h>
89
+#include <unistd.h>
90
+#include <time.h>
91
+#include <string.h>
92
 #include <X11/Xlib.h>
93
 #include <X11/Xutil.h>
94
 #ifndef LOCAL_XPM_H
95
@@ -163,11 +167,21 @@
96
 int      hisc_height = 80;
97
 #endif /* !ENABLE_HISCORE */
98
 
99
-
100
+int ReadInitFile(int* width, int* height, int* same_pic);
101
+int SaveInitFile(int width, int height, int same_pic);
102
 int CheckSameDataFile(DataFile ***);
103
 int LoadBMPSameData(Display *dpy, Colormap cmap, SameGame *, char *);
104
 int LoadSameData(ImportSameData *, char *);
105
+int CheckSelectSame(int sx, int sy);
106
+
107
+static
108
+int
109
+Access(const char* path)
110
+{
111
+	return access(path, R_OK);
112
+}
113
 
114
+# define access(x)	Access(x)		
115
 
116
 void main(argc, argv)
117
 int argc;
(-)games/sxsame/patches/patch-ac (-227 lines)
Lines 1-227 Link Here
1
--- ../../work-old/sxsame-3.02/hiscore.c	Mon Nov  1 01:17:43 1999
2
+++ hiscore.c	Mon Nov  1 00:24:36 1999
3
@@ -8,8 +8,7 @@
4
 #include <stdlib.h>
5
 #include <string.h>
6
 #include <unistd.h>
7
-#include <sys/types.h>
8
-#include <sys/stat.h>
9
+#include <sys/param.h>
10
 #include "config.h"
11
 #include "hiscore.h"
12
 
13
@@ -33,12 +32,15 @@
14
 	FILE *fp;
15
 	int i, j;
16
 	char *myname;
17
-	char tmpf[256];
18
+	char tmpf[MAXPATHLEN];
19
 	int new = 0;
20
 
21
 	myname = (char *)getenv("LOGNAME");
22
-	sprintf(tmpf, "%s/%s", same_dir, hiscoref);
23
-	umask(0);
24
+	if (MAXPATHLEN <= snprintf(tmpf, MAXPATHLEN ,"%s/%s", same_dir, hiscoref) ) {
25
+		fprintf(stderr,"Error: hiscore file name too long.\n");
26
+		return -1;
27
+	}
28
+	umask(002);
29
 	fp = fopen(tmpf,"rb");
30
 	if(fp != NULL)
31
 	{
32
@@ -82,7 +84,7 @@
33
 		{
34
 			if(lock_file(0) != 0)
35
 				return(-1);
36
-			umask(0);
37
+			umask(002);
38
 			fp = fopen(tmpf, "wb");
39
 			fwrite(hiscore, sizeof(hiscore), 1, fp);
40
 			fclose(fp);
41
@@ -98,10 +100,13 @@
42
 int cmd;
43
 {
44
 	FILE *fp;
45
-	char lkf[256];
46
+	char lkf[MAXPATHLEN];
47
 	int i;
48
 
49
-	sprintf(lkf,"%s/%s", same_dir, lockfn);
50
+	if (MAXPATHLEN <= snprintf(lkf, MAXPATHLEN, "%s/%s", same_dir, lockfn)) { 
51
+		fprintf(stderr,"Error: lock file name too long.\n");
52
+		return -1;
53
+	}
54
 	if(cmd == 1)
55
 	{
56
 		if(remove(lkf) != 0)
57
@@ -137,9 +142,12 @@
58
 struct Hiscore *hi;
59
 {
60
 	FILE *fp;
61
-	char tmpf[256];
62
+	char tmpf[MAXPATHLEN];
63
 
64
-	sprintf(tmpf, "%s/%s", same_dir, hiscoref);
65
+	if (MAXPATHLEN <= snprintf(tmpf, MAXPATHLEN, "%s/%s", same_dir, hiscoref)) {
66
+		fprintf(stderr,"Error: hiscore file name too long.\n");
67
+		return -1;
68
+	}
69
 	fp = fopen(tmpf,"rb");
70
 	if(fp == NULL)
71
 		return(-1);
72
--- ../../work-old/sxsame-3.02/loadbmp.c	Mon Nov  1 01:17:43 1999
73
+++ loadbmp.c	Mon Nov  1 01:38:08 1999
74
@@ -7,6 +7,7 @@
75
 #include <stdio.h>
76
 #include <stdlib.h>
77
 #include <string.h>
78
+#include <sys/param.h>
79
 #include <X11/Xlib.h>
80
 #include "sxsame.h"
81
 
82
@@ -39,17 +40,24 @@
83
 	int c, c1,c2;
84
 	int width, height, planes, ncol;
85
 	int *col;
86
-	char fname[256];
87
+	char fname[MAXPATHLEN];
88
 
89
 	Pixmap w;
90
 	GC gc;
91
 	int i, j, k;
92
 
93
+	if (MAXPATHLEN <= strlen(bmpname) ) {
94
+		fprintf(stderr,"Error: BMP file name too long.\n");
95
+		return -1;
96
+	}
97
 	strcpy(fname,bmpname);
98
 	fp = fopen(fname,"rb");
99
 	if(fp == NULL)
100
 	{
101
-		sprintf(fname, "%s/%s", SAME_DIR, bmpname);
102
+		if (MAXPATHLEN <= snprintf(fname, MAXPATHLEN, "%s/%s", SAME_DIR, bmpname)) {
103
+			fprintf(stderr,"Error: BMP file name too long.\n");
104
+			return -1;
105
+		}
106
 		fp = fopen(fname, "r");
107
 		if(fp == NULL)
108
 		{
109
--- ../../work-old/sxsame-3.02/loaddata.c	Mon Nov  1 01:17:43 1999
110
+++ loaddata.c	Mon Nov  1 01:35:49 1999
111
@@ -7,6 +7,7 @@
112
 #include <stdio.h>
113
 #include <stdlib.h>
114
 #include <string.h>
115
+#include <sys/param.h>
116
 #include "config.h"
117
 #include "sxsame.h"
118
 
119
@@ -27,7 +28,7 @@
120
 DataFile ***data;
121
 {
122
 	FILE *fp;
123
-	char fname[256];
124
+	char fname[MAXPATHLEN];
125
 	char buf[256];
126
 	char str1[256];
127
 	char str2[256];
128
@@ -36,11 +37,18 @@
129
 	char *p;
130
 	int i;
131
 
132
+	if (MAXPATHLEN <= strlen(entry_name)) {
133
+		fprintf(stderr,"Error: data file name too long.\n");
134
+		return 0;
135
+	}
136
 	strcpy(fname,entry_name);
137
 	fp = fopen(fname, "r");
138
 	if(fp == NULL)
139
 	{
140
-		sprintf(fname, "%s/%s", SAME_DIR, entry_name);
141
+		if (MAXPATHLEN <= snprintf(fname, MAXPATHLEN ,"%s/%s", SAME_DIR, entry_name)) {
142
+			fprintf(stderr,"Error: data file name too long.\n");
143
+			return 0;
144
+		}
145
 		fp = fopen(fname, "r");
146
 		if(fp == NULL)
147
 			return(0);
148
@@ -83,7 +91,7 @@
149
 char *fname;
150
 {
151
 	FILE *fp;
152
-	char tmpfname[256];
153
+	char tmpfname[MAXPATHLEN];
154
 	char buf[256];
155
 	char str1[256],str2[256];
156
 	int val, i, j;
157
@@ -105,7 +113,10 @@
158
 	fp = fopen(fname,"r");
159
 	if(fp == NULL)
160
 	{
161
-		sprintf(tmpfname, "%s/%s", SAME_DIR, fname);
162
+		if (MAXPATHLEN <= snprintf(tmpfname, MAXPATHLEN, "%s/%s", SAME_DIR, fname)) {
163
+			fprintf(stderr,"Error: data file name too long.\n", fname);
164
+			return -1;
165
+		}
166
 		fp = fopen(tmpfname, "r");
167
 		if(fp == NULL)
168
 		{
169
--- ../../work-old/sxsame-3.02/sxsame.c	Mon Nov  1 01:17:44 1999
170
+++ sxsame.c	Mon Nov  1 01:32:18 1999
171
@@ -16,6 +16,7 @@
172
 #include <unistd.h>
173
 #include <time.h>
174
 #include <string.h>
175
+#include <sys/param.h>
176
 #include <X11/Xlib.h>
177
 #include <X11/Xutil.h>
178
 #ifndef LOCAL_XPM_H
179
@@ -740,7 +741,7 @@
180
 {
181
 	ImportSameData data;
182
 	int i, j, val, ncol;
183
-	char tmpfname[256];
184
+	char tmpfname[MAXPATHLEN];
185
 
186
 	if(strlen(fname)>4) /* check Windows data file... */
187
 	{
188
@@ -798,9 +799,13 @@
189
 			{
190
 				if(!access(data.xpm_data[i][j]))
191
 					strcpy(tmpfname,data.xpm_data[i][j]);
192
-				else
193
-					sprintf(tmpfname,"%s/%s",same_dir,
194
-						data.xpm_data[i][j]);
195
+				else {
196
+					if (MAXPATHLEN <=
197
+						snprintf(tmpfname, MAXPATHLEN, "%s/%s",same_dir,
198
+						data.xpm_data[i][j])) {
199
+						goto xpm_error;
200
+					}
201
+				}
202
 				val = XpmReadFileToPixmap(dpy, root,
203
 					tmpfname, &game.bits_xpm[i][j],
204
 					NULL, &xpm_attr);
205
@@ -818,7 +823,9 @@
206
 	if(!access(data.bg_data))
207
 		strcpy(tmpfname,data.bg_data);
208
 	else
209
-		sprintf(tmpfname,"%s/%s",same_dir, data.bg_data);
210
+		if (MAXPATHLEN <= snprintf(tmpfname, MAXPATHLEN, "%s/%s",same_dir, data.bg_data)) {
211
+			goto xpm_error;
212
+		}
213
 	val = XpmReadFileToPixmap(dpy, root, tmpfname,
214
 			&game.bg_xpm, NULL, &xpm_attr);
215
 	free(data.bg_data);
216
@@ -828,7 +835,10 @@
217
 	if(!access(data.frame_data))
218
 		strcpy(tmpfname,data.frame_data);
219
 	else
220
-		sprintf(tmpfname,"%s/%s",same_dir, data.frame_data);
221
+		if (MAXPATHLEN <= snprintf(tmpfname, MAXPATHLEN, "%s/%s",same_dir, data.frame_data)) {
222
+			
223
+			goto xpm_error;
224
+		}
225
 	val = XpmReadFileToPixmap(dpy, root, tmpfname,
226
 			&game.frame_xpm, NULL, &xpm_attr);
227
 	free(data.frame_data);
(-)games/sxsame/patches/patch-ad (+86 lines)
Line 0 Link Here
1
--- hiscore.c.orig	Sun May  5 04:09:25 1996
2
+++ hiscore.c	Tue Jul 11 21:29:01 2000
3
@@ -5,14 +5,16 @@
4
  * Copyleft  (c) 1994-1996  Software Research Academy                   *
5
  ************************************************************************/
6
 #include <stdio.h>
7
-#include <sys/types.h>
8
-#include <sys/stat.h>
9
+#include <stdlib.h>
10
+#include <string.h>
11
+#include <unistd.h>
12
+#include <sys/param.h>
13
 #include "config.h"
14
 #include "hiscore.h"
15
 
16
 static struct Hiscore hiscore[4];
17
 
18
-static char *lockf = LOCK_FILE;
19
+static char *lockfn = LOCK_FILE;
20
 static char *hiscoref = HISCORE_FILE;
21
 extern char *same_dir;
22
 static int lock_file(
23
@@ -30,12 +32,15 @@
24
 	FILE *fp;
25
 	int i, j;
26
 	char *myname;
27
-	char tmpf[256];
28
+	char tmpf[MAXPATHLEN];
29
 	int new = 0;
30
 
31
 	myname = (char *)getenv("LOGNAME");
32
-	sprintf(tmpf, "%s/%s", same_dir, hiscoref);
33
-	umask(0);
34
+	if (MAXPATHLEN <= snprintf(tmpf, MAXPATHLEN ,"%s/%s", same_dir, hiscoref) ) {
35
+		fprintf(stderr,"Error: hiscore file name too long.\n");
36
+		return -1;
37
+	}
38
+	umask(002);
39
 	fp = fopen(tmpf,"rb");
40
 	if(fp != NULL)
41
 	{
42
@@ -75,11 +80,11 @@
43
 				break;
44
 			}
45
 		}
46
-		if(i < 10 | new == 1)
47
+		if(i < 10 || new == 1)
48
 		{
49
 			if(lock_file(0) != 0)
50
 				return(-1);
51
-			umask(0);
52
+			umask(002);
53
 			fp = fopen(tmpf, "wb");
54
 			fwrite(hiscore, sizeof(hiscore), 1, fp);
55
 			fclose(fp);
56
@@ -95,10 +100,12 @@
57
 int cmd;
58
 {
59
 	FILE *fp;
60
-	char lkf[256];
61
+	char lkf[MAXPATHLEN];
62
 	int i;
63
-
64
-	sprintf(lkf,"%s/%s", same_dir, lockf);
65
+	if (MAXPATHLEN <= snprintf(lkf, MAXPATHLEN, "%s/%s", same_dir, lockfn)) { 
66
+		fprintf(stderr,"Error: lock file name too long.\n");
67
+		return -1;
68
+	}
69
 	if(cmd == 1)
70
 	{
71
 		if(remove(lkf) != 0)
72
@@ -134,9 +141,12 @@
73
 struct Hiscore *hi;
74
 {
75
 	FILE *fp;
76
-	char tmpf[256];
77
+	char tmpf[MAXPATHLEN];
78
 
79
-	sprintf(tmpf, "%s/%s", same_dir, hiscoref);
80
+	if (MAXPATHLEN <= snprintf(tmpf, MAXPATHLEN, "%s/%s", same_dir, hiscoref)) {
81
+		fprintf(stderr,"Error: hiscore file name too long.\n");
82
+		return -1;
83
+	}
84
 	fp = fopen(tmpf,"rb");
85
 	if(fp == NULL)
86
 		return(-1);
(-)games/sxsame/patches/patch-ae (+11 lines)
Line 0 Link Here
1
--- inifile.c.orig	Sun May  5 04:09:25 1996
2
+++ inifile.c	Tue Jul 11 21:14:03 2000
3
@@ -5,6 +5,8 @@
4
  * Copyleft  (c) 1994-1996  Software Research Academy                   *
5
  ************************************************************************/
6
 #include <stdio.h>
7
+#include <stdlib.h>
8
+#include <string.h>
9
 
10
 #include "sxsame.h"
11
 
(-)games/sxsame/patches/patch-af (+39 lines)
Line 0 Link Here
1
--- loadbmp.c.orig	Sun May  5 04:09:25 1996
2
+++ loadbmp.c	Tue Jul 11 21:30:24 2000
3
@@ -5,6 +5,9 @@
4
  * Copyleft  (c) 1994-1996  Software Research Academy                   *
5
  ************************************************************************/
6
 #include <stdio.h>
7
+#include <stdlib.h>
8
+#include <string.h>
9
+#include <sys/param.h>
10
 #include <X11/Xlib.h>
11
 #include "sxsame.h"
12
 
13
@@ -37,17 +40,24 @@
14
 	int c, c1,c2;
15
 	int width, height, planes, ncol;
16
 	int *col;
17
-	char fname[256];
18
+	char fname[MAXPATHLEN];
19
 
20
 	Pixmap w;
21
 	GC gc;
22
 	int i, j, k;
23
 
24
+	if (MAXPATHLEN <= strlen(bmpname) ) {
25
+		fprintf(stderr,"Error: BMP file name too long.\n");
26
+		return -1;
27
+	}
28
 	strcpy(fname,bmpname);
29
 	fp = fopen(fname,"rb");
30
 	if(fp == NULL)
31
 	{
32
-		sprintf(fname, "%s/%s", SAME_DIR, bmpname);
33
+		if (MAXPATHLEN <= snprintf(fname, MAXPATHLEN, "%s/%s", SAME_DIR, bmpname)) {
34
+			fprintf(stderr,"Error: BMP file name too long.\n");
35
+			return -1;
36
+		}
37
 		fp = fopen(fname, "r");
38
 		if(fp == NULL)
39
 		{
(-)games/sxsame/patches/patch-ag (+71 lines)
Line 0 Link Here
1
--- loaddata.c.orig	Sun May  5 04:09:25 1996
2
+++ loaddata.c	Tue Jul 11 21:32:34 2000
3
@@ -5,6 +5,9 @@
4
  * Copyleft  (c) 1994-1996  Software Research Academy                   *
5
  ************************************************************************/
6
 #include <stdio.h>
7
+#include <stdlib.h>
8
+#include <string.h>
9
+#include <sys/param.h>
10
 #include "config.h"
11
 #include "sxsame.h"
12
 
13
@@ -25,7 +28,7 @@
14
 DataFile ***data;
15
 {
16
 	FILE *fp;
17
-	char fname[256];
18
+	char fname[MAXPATHLEN];
19
 	char buf[256];
20
 	char str1[256];
21
 	char str2[256];
22
@@ -34,11 +37,18 @@
23
 	char *p;
24
 	int i;
25
 
26
+	if (MAXPATHLEN <= strlen(entry_name)) {
27
+		fprintf(stderr,"Error: data file name too long.\n");
28
+		return 0;
29
+	}
30
 	strcpy(fname,entry_name);
31
 	fp = fopen(fname, "r");
32
 	if(fp == NULL)
33
 	{
34
-		sprintf(fname, "%s/%s", SAME_DIR, entry_name);
35
+		if (MAXPATHLEN <= snprintf(fname, MAXPATHLEN ,"%s/%s", SAME_DIR, entry_name)) {
36
+			fprintf(stderr,"Error: data file name too long.\n");
37
+			return 0;
38
+		}
39
 		fp = fopen(fname, "r");
40
 		if(fp == NULL)
41
 			return(0);
42
@@ -81,7 +91,7 @@
43
 char *fname;
44
 {
45
 	FILE *fp;
46
-	char tmpfname[256];
47
+	char tmpfname[MAXPATHLEN];
48
 	char buf[256];
49
 	char str1[256],str2[256];
50
 	int val, i, j;
51
@@ -94,7 +104,7 @@
52
 	{
53
 		for(j=0;j<5;j++)
54
 		{
55
-			data->xpm_data[i][j] == 0;
56
+			data->xpm_data[i][j] = 0;
57
 		}
58
 	}
59
 	data->bg_data = 0;
60
@@ -103,7 +113,10 @@
61
 	fp = fopen(fname,"r");
62
 	if(fp == NULL)
63
 	{
64
-		sprintf(tmpfname, "%s/%s", SAME_DIR, fname);
65
+		if (MAXPATHLEN <= snprintf(tmpfname, MAXPATHLEN, "%s/%s", SAME_DIR, fname)) {
66
+			fprintf(stderr,"Error: data file name too long.\n", fname);
67
+			return -1;
68
+		}
69
 		fp = fopen(tmpfname, "r");
70
 		if(fp == NULL)
71
 		{
(-)games/sxsame/patches/patch-ah (+85 lines)
Line 0 Link Here
1
--- sxsame.c.orig	Sun May  5 04:09:26 1996
2
+++ sxsame.c	Tue Jul 11 21:35:38 2000
3
@@ -12,6 +12,11 @@
4
 char *program_version = "3.02";
5
 
6
 #include <stdio.h>
7
+#include <stdlib.h>
8
+#include <unistd.h>
9
+#include <time.h>
10
+#include <string.h>
11
+#include <sys/param.h>
12
 #include <X11/Xlib.h>
13
 #include <X11/Xutil.h>
14
 #ifndef LOCAL_XPM_H
15
@@ -163,11 +168,21 @@
16
 int      hisc_height = 80;
17
 #endif /* !ENABLE_HISCORE */
18
 
19
-
20
+int ReadInitFile(int* width, int* height, int* same_pic);
21
+int SaveInitFile(int width, int height, int same_pic);
22
 int CheckSameDataFile(DataFile ***);
23
 int LoadBMPSameData(Display *dpy, Colormap cmap, SameGame *, char *);
24
 int LoadSameData(ImportSameData *, char *);
25
+int CheckSelectSame(int sx, int sy);
26
 
27
+static
28
+int
29
+Access(const char* path)
30
+{
31
+	return access(path, R_OK);
32
+}
33
+
34
+# define access(x)	Access(x)		
35
 
36
 void main(argc, argv)
37
 int argc;
38
@@ -726,7 +741,7 @@
39
 {
40
 	ImportSameData data;
41
 	int i, j, val, ncol;
42
-	char tmpfname[256];
43
+	char tmpfname[MAXPATHLEN];
44
 
45
 	if(strlen(fname)>4) /* check Windows data file... */
46
 	{
47
@@ -784,9 +799,13 @@
48
 			{
49
 				if(!access(data.xpm_data[i][j]))
50
 					strcpy(tmpfname,data.xpm_data[i][j]);
51
-				else
52
-					sprintf(tmpfname,"%s/%s",same_dir,
53
-						data.xpm_data[i][j]);
54
+				else {
55
+					if (MAXPATHLEN <=
56
+						snprintf(tmpfname, MAXPATHLEN, "%s/%s",same_dir,
57
+						data.xpm_data[i][j])) {
58
+						goto xpm_error;
59
+					}
60
+				}
61
 				val = XpmReadFileToPixmap(dpy, root,
62
 					tmpfname, &game.bits_xpm[i][j],
63
 					NULL, &xpm_attr);
64
@@ -804,7 +823,9 @@
65
 	if(!access(data.bg_data))
66
 		strcpy(tmpfname,data.bg_data);
67
 	else
68
-		sprintf(tmpfname,"%s/%s",same_dir, data.bg_data);
69
+		if (MAXPATHLEN <= snprintf(tmpfname, MAXPATHLEN, "%s/%s",same_dir, data.bg_data)) {
70
+			goto xpm_error;
71
+		}
72
 	val = XpmReadFileToPixmap(dpy, root, tmpfname,
73
 			&game.bg_xpm, NULL, &xpm_attr);
74
 	free(data.bg_data);
75
@@ -815,6 +836,10 @@
76
 		strcpy(tmpfname,data.frame_data);
77
 	else
78
 		sprintf(tmpfname,"%s/%s",same_dir, data.frame_data);
79
+		if (MAXPATHLEN <= snprintf(tmpfname, MAXPATHLEN, "%s/%s",same_dir, data.frame_data)) {
80
+			
81
+			goto xpm_error;
82
+		}
83
 	val = XpmReadFileToPixmap(dpy, root, tmpfname,
84
 			&game.frame_xpm, NULL, &xpm_attr);
85
 	free(data.frame_data);

Return to bug 19925