Package: gnujump / 1.0.8-3

07_getenv_NULL.patch Patch series | download
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
From: Evgeni Golov <evgeni@debian.org>
Subject: fix crash when HOME is unset and getenv() returns NULL
Last-Update: 2013-06-26

Index: gnujump-1.0.6/src/main.c
===================================================================
--- gnujump-1.0.6.orig/src/main.c	2013-06-26 21:14:47.000000000 +0200
+++ gnujump-1.0.6/src/main.c	2013-06-26 21:30:18.764096468 +0200
@@ -54,6 +54,10 @@
   /* Get the config file name */
 #ifndef WIN32
   homeDir = getenv ("HOME");
+  if (homeDir == NULL) {
+    homeDir = malloc (sizeof (char) * 2);
+    strcpy(homeDir, "/");
+  }
   cfgFile =
     malloc (sizeof (char) *
 	    (strlen (homeDir) + strlen (CONFDIR) + strlen (CFGFILE) + 3));
Index: gnujump-1.0.6/src/setup.c
===================================================================
--- gnujump-1.0.6.orig/src/setup.c	2008-09-23 16:17:29.000000000 +0200
+++ gnujump-1.0.6/src/setup.c	2013-06-26 21:30:43.089779756 +0200
@@ -55,6 +55,10 @@
 
 #ifndef WIN32
   homeDir = getenv ("HOME");
+  if (homeDir == NULL) {
+    homeDir = malloc (sizeof (char) * 2);
+    strcpy(homeDir, "/");
+  }
   cfgDir = malloc (sizeof (char) * (strlen (homeDir) + strlen (CONFDIR) + 2));
   sprintf (cfgDir, "%s/" CONFDIR, homeDir);
   if (access (cfgDir, F_OK) < 0)