aboutsummaryrefslogtreecommitdiff
path: root/games/urban/files/patch-src::highscor::highscor.cc
blob: 8430fc2fd1b857ed864b576e157f387b9cd28e82 (plain) (blame)
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
57
58
59
--- src/highscor/highscor.cc.orig	Fri Sep  2 13:26:47 2005
+++ src/highscor/highscor.cc	Fri Sep  2 13:27:53 2005
@@ -75,7 +75,7 @@
 
 		if(highscore[i].Level)
 	        	sprintf(buffer, " %-10s%6d   %1d:%1d", highscore[i].Name,
-	        		highscore[i].Score, ((highscore[i].Level-1) / 3) + 1, ((highscore[i].Level-1) % 3) + 1);
+	        		highscore[i].Skore, ((highscore[i].Level-1) / 3) + 1, ((highscore[i].Level-1) % 3) + 1);
 		else
 	        	sprintf(buffer, " %-10s%6d   0:0", "Empty", 0);
 
@@ -100,7 +100,7 @@
 		strcpy(Name, "Unknown");
 #else
 		if(getenv("USER") != NULL)
-			strcpy(Name, getenv("USER"));
+	                strncpy(Name, getenv("USER"), sizeof(Name)-1);		
 		else
 			strcpy(Name, "Unknown");
 #endif
@@ -166,13 +166,13 @@
 
         for(int i = 0; i < NUM_HIGHSCORES; i++) {
 
-        	if(score > highscore[i].Score) {
+        	if(score > highscore[i].Skore) {
 
                 	memmove(&highscore[i + 1], &highscore[i],
                 		sizeof(Score_t) * (NUM_HIGHSCORES - i - 1));
 
                         strcpy(highscore[i].Name, GetName());
-                        highscore[i].Score = score;
+                        highscore[i].Skore = score;
                         highscore[i].Level = level;
                         break;
         	}
@@ -192,7 +192,7 @@
 #else
 	char filename[1024];
 
-	sprintf(filename, "%s/.urban/hs.dat", getenv("HOME"));
+        snprintf(filename, sizeof(filename)-1, "%s/.urban/hs.dat", getenv("HOME"));
 
         if((fd = fopen(filename, "rb")) == NULL)
 #endif
@@ -215,11 +215,10 @@
 	char filename[1024];
 
 	/* Create dir */
-	sprintf(filename, "%s/.urban", getenv("HOME"));
+	snprintf(filename, sizeof(filename)-1, "%s/.urban", getenv("HOME"));
 	mkdir(filename, S_IRUSR | S_IWUSR | S_IXUSR);
 
-	sprintf(filename, "%s/.urban/hs.dat", getenv("HOME"));
-
+        snprintf(filename, sizeof(filename)-1, "%s/.urban/hs.dat", getenv("HOME"));
         if((fd = fopen(filename, "wb")) == NULL)
 #endif
 #endif