Browse Source

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
tags/debian-devuan_common
Mark Hindley 3 years ago
parent
commit
74883bcfe6
2 changed files with 47 additions and 0 deletions
  1. +46
    -0
      debian/patches/Fix_glibc_program_invocation_name_pointer_overlap.diff
  2. +1
    -0
      debian/patches/series

+ 46
- 0
debian/patches/Fix_glibc_program_invocation_name_pointer_overlap.diff View File

@@ -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

+ 1
- 0
debian/patches/series View File

@@ -1 +1,2 @@
manpage-branding.diff
Fix_glibc_program_invocation_name_pointer_overlap.diff

Loading…
Cancel
Save