Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 14 Jul 2000 09:37:24 -0700 (PDT)
From:      tkato@prontomail.ne.jp
To:        freebsd-gnats-submit@FreeBSD.org
Subject:   ports/19925: Update port: games/sxsame
Message-ID:  <20000714163724.AC6CA37B8C3@hub.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         19925
>Category:       ports
>Synopsis:       Update port: games/sxsame
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-ports
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Fri Jul 14 09:40:01 PDT 2000
>Closed-Date:
>Last-Modified:
>Originator:     KATO Tsuguru
>Release:        4.0-RELEASE i386
>Organization:
>Environment:
>Description:
- Support CFLAGS properly
- Modify patches to conform 'one file per patch' porting guideline

New file:
patches/patch-ad  patches/patch-ae  patches/patch-af  patches/patch-ag
patches/patch-ah

Remove file:
patches/patch-ab  patches/patch-ac

>How-To-Repeat:

>Fix:
diff -urN /usr/ports/games/sxsame/Makefile games/sxsame/Makefile
--- /usr/ports/games/sxsame/Makefile	Mon May  1 21:46:22 2000
+++ games/sxsame/Makefile	Fri Jul 14 22:50:13 2000
@@ -25,12 +25,12 @@
 BINMODE=	2755
 MAKE_ENV+=	BINOWN=${BINOWN} BINGRP=${BINGRP} BINMODE=${BINMODE}
 
-WRKSRC=         ${WRKDIR}/sxsame-3.02
-
 post-install:
+.if !defined(NOPORTDOCS)
 	@${MKDIR} ${PREFIX}/share/doc/sxsame
 .for i in INSTALL.jp README.jp
-	@${INSTALL_DATA} ${WRKSRC}/$i ${PREFIX}/share/doc/sxsame
+	${INSTALL_DATA} ${WRKSRC}/${i} ${PREFIX}/share/doc/sxsame
 .endfor
+.endif
 
 .include <bsd.port.mk>
diff -urN /usr/ports/games/sxsame/patches/patch-aa games/sxsame/patches/patch-aa
--- /usr/ports/games/sxsame/patches/patch-aa	Sat Dec 11 04:30:05 1999
+++ games/sxsame/patches/patch-aa	Tue Jul 11 21:36:06 2000
@@ -1,11 +1,11 @@
 --- Imakefile.orig	Sun May  5 04:10:27 1996
-+++ Imakefile	Mon Nov  1 02:11:20 1999
++++ Imakefile	Tue Jul 11 21:14:48 2000
 @@ -3,7 +3,7 @@
  # * Copyleft  (c) 1994-1996  Software Research Academy         *
  # **************************************************************
  #
 -SAMEDIR = /usr/local/games/sxsame
-+SAMEDIR = $(PREFIX)/lib/X11/sxsame
++SAMEDIR = $(LIBDIR)/sxsame
  
  #BINDIR = /usr/local/bin
  #MANDIR = /usr/local/man/man1
@@ -17,6 +17,15 @@
  
  XPMLIB = -lXpm
  LOCAL_LIBRARIES = $(XPMLIB) -lX11
+@@ -19,7 +20,7 @@
+ DEFINES = -DSAME_DIR=\"$(SAMEDIR)\"
+ 
+ #CDEBUGFLAGS = -O2 -Wall
+-CDEBUGFLAGS = -g -Wall
++#CDEBUGFLAGS = -g -Wall
+ #CDEBUGFLAGS = -O2
+ ComplexProgramTarget(sxsame)
+ InstallManPage(sxsame,$(MANDIR))
 @@ -29,6 +30,10 @@
  #defdata.o:: defdata.c defdata.h
  install.dir::
diff -urN /usr/ports/games/sxsame/patches/patch-ab games/sxsame/patches/patch-ab
--- /usr/ports/games/sxsame/patches/patch-ab	Sat Dec 11 04:30:05 1999
+++ games/sxsame/patches/patch-ab	Thu Jan  1 09:00:00 1970
@@ -1,117 +0,0 @@
---- hiscore.c.orig	Sun May  5 04:09:25 1996
-+++ hiscore.c	Sun Oct 31 23:23:42 1999
-@@ -5,6 +5,9 @@
-  * Copyleft  (c) 1994-1996  Software Research Academy                   *
-  ************************************************************************/
- #include <stdio.h>
-+#include <stdlib.h>
-+#include <string.h>
-+#include <unistd.h>
- #include <sys/types.h>
- #include <sys/stat.h>
- #include "config.h"
-@@ -12,7 +15,7 @@
- 
- static struct Hiscore hiscore[4];
- 
--static char *lockf = LOCK_FILE;
-+static char *lockfn = LOCK_FILE;
- static char *hiscoref = HISCORE_FILE;
- extern char *same_dir;
- static int lock_file(
-@@ -75,7 +78,7 @@
- 				break;
- 			}
- 		}
--		if(i < 10 | new == 1)
-+		if(i < 10 || new == 1)
- 		{
- 			if(lock_file(0) != 0)
- 				return(-1);
-@@ -98,7 +101,7 @@
- 	char lkf[256];
- 	int i;
- 
--	sprintf(lkf,"%s/%s", same_dir, lockf);
-+	sprintf(lkf,"%s/%s", same_dir, lockfn);
- 	if(cmd == 1)
- 	{
- 		if(remove(lkf) != 0)
---- inifile.c.orig	Sun May  5 04:09:25 1996
-+++ inifile.c	Sun Oct 31 23:23:42 1999
-@@ -5,6 +5,8 @@
-  * Copyleft  (c) 1994-1996  Software Research Academy                   *
-  ************************************************************************/
- #include <stdio.h>
-+#include <stdlib.h>
-+#include <string.h>
- 
- #include "sxsame.h"
- 
---- loadbmp.c.orig	Sun May  5 04:09:25 1996
-+++ loadbmp.c	Sun Oct 31 23:23:42 1999
-@@ -5,6 +5,8 @@
-  * Copyleft  (c) 1994-1996  Software Research Academy                   *
-  ************************************************************************/
- #include <stdio.h>
-+#include <stdlib.h>
-+#include <string.h>
- #include <X11/Xlib.h>
- #include "sxsame.h"
- 
---- loaddata.c.orig	Sun May  5 04:09:25 1996
-+++ loaddata.c	Sun Oct 31 23:24:02 1999
-@@ -5,6 +5,8 @@
-  * Copyleft  (c) 1994-1996  Software Research Academy                   *
-  ************************************************************************/
- #include <stdio.h>
-+#include <stdlib.h>
-+#include <string.h>
- #include "config.h"
- #include "sxsame.h"
- 
-@@ -94,7 +96,7 @@
- 	{
- 		for(j=0;j<5;j++)
- 		{
--			data->xpm_data[i][j] == 0;
-+			data->xpm_data[i][j] = 0;
- 		}
- 	}
- 	data->bg_data = 0;
---- sxsame.c.orig	Sun May  5 04:09:26 1996
-+++ sxsame.c	Sun Oct 31 23:23:42 1999
-@@ -12,6 +12,10 @@
- char *program_version = "3.02";
- 
- #include <stdio.h>
-+#include <stdlib.h>
-+#include <unistd.h>
-+#include <time.h>
-+#include <string.h>
- #include <X11/Xlib.h>
- #include <X11/Xutil.h>
- #ifndef LOCAL_XPM_H
-@@ -163,11 +167,21 @@
- int      hisc_height = 80;
- #endif /* !ENABLE_HISCORE */
- 
--
-+int ReadInitFile(int* width, int* height, int* same_pic);
-+int SaveInitFile(int width, int height, int same_pic);
- int CheckSameDataFile(DataFile ***);
- int LoadBMPSameData(Display *dpy, Colormap cmap, SameGame *, char *);
- int LoadSameData(ImportSameData *, char *);
-+int CheckSelectSame(int sx, int sy);
-+
-+static
-+int
-+Access(const char* path)
-+{
-+	return access(path, R_OK);
-+}
- 
-+# define access(x)	Access(x)		
- 
- void main(argc, argv)
- int argc;
diff -urN /usr/ports/games/sxsame/patches/patch-ac games/sxsame/patches/patch-ac
--- /usr/ports/games/sxsame/patches/patch-ac	Sat Dec 11 04:30:05 1999
+++ games/sxsame/patches/patch-ac	Thu Jan  1 09:00:00 1970
@@ -1,227 +0,0 @@
---- ../../work-old/sxsame-3.02/hiscore.c	Mon Nov  1 01:17:43 1999
-+++ hiscore.c	Mon Nov  1 00:24:36 1999
-@@ -8,8 +8,7 @@
- #include <stdlib.h>
- #include <string.h>
- #include <unistd.h>
--#include <sys/types.h>
--#include <sys/stat.h>
-+#include <sys/param.h>
- #include "config.h"
- #include "hiscore.h"
- 
-@@ -33,12 +32,15 @@
- 	FILE *fp;
- 	int i, j;
- 	char *myname;
--	char tmpf[256];
-+	char tmpf[MAXPATHLEN];
- 	int new = 0;
- 
- 	myname = (char *)getenv("LOGNAME");
--	sprintf(tmpf, "%s/%s", same_dir, hiscoref);
--	umask(0);
-+	if (MAXPATHLEN <= snprintf(tmpf, MAXPATHLEN ,"%s/%s", same_dir, hiscoref) ) {
-+		fprintf(stderr,"Error: hiscore file name too long.\n");
-+		return -1;
-+	}
-+	umask(002);
- 	fp = fopen(tmpf,"rb");
- 	if(fp != NULL)
- 	{
-@@ -82,7 +84,7 @@
- 		{
- 			if(lock_file(0) != 0)
- 				return(-1);
--			umask(0);
-+			umask(002);
- 			fp = fopen(tmpf, "wb");
- 			fwrite(hiscore, sizeof(hiscore), 1, fp);
- 			fclose(fp);
-@@ -98,10 +100,13 @@
- int cmd;
- {
- 	FILE *fp;
--	char lkf[256];
-+	char lkf[MAXPATHLEN];
- 	int i;
- 
--	sprintf(lkf,"%s/%s", same_dir, lockfn);
-+	if (MAXPATHLEN <= snprintf(lkf, MAXPATHLEN, "%s/%s", same_dir, lockfn)) { 
-+		fprintf(stderr,"Error: lock file name too long.\n");
-+		return -1;
-+	}
- 	if(cmd == 1)
- 	{
- 		if(remove(lkf) != 0)
-@@ -137,9 +142,12 @@
- struct Hiscore *hi;
- {
- 	FILE *fp;
--	char tmpf[256];
-+	char tmpf[MAXPATHLEN];
- 
--	sprintf(tmpf, "%s/%s", same_dir, hiscoref);
-+	if (MAXPATHLEN <= snprintf(tmpf, MAXPATHLEN, "%s/%s", same_dir, hiscoref)) {
-+		fprintf(stderr,"Error: hiscore file name too long.\n");
-+		return -1;
-+	}
- 	fp = fopen(tmpf,"rb");
- 	if(fp == NULL)
- 		return(-1);
---- ../../work-old/sxsame-3.02/loadbmp.c	Mon Nov  1 01:17:43 1999
-+++ loadbmp.c	Mon Nov  1 01:38:08 1999
-@@ -7,6 +7,7 @@
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
-+#include <sys/param.h>
- #include <X11/Xlib.h>
- #include "sxsame.h"
- 
-@@ -39,17 +40,24 @@
- 	int c, c1,c2;
- 	int width, height, planes, ncol;
- 	int *col;
--	char fname[256];
-+	char fname[MAXPATHLEN];
- 
- 	Pixmap w;
- 	GC gc;
- 	int i, j, k;
- 
-+	if (MAXPATHLEN <= strlen(bmpname) ) {
-+		fprintf(stderr,"Error: BMP file name too long.\n");
-+		return -1;
-+	}
- 	strcpy(fname,bmpname);
- 	fp = fopen(fname,"rb");
- 	if(fp == NULL)
- 	{
--		sprintf(fname, "%s/%s", SAME_DIR, bmpname);
-+		if (MAXPATHLEN <= snprintf(fname, MAXPATHLEN, "%s/%s", SAME_DIR, bmpname)) {
-+			fprintf(stderr,"Error: BMP file name too long.\n");
-+			return -1;
-+		}
- 		fp = fopen(fname, "r");
- 		if(fp == NULL)
- 		{
---- ../../work-old/sxsame-3.02/loaddata.c	Mon Nov  1 01:17:43 1999
-+++ loaddata.c	Mon Nov  1 01:35:49 1999
-@@ -7,6 +7,7 @@
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
-+#include <sys/param.h>
- #include "config.h"
- #include "sxsame.h"
- 
-@@ -27,7 +28,7 @@
- DataFile ***data;
- {
- 	FILE *fp;
--	char fname[256];
-+	char fname[MAXPATHLEN];
- 	char buf[256];
- 	char str1[256];
- 	char str2[256];
-@@ -36,11 +37,18 @@
- 	char *p;
- 	int i;
- 
-+	if (MAXPATHLEN <= strlen(entry_name)) {
-+		fprintf(stderr,"Error: data file name too long.\n");
-+		return 0;
-+	}
- 	strcpy(fname,entry_name);
- 	fp = fopen(fname, "r");
- 	if(fp == NULL)
- 	{
--		sprintf(fname, "%s/%s", SAME_DIR, entry_name);
-+		if (MAXPATHLEN <= snprintf(fname, MAXPATHLEN ,"%s/%s", SAME_DIR, entry_name)) {
-+			fprintf(stderr,"Error: data file name too long.\n");
-+			return 0;
-+		}
- 		fp = fopen(fname, "r");
- 		if(fp == NULL)
- 			return(0);
-@@ -83,7 +91,7 @@
- char *fname;
- {
- 	FILE *fp;
--	char tmpfname[256];
-+	char tmpfname[MAXPATHLEN];
- 	char buf[256];
- 	char str1[256],str2[256];
- 	int val, i, j;
-@@ -105,7 +113,10 @@
- 	fp = fopen(fname,"r");
- 	if(fp == NULL)
- 	{
--		sprintf(tmpfname, "%s/%s", SAME_DIR, fname);
-+		if (MAXPATHLEN <= snprintf(tmpfname, MAXPATHLEN, "%s/%s", SAME_DIR, fname)) {
-+			fprintf(stderr,"Error: data file name too long.\n", fname);
-+			return -1;
-+		}
- 		fp = fopen(tmpfname, "r");
- 		if(fp == NULL)
- 		{
---- ../../work-old/sxsame-3.02/sxsame.c	Mon Nov  1 01:17:44 1999
-+++ sxsame.c	Mon Nov  1 01:32:18 1999
-@@ -16,6 +16,7 @@
- #include <unistd.h>
- #include <time.h>
- #include <string.h>
-+#include <sys/param.h>
- #include <X11/Xlib.h>
- #include <X11/Xutil.h>
- #ifndef LOCAL_XPM_H
-@@ -740,7 +741,7 @@
- {
- 	ImportSameData data;
- 	int i, j, val, ncol;
--	char tmpfname[256];
-+	char tmpfname[MAXPATHLEN];
- 
- 	if(strlen(fname)>4) /* check Windows data file... */
- 	{
-@@ -798,9 +799,13 @@
- 			{
- 				if(!access(data.xpm_data[i][j]))
- 					strcpy(tmpfname,data.xpm_data[i][j]);
--				else
--					sprintf(tmpfname,"%s/%s",same_dir,
--						data.xpm_data[i][j]);
-+				else {
-+					if (MAXPATHLEN <=
-+						snprintf(tmpfname, MAXPATHLEN, "%s/%s",same_dir,
-+						data.xpm_data[i][j])) {
-+						goto xpm_error;
-+					}
-+				}
- 				val = XpmReadFileToPixmap(dpy, root,
- 					tmpfname, &game.bits_xpm[i][j],
- 					NULL, &xpm_attr);
-@@ -818,7 +823,9 @@
- 	if(!access(data.bg_data))
- 		strcpy(tmpfname,data.bg_data);
- 	else
--		sprintf(tmpfname,"%s/%s",same_dir, data.bg_data);
-+		if (MAXPATHLEN <= snprintf(tmpfname, MAXPATHLEN, "%s/%s",same_dir, data.bg_data)) {
-+			goto xpm_error;
-+		}
- 	val = XpmReadFileToPixmap(dpy, root, tmpfname,
- 			&game.bg_xpm, NULL, &xpm_attr);
- 	free(data.bg_data);
-@@ -828,7 +835,10 @@
- 	if(!access(data.frame_data))
- 		strcpy(tmpfname,data.frame_data);
- 	else
--		sprintf(tmpfname,"%s/%s",same_dir, data.frame_data);
-+		if (MAXPATHLEN <= snprintf(tmpfname, MAXPATHLEN, "%s/%s",same_dir, data.frame_data)) {
-+			
-+			goto xpm_error;
-+		}
- 	val = XpmReadFileToPixmap(dpy, root, tmpfname,
- 			&game.frame_xpm, NULL, &xpm_attr);
- 	free(data.frame_data);
diff -urN /usr/ports/games/sxsame/patches/patch-ad games/sxsame/patches/patch-ad
--- /usr/ports/games/sxsame/patches/patch-ad	Thu Jan  1 09:00:00 1970
+++ games/sxsame/patches/patch-ad	Tue Jul 11 21:36:15 2000
@@ -0,0 +1,86 @@
+--- hiscore.c.orig	Sun May  5 04:09:25 1996
++++ hiscore.c	Tue Jul 11 21:29:01 2000
+@@ -5,14 +5,16 @@
+  * Copyleft  (c) 1994-1996  Software Research Academy                   *
+  ************************************************************************/
+ #include <stdio.h>
+-#include <sys/types.h>
+-#include <sys/stat.h>
++#include <stdlib.h>
++#include <string.h>
++#include <unistd.h>
++#include <sys/param.h>
+ #include "config.h"
+ #include "hiscore.h"
+ 
+ static struct Hiscore hiscore[4];
+ 
+-static char *lockf = LOCK_FILE;
++static char *lockfn = LOCK_FILE;
+ static char *hiscoref = HISCORE_FILE;
+ extern char *same_dir;
+ static int lock_file(
+@@ -30,12 +32,15 @@
+ 	FILE *fp;
+ 	int i, j;
+ 	char *myname;
+-	char tmpf[256];
++	char tmpf[MAXPATHLEN];
+ 	int new = 0;
+ 
+ 	myname = (char *)getenv("LOGNAME");
+-	sprintf(tmpf, "%s/%s", same_dir, hiscoref);
+-	umask(0);
++	if (MAXPATHLEN <= snprintf(tmpf, MAXPATHLEN ,"%s/%s", same_dir, hiscoref) ) {
++		fprintf(stderr,"Error: hiscore file name too long.\n");
++		return -1;
++	}
++	umask(002);
+ 	fp = fopen(tmpf,"rb");
+ 	if(fp != NULL)
+ 	{
+@@ -75,11 +80,11 @@
+ 				break;
+ 			}
+ 		}
+-		if(i < 10 | new == 1)
++		if(i < 10 || new == 1)
+ 		{
+ 			if(lock_file(0) != 0)
+ 				return(-1);
+-			umask(0);
++			umask(002);
+ 			fp = fopen(tmpf, "wb");
+ 			fwrite(hiscore, sizeof(hiscore), 1, fp);
+ 			fclose(fp);
+@@ -95,10 +100,12 @@
+ int cmd;
+ {
+ 	FILE *fp;
+-	char lkf[256];
++	char lkf[MAXPATHLEN];
+ 	int i;
+-
+-	sprintf(lkf,"%s/%s", same_dir, lockf);
++	if (MAXPATHLEN <= snprintf(lkf, MAXPATHLEN, "%s/%s", same_dir, lockfn)) { 
++		fprintf(stderr,"Error: lock file name too long.\n");
++		return -1;
++	}
+ 	if(cmd == 1)
+ 	{
+ 		if(remove(lkf) != 0)
+@@ -134,9 +141,12 @@
+ struct Hiscore *hi;
+ {
+ 	FILE *fp;
+-	char tmpf[256];
++	char tmpf[MAXPATHLEN];
+ 
+-	sprintf(tmpf, "%s/%s", same_dir, hiscoref);
++	if (MAXPATHLEN <= snprintf(tmpf, MAXPATHLEN, "%s/%s", same_dir, hiscoref)) {
++		fprintf(stderr,"Error: hiscore file name too long.\n");
++		return -1;
++	}
+ 	fp = fopen(tmpf,"rb");
+ 	if(fp == NULL)
+ 		return(-1);
diff -urN /usr/ports/games/sxsame/patches/patch-ae games/sxsame/patches/patch-ae
--- /usr/ports/games/sxsame/patches/patch-ae	Thu Jan  1 09:00:00 1970
+++ games/sxsame/patches/patch-ae	Tue Jul 11 21:36:28 2000
@@ -0,0 +1,11 @@
+--- inifile.c.orig	Sun May  5 04:09:25 1996
++++ inifile.c	Tue Jul 11 21:14:03 2000
+@@ -5,6 +5,8 @@
+  * Copyleft  (c) 1994-1996  Software Research Academy                   *
+  ************************************************************************/
+ #include <stdio.h>
++#include <stdlib.h>
++#include <string.h>
+ 
+ #include "sxsame.h"
+ 
diff -urN /usr/ports/games/sxsame/patches/patch-af games/sxsame/patches/patch-af
--- /usr/ports/games/sxsame/patches/patch-af	Thu Jan  1 09:00:00 1970
+++ games/sxsame/patches/patch-af	Tue Jul 11 21:36:39 2000
@@ -0,0 +1,39 @@
+--- loadbmp.c.orig	Sun May  5 04:09:25 1996
++++ loadbmp.c	Tue Jul 11 21:30:24 2000
+@@ -5,6 +5,9 @@
+  * Copyleft  (c) 1994-1996  Software Research Academy                   *
+  ************************************************************************/
+ #include <stdio.h>
++#include <stdlib.h>
++#include <string.h>
++#include <sys/param.h>
+ #include <X11/Xlib.h>
+ #include "sxsame.h"
+ 
+@@ -37,17 +40,24 @@
+ 	int c, c1,c2;
+ 	int width, height, planes, ncol;
+ 	int *col;
+-	char fname[256];
++	char fname[MAXPATHLEN];
+ 
+ 	Pixmap w;
+ 	GC gc;
+ 	int i, j, k;
+ 
++	if (MAXPATHLEN <= strlen(bmpname) ) {
++		fprintf(stderr,"Error: BMP file name too long.\n");
++		return -1;
++	}
+ 	strcpy(fname,bmpname);
+ 	fp = fopen(fname,"rb");
+ 	if(fp == NULL)
+ 	{
+-		sprintf(fname, "%s/%s", SAME_DIR, bmpname);
++		if (MAXPATHLEN <= snprintf(fname, MAXPATHLEN, "%s/%s", SAME_DIR, bmpname)) {
++			fprintf(stderr,"Error: BMP file name too long.\n");
++			return -1;
++		}
+ 		fp = fopen(fname, "r");
+ 		if(fp == NULL)
+ 		{
diff -urN /usr/ports/games/sxsame/patches/patch-ag games/sxsame/patches/patch-ag
--- /usr/ports/games/sxsame/patches/patch-ag	Thu Jan  1 09:00:00 1970
+++ games/sxsame/patches/patch-ag	Tue Jul 11 21:36:54 2000
@@ -0,0 +1,71 @@
+--- loaddata.c.orig	Sun May  5 04:09:25 1996
++++ loaddata.c	Tue Jul 11 21:32:34 2000
+@@ -5,6 +5,9 @@
+  * Copyleft  (c) 1994-1996  Software Research Academy                   *
+  ************************************************************************/
+ #include <stdio.h>
++#include <stdlib.h>
++#include <string.h>
++#include <sys/param.h>
+ #include "config.h"
+ #include "sxsame.h"
+ 
+@@ -25,7 +28,7 @@
+ DataFile ***data;
+ {
+ 	FILE *fp;
+-	char fname[256];
++	char fname[MAXPATHLEN];
+ 	char buf[256];
+ 	char str1[256];
+ 	char str2[256];
+@@ -34,11 +37,18 @@
+ 	char *p;
+ 	int i;
+ 
++	if (MAXPATHLEN <= strlen(entry_name)) {
++		fprintf(stderr,"Error: data file name too long.\n");
++		return 0;
++	}
+ 	strcpy(fname,entry_name);
+ 	fp = fopen(fname, "r");
+ 	if(fp == NULL)
+ 	{
+-		sprintf(fname, "%s/%s", SAME_DIR, entry_name);
++		if (MAXPATHLEN <= snprintf(fname, MAXPATHLEN ,"%s/%s", SAME_DIR, entry_name)) {
++			fprintf(stderr,"Error: data file name too long.\n");
++			return 0;
++		}
+ 		fp = fopen(fname, "r");
+ 		if(fp == NULL)
+ 			return(0);
+@@ -81,7 +91,7 @@
+ char *fname;
+ {
+ 	FILE *fp;
+-	char tmpfname[256];
++	char tmpfname[MAXPATHLEN];
+ 	char buf[256];
+ 	char str1[256],str2[256];
+ 	int val, i, j;
+@@ -94,7 +104,7 @@
+ 	{
+ 		for(j=0;j<5;j++)
+ 		{
+-			data->xpm_data[i][j] == 0;
++			data->xpm_data[i][j] = 0;
+ 		}
+ 	}
+ 	data->bg_data = 0;
+@@ -103,7 +113,10 @@
+ 	fp = fopen(fname,"r");
+ 	if(fp == NULL)
+ 	{
+-		sprintf(tmpfname, "%s/%s", SAME_DIR, fname);
++		if (MAXPATHLEN <= snprintf(tmpfname, MAXPATHLEN, "%s/%s", SAME_DIR, fname)) {
++			fprintf(stderr,"Error: data file name too long.\n", fname);
++			return -1;
++		}
+ 		fp = fopen(tmpfname, "r");
+ 		if(fp == NULL)
+ 		{
diff -urN /usr/ports/games/sxsame/patches/patch-ah games/sxsame/patches/patch-ah
--- /usr/ports/games/sxsame/patches/patch-ah	Thu Jan  1 09:00:00 1970
+++ games/sxsame/patches/patch-ah	Tue Jul 11 21:37:05 2000
@@ -0,0 +1,85 @@
+--- sxsame.c.orig	Sun May  5 04:09:26 1996
++++ sxsame.c	Tue Jul 11 21:35:38 2000
+@@ -12,6 +12,11 @@
+ char *program_version = "3.02";
+ 
+ #include <stdio.h>
++#include <stdlib.h>
++#include <unistd.h>
++#include <time.h>
++#include <string.h>
++#include <sys/param.h>
+ #include <X11/Xlib.h>
+ #include <X11/Xutil.h>
+ #ifndef LOCAL_XPM_H
+@@ -163,11 +168,21 @@
+ int      hisc_height = 80;
+ #endif /* !ENABLE_HISCORE */
+ 
+-
++int ReadInitFile(int* width, int* height, int* same_pic);
++int SaveInitFile(int width, int height, int same_pic);
+ int CheckSameDataFile(DataFile ***);
+ int LoadBMPSameData(Display *dpy, Colormap cmap, SameGame *, char *);
+ int LoadSameData(ImportSameData *, char *);
++int CheckSelectSame(int sx, int sy);
+ 
++static
++int
++Access(const char* path)
++{
++	return access(path, R_OK);
++}
++
++# define access(x)	Access(x)		
+ 
+ void main(argc, argv)
+ int argc;
+@@ -726,7 +741,7 @@
+ {
+ 	ImportSameData data;
+ 	int i, j, val, ncol;
+-	char tmpfname[256];
++	char tmpfname[MAXPATHLEN];
+ 
+ 	if(strlen(fname)>4) /* check Windows data file... */
+ 	{
+@@ -784,9 +799,13 @@
+ 			{
+ 				if(!access(data.xpm_data[i][j]))
+ 					strcpy(tmpfname,data.xpm_data[i][j]);
+-				else
+-					sprintf(tmpfname,"%s/%s",same_dir,
+-						data.xpm_data[i][j]);
++				else {
++					if (MAXPATHLEN <=
++						snprintf(tmpfname, MAXPATHLEN, "%s/%s",same_dir,
++						data.xpm_data[i][j])) {
++						goto xpm_error;
++					}
++				}
+ 				val = XpmReadFileToPixmap(dpy, root,
+ 					tmpfname, &game.bits_xpm[i][j],
+ 					NULL, &xpm_attr);
+@@ -804,7 +823,9 @@
+ 	if(!access(data.bg_data))
+ 		strcpy(tmpfname,data.bg_data);
+ 	else
+-		sprintf(tmpfname,"%s/%s",same_dir, data.bg_data);
++		if (MAXPATHLEN <= snprintf(tmpfname, MAXPATHLEN, "%s/%s",same_dir, data.bg_data)) {
++			goto xpm_error;
++		}
+ 	val = XpmReadFileToPixmap(dpy, root, tmpfname,
+ 			&game.bg_xpm, NULL, &xpm_attr);
+ 	free(data.bg_data);
+@@ -815,6 +836,10 @@
+ 		strcpy(tmpfname,data.frame_data);
+ 	else
+ 		sprintf(tmpfname,"%s/%s",same_dir, data.frame_data);
++		if (MAXPATHLEN <= snprintf(tmpfname, MAXPATHLEN, "%s/%s",same_dir, data.frame_data)) {
++			
++			goto xpm_error;
++		}
+ 	val = XpmReadFileToPixmap(dpy, root, tmpfname,
+ 			&game.frame_xpm, NULL, &xpm_attr);
+ 	free(data.frame_data);


>Release-Note:
>Audit-Trail:
>Unformatted:


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-ports" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20000714163724.AC6CA37B8C3>