summaryrefslogtreecommitdiff
path: root/games/xnethack/files/patch-util-makedefs.c
diff options
context:
space:
mode:
authorRobert Clausecker <fuz@fuz.su>2021-04-27 23:43:23 +0200
committerLi-Wen Hsu <lwhsu@FreeBSD.org>2021-05-24 08:09:09 +0800
commit7ef30eed0cf6f5626f708259518981a293a7645a (patch)
treec2d72570729f45c45c837c74cbc4c17017330b13 /games/xnethack/files/patch-util-makedefs.c
parentgames/nbsdgames: (new port) 17 text-based modern games (diff)
games/xnethack: (new port) Experimental features and improvements applied to NetHack 3.7-dev
xNetHack is a fork of the dungeon exploration game NetHack. It is a distant descendent of Rogue and Hack, and a direct descendant of the development version of NetHack 3.7. The main goals of xNetHack are to take vanilla NetHack and: - Fix gameplay balance issues. - Remove tedious and frustrating parts of the game. - Make uninteresting parts of the game more interesting. - Experiment with new ideas from the community. In general, the game design takes a conservative approach to changing the gameplay compared to other variants, with focus on deepening elements of the game rather than broadening them. For example, this philosophy would prefer to differentiate monsters in a class that all tend to play the same way, instead of adding new monsters to that class. WWW: https://nethackwiki.com/wiki/XNetHack PR: 255456
Diffstat (limited to 'games/xnethack/files/patch-util-makedefs.c')
-rw-r--r--games/xnethack/files/patch-util-makedefs.c71
1 files changed, 71 insertions, 0 deletions
diff --git a/games/xnethack/files/patch-util-makedefs.c b/games/xnethack/files/patch-util-makedefs.c
new file mode 100644
index 000000000000..13d38f3bfba0
--- /dev/null
+++ b/games/xnethack/files/patch-util-makedefs.c
@@ -0,0 +1,71 @@
+--- util/makedefs.c.orig 2021-03-22 22:28:14 UTC
++++ util/makedefs.c
+@@ -116,6 +116,7 @@ static struct version_info version;
+ #define MAXFNAMELEN 600
+
+ static char filename[MAXFNAMELEN];
++static char tempfilename[MAXFNAMELEN];
+
+ #ifdef FILE_PREFIX
+ /* if defined, a first argument not starting with - is
+@@ -229,6 +230,12 @@ main(int argc, char *argv[])
+ return 1;
+ }
+
++ if (snprintf(tempfilename, sizeof(tempfilename), "%s.%d", "grep.tmp", getpid()) >= sizeof(tempfilename)) {
++ Fprintf(stderr, "Cannot create temporary filename.");
++ (void) fflush(stderr);
++ return 1;
++ }
++
+ #ifdef FILE_PREFIX
+ if (argc >= 2 && argv[1][0] != '-') {
+ file_prefix = argv[1];
+@@ -964,12 +971,12 @@ do_rnd_access_file(const char* fname, const char* defl
+ more likely to be picked than normal but it's nothing to worry about */
+ (void) fputs(xcrypt(deflt_content), ofp);
+
+- tfp = getfp(DATA_TEMPLATE, "grep.tmp", WRTMODE, FLG_TEMPFILE);
++ tfp = getfp(DATA_TEMPLATE, tempfilename, WRTMODE, FLG_TEMPFILE);
+ grep0(ifp, tfp, FLG_TEMPFILE);
+ #ifndef HAS_NO_MKSTEMP
+ ifp = tfp;
+ #else
+- ifp = getfp(DATA_TEMPLATE, "grep.tmp", RDTMODE, 0);
++ ifp = getfp(DATA_TEMPLATE, tempfilename, RDTMODE, 0);
+ #endif
+ while ((line = fgetline(ifp)) != 0) {
+ if (line[0] != '#' && line[0] != '\n')
+@@ -980,7 +987,7 @@ do_rnd_access_file(const char* fname, const char* defl
+ Fclose(ofp);
+
+ #ifdef HAS_NO_MKSTEMP
+- delete_file(DATA_TEMPLATE, "grep.tmp");
++ delete_file(DATA_TEMPLATE, templfilename);
+ #endif
+ return;
+ }
+@@ -1758,12 +1765,12 @@ do_dungeon(void)
+ }
+ Fprintf(ofp, "%s", Dont_Edit_Data);
+
+- tfp = getfp(DATA_TEMPLATE, "grep.tmp", WRTMODE, FLG_TEMPFILE);
++ tfp = getfp(DATA_TEMPLATE, tempfilename, WRTMODE, FLG_TEMPFILE);
+ grep0(ifp, tfp, FLG_TEMPFILE);
+ #ifndef HAS_NO_MKSTEMP
+ ifp = tfp;
+ #else
+- ifp = getfp(DATA_TEMPLATE, "grep.tmp", RDTMODE, 0);
++ ifp = getfp(DATA_TEMPLATE, tempfilename, RDTMODE, 0);
+ #endif
+ while ((line = fgetline(ifp)) != 0) {
+ SpinCursor(3);
+@@ -1779,7 +1786,7 @@ do_dungeon(void)
+ Fclose(ofp);
+
+ #ifdef HAS_NO_MKSTEMP
+- delete_file(DATA_TEMPLATE, "grep.tmp");
++ delete_file(DATA_TEMPLATE, tempfilename);
+ #endif
+ return;
+ }