summaryrefslogtreecommitdiff
path: root/debian
diff options
context:
space:
mode:
authorMark Hindley <mark@hindley.org.uk>2018-11-04 11:53:47 +0000
committerMark Hindley <mark@hindley.org.uk>2018-11-06 00:12:43 +0000
commit74883bcfe68b77c328b7fe5be9e640a4c7bc6629 (patch)
tree260186ce9b318b840ae0b2b1ba1ff05787d54117 /debian
parentfffec2cd439e8b1b154026a8a981b5628cef2c55 (diff)
Fix daemonization. Avoid SIGABRT from mfree() on program_invocation_short_name
which overlaps with program_invocation_name on glibc 2.27, at least. I am not sure this is the best fix, but it works for now. Submitted upstream: https://github.com/elogind/elogind/issues/92
Diffstat (limited to 'debian')
-rw-r--r--debian/patches/Fix_glibc_program_invocation_name_pointer_overlap.diff46
-rw-r--r--debian/patches/series1
2 files changed, 47 insertions, 0 deletions
diff --git a/debian/patches/Fix_glibc_program_invocation_name_pointer_overlap.diff b/debian/patches/Fix_glibc_program_invocation_name_pointer_overlap.diff
new file mode 100644
index 000000000..5f1868272
--- /dev/null
+++ b/debian/patches/Fix_glibc_program_invocation_name_pointer_overlap.diff
@@ -0,0 +1,46 @@
+Description: Avoid SIGABRT if program_invocation_short_name is a pointer within progam_invocation_short_name
+Bug: https://github.com/elogind/elogind/issues/92
+
+--- a/src/shared/musl_missing.c
++++ b/src/shared/musl_missing.c
+@@ -34,9 +34,14 @@
+
+ static void elogind_free_program_name(void) {
+
+- if (program_invocation_name && (program_invocation_name != program_arg_name) && strlen(program_invocation_name))
++ if (program_invocation_name &&
++ (program_invocation_name != program_arg_name) &&
++ strlen(program_invocation_name))
+ program_invocation_name = mfree(program_invocation_name);
+- if (program_invocation_short_name && (program_invocation_short_name != program_arg_name) && strlen(program_invocation_short_name))
++ if (program_invocation_short_name &&
++ (program_invocation_short_name != program_arg_name) &&
++ (program_invocation_short_name + strlen(program_invocation_short_name) != program_invocation_name + strlen(program_invocation_name))
++ && strlen(program_invocation_short_name))
+ program_invocation_short_name = mfree(program_invocation_short_name);
+ }
+
+--- a/src/basic/process-util.c
++++ b/src/basic/process-util.c
+@@ -10,6 +10,7 @@
+ #include <stdio.h>
+ #include <stdio_ext.h>
+ #include <stdlib.h>
++#include <libgen.h>
+ #include <string.h>
+ #include <sys/mman.h>
+ #include <sys/mount.h>
+@@ -306,8 +307,12 @@
+
+ k = strlen(program_invocation_name);
+ strncpy(program_invocation_name, name, k);
+- if (l > k)
++ if (l > k) {
+ truncated = true;
++ program_invocation_short_name = NULL;
++ }
++ else
++ program_invocation_short_name = program_invocation_name + strlen(dirname(program_invocation_name)) -1;
+ }
+
+ /* Third step, completely replace the argv[] array the kernel maintains for us. This requires privileges, but
diff --git a/debian/patches/series b/debian/patches/series
index 295f7f092..33125a623 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -1 +1,2 @@
manpage-branding.diff
+Fix_glibc_program_invocation_name_pointer_overlap.diff