aboutsummaryrefslogtreecommitdiffstats
path: root/community/bareos/fix-bsmtp-segfault.patch
diff options
context:
space:
mode:
authorSimon Frankenberger <simon@fraho.eu>2019-04-05 07:43:32 +0200
committerNatanael Copa <ncopa@alpinelinux.org>2019-04-08 20:23:45 +0200
commit1b3fe8f6f7bcaaa6789d90017f419f0887029260 (patch)
tree12f70111a1c6285e7f3c075e7ee8758e948d0d62 /community/bareos/fix-bsmtp-segfault.patch
parentd97ad97a7a708b313cb922e17d4730079fdfc999 (diff)
downloadaports-1b3fe8f6f7bcaaa6789d90017f419f0887029260.tar.gz
aports-1b3fe8f6f7bcaaa6789d90017f419f0887029260.tar.bz2
aports-1b3fe8f6f7bcaaa6789d90017f419f0887029260.tar.xz
community/bareos: Fix segfaults on startup
This PR fixes two undefined behaviours with pthreads leading to segfaults. Fixes #10156 https://bugs.alpinelinux.org/issues/10156 (cherry picked from commit 37923bd0f6d4e33a3b7de6c23e708787c5d7d3bf)
Diffstat (limited to 'community/bareos/fix-bsmtp-segfault.patch')
-rw-r--r--community/bareos/fix-bsmtp-segfault.patch46
1 files changed, 46 insertions, 0 deletions
diff --git a/community/bareos/fix-bsmtp-segfault.patch b/community/bareos/fix-bsmtp-segfault.patch
new file mode 100644
index 0000000000..8712f68a98
--- /dev/null
+++ b/community/bareos/fix-bsmtp-segfault.patch
@@ -0,0 +1,46 @@
+Patch from Michael Cassaniti, posted here:
+https://bugs.alpinelinux.org/issues/10156#note-5
+Until this issue is fixed upstream this patch is needed.
+
+diff --git a/src/lib/jcr.c b/src/lib/jcr.c
+index 00bfe8c87..338f90e59 100644
+--- a/src/lib/jcr.c
++++ b/src/lib/jcr.c
+@@ -77,6 +77,7 @@ static pthread_mutex_t jcr_lock = PTHREAD_MUTEX_INITIALIZER;
+ static pthread_mutex_t job_start_mutex = PTHREAD_MUTEX_INITIALIZER;
+ static pthread_mutex_t last_jobs_mutex = PTHREAD_MUTEX_INITIALIZER;
+
++static bool jcr_initialized = false;
+ #ifdef HAVE_WIN32
+ static bool tsd_initialized = false;
+ static pthread_key_t jcr_key; /* Pointer to jcr for each thread */
+@@ -351,6 +352,8 @@ static void create_jcr_key()
+ berrno be;
+ Jmsg1(NULL, M_ABORT, 0, _("pthread key create failed: ERR=%s\n"),
+ be.bstrerror(status));
++ } else {
++ jcr_initialized = true;
+ }
+ }
+
+@@ -719,7 +722,10 @@ void set_jcr_in_tsd(JCR *jcr)
+ */
+ JCR *get_jcr_from_tsd()
+ {
+- JCR *jcr = (JCR *)pthread_getspecific(jcr_key);
++ JCR *jcr = (JCR *)INVALID_JCR;
++ if (jcr_initialized){
++ jcr = (JCR *)pthread_getspecific(jcr_key);
++ }
+
+ /*
+ * Set any INVALID_JCR to NULL which the rest of BAREOS understands
+@@ -736,7 +742,7 @@ JCR *get_jcr_from_tsd()
+ */
+ uint32_t get_jobid_from_tsd()
+ {
+- JCR *jcr = (JCR *)pthread_getspecific(jcr_key);
++ JCR *jcr = get_jcr_from_tsd();
+ uint32_t JobId = 0;
+
+ if (jcr && jcr != INVALID_JCR) {