summaryrefslogtreecommitdiffstats
path: root/games/joy2key/home_not_set_segfault.patch
diff options
context:
space:
mode:
Diffstat (limited to 'games/joy2key/home_not_set_segfault.patch')
-rw-r--r--games/joy2key/home_not_set_segfault.patch34
1 files changed, 34 insertions, 0 deletions
diff --git a/games/joy2key/home_not_set_segfault.patch b/games/joy2key/home_not_set_segfault.patch
new file mode 100644
index 0000000000..0e0fb08c81
--- /dev/null
+++ b/games/joy2key/home_not_set_segfault.patch
@@ -0,0 +1,34 @@
+Author: Jonathan Niehof <jtniehof@gmail.com>
+Subject: Fix segfault if $HOME not set and -config passed
+Bug-Debian: https://bugs.debian.org/716582
+Forwarded: https://sourceforge.net/p/joy2key/patches/5/
+Last-Update: 2013-07-13
+
+--- a/joy2key.c
++++ b/joy2key.c
+@@ -386,6 +386,7 @@
+ FILE *file;
+ int rcargc;
+ char *rcargv[255], line[255];
++ char *homedir;
+
+ for(i=1; i<argc; i++)
+ {
+@@ -442,9 +443,15 @@
+ }
+ if(strcmp(rcfile,DEFAULT_RCFILE) == 0)
+ {
+- x=strlen(getenv("HOME")) + strlen(rcfile) + 2;
++ homedir=getenv("HOME");
++ if(homedir==NULL)
++ {
++ printf("No home directory; cannot open default rc file\n");
++ exit(1);
++ }
++ x=strlen(homedir) + strlen(rcfile) + 2;
+ rcfile=(char*)malloc(x);
+- sprintf(rcfile, "%s/%s", getenv("HOME"), DEFAULT_RCFILE);
++ sprintf(rcfile, "%s/%s", homedir, DEFAULT_RCFILE);
+ }
+ if((file=fopen(rcfile, "r"))==NULL)
+ {