on de.billardgl.Billardgl help sign in
flathub/patches/07_segfault_no_home.patch
48 lines 1.6 kB history raw
1Description: billard-gl tries to get the HOME dir but doesn't fail gracefully
2 if it is not set in the environment. This patch addresses that.
3Author: Barry deFreese <bdefreese@debian.org>
4Debian-Bug: http://bugs.debian.org/715681
5Index: billard-gl-1.75/src/KommandoZeilenParameter.cpp
6===================================================================
7--- billard-gl-1.75.orig/src/KommandoZeilenParameter.cpp 2013-08-09 11:52:05.000000000 -0400
8+++ billard-gl-1.75/src/KommandoZeilenParameter.cpp 2013-08-09 20:25:45.906456954 -0400
9@@ -2,6 +2,9 @@
10 #include <stdlib.h>
11 #include <stdio.h>
12 #include <string.h>
13+#include <unistd.h>
14+#include <sys/types.h>
15+#include <pwd.h>
16 #include "Namen.h"
17 #include "KommandoZeilenParameter.h"
19@@ -9,7 +12,13 @@
20 FILE *f;
21 #ifndef _WIN32
22 char dateiname[512];
23- snprintf(dateiname,sizeof(dateiname),"%s/.BillardGL.conf.v7",getenv("HOME"));
24+ const char *homedir = getenv("HOME");
25+ if (!homedir) {
26+ struct passwd *pw;
27+ pw = getpwuid(getuid());
28+ homedir = pw->pw_dir;
29+ }
30+ snprintf(dateiname,sizeof(dateiname),"%s/.BillardGL.conf.v7",homedir);
31 f=fopen(dateiname,"w+");
32 #endif
33 #ifdef _WIN32
34@@ -66,7 +75,13 @@
35 FILE *f;
36 #ifndef _WIN32
37 char dateiname[512];
38- snprintf(dateiname,sizeof(dateiname),"%s/.BillardGL.conf.v7",getenv("HOME"));
39+ const char *homedir = getenv("HOME");
40+ if (!homedir) {
41+ struct passwd *pw;
42+ pw = getpwuid(getuid());
43+ homedir = pw->pw_dir;
44+ }
45+ snprintf(dateiname,sizeof(dateiname),"%s/.BillardGL.conf.v7",homedir);
46 f=fopen(dateiname,"r");
47 #endif
48 #ifdef _WIN32