summaryrefslogtreecommitdiff
path: root/games/xboing/patches/patch-ad
blob: 6946f5aaf02d04d6ed196920cccb3fb8cb108612 (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
$NetBSD: patch-ad,v 1.2 2004/02/28 18:36:38 snj Exp $

--- highscore.c.orig	1996-11-21 17:28:46.000000000 -0800
+++ highscore.c	2004-02-28 10:27:07.000000000 -0800
@@ -54,6 +54,9 @@
 #include <unistd.h>
 #include <time.h>
 #include <file.h>
+#ifdef __NetBSD__
+  #include <sys/file.h>
+#endif
 #include <sys/param.h>
 #include <X11/Xlib.h>
 #include <X11/Xutil.h>
@@ -1022,9 +1025,10 @@ int ReadHighScoreTable(type)
 	if (type == GLOBAL)
 	{
 		/* Use the environment variable if it exists */
-		if ((str = getenv("XBOING_SCORE_FILE")) != NULL)
-			strcpy(filename, str);
-		else
+		if ((str = getenv("XBOING_SCORE_FILE")) != NULL) {
+			strncpy(filename, str, sizeof(filename)-1);
+			filename[sizeof(filename)-1] = '\0';
+		} else
 			strcpy(filename, HIGH_SCORE_FILE);
 	}
 	else
@@ -1094,9 +1098,10 @@ int WriteHighScoreTable(type)
 	if (type == GLOBAL)
 	{
 		/* Use the environment variable if it exists */
-		if ((str = getenv("XBOING_SCORE_FILE")) != NULL)
-			strcpy(filename, str);
-		else
+		if ((str = getenv("XBOING_SCORE_FILE")) != NULL) {
+			strncpy(filename, str, sizeof(filename)-1);
+			filename[sizeof(filename)-1] = '\0';
+		} else
 			strcpy(filename, HIGH_SCORE_FILE);
 	}	
 	else
@@ -1217,9 +1222,10 @@ static int LockUnlock(cmd)
 
 
 	/* Use the environment variable if it exists */
-	if ((str = getenv("XBOING_SCORE_FILE")) != NULL)
-		strcpy(filename, str);
-	else
+	if ((str = getenv("XBOING_SCORE_FILE")) != NULL) {
+		strncpy(filename, str, sizeof(filename)-1);
+		filename[sizeof(filename)-1] = '\0';
+	} else
 		strcpy(filename, HIGH_SCORE_FILE);
 
 	/* Open the highscore file for both read & write */