summaryrefslogtreecommitdiff
path: root/net/freeradius/patches
diff options
context:
space:
mode:
authormanu <manu@pkgsrc.org>2018-12-19 22:52:32 +0000
committermanu <manu@pkgsrc.org>2018-12-19 22:52:32 +0000
commit41f3340ca8827b3ed1803d848e39d0992cab1816 (patch)
tree6c72c3fd7a3a174217e59deeb77e3ebbe1505254 /net/freeradius/patches
parentac78b687edd1fb6817799d938b9d9683d5c25524 (diff)
downloadpkgsrc-41f3340ca8827b3ed1803d848e39d0992cab1816.tar.gz
Fix startup crash when running outside of gdb on BSD systems
On BSD systems, ptrace(PT_DETACH) uses a third argument for resume address, with the magic value (void *)1 to resume where process stopped. Specifying NULL there leads to a crash because process resumes at address 0. We introduce an OS-dependent _PTRACE_DETACH macro to specify third argument as NULL on Linux and (void *)1 on other systems. Always using (void *)1 could be another solution, since basic tests suggests passing (void *)1 as third argument on Linux does not cause harm. From upstream https://github.com/FreeRADIUS/freeradius-server/commit/1f8cd27b78c011826bc0744debb4ed60b3f0584a
Diffstat (limited to 'net/freeradius/patches')
-rw-r--r--net/freeradius/patches/patch-src_lib_debug.c41
1 files changed, 41 insertions, 0 deletions
diff --git a/net/freeradius/patches/patch-src_lib_debug.c b/net/freeradius/patches/patch-src_lib_debug.c
new file mode 100644
index 00000000000..bcf2d5dfe06
--- /dev/null
+++ b/net/freeradius/patches/patch-src_lib_debug.c
@@ -0,0 +1,41 @@
+$NetBSD: patch-src_lib_debug.c,v 1.1 2018/12/19 22:52:32 manu Exp $
+
+Fix startup crash when running outside of gdb on BSD systems.
+
+From upstream https://github.com/FreeRADIUS/freeradius-server/commit/1f8cd27b78c011826bc0744debb4ed60b3f0584a
+
+--- src/lib//debug.c.orig 2018-12-16 03:31:31.909930476 +0100
++++ src/lib//debug.c 2018-12-19 10:05:49.848809433 +0100
+@@ -105,13 +105,21 @@
+
+ static TALLOC_CTX *talloc_null_ctx;
+ static TALLOC_CTX *talloc_autofree_ctx;
+
++/*
++ * On BSD systems, ptrace(PT_DETACH) uses a third argument for
++ * resume address, with the magic value (void *)1 to resume where
++ * process stopped. Specifying NULL there leads to a crash because
++ * process resumes at address 0.
++ */
+ #ifdef HAVE_SYS_PTRACE_H
+ # ifdef __linux__
+ # define _PTRACE(_x, _y) ptrace(_x, _y, NULL, NULL)
++# define _PTRACE_DETACH(_x) ptrace(PT_DETACH, _x, NULL, NULL)
+ # else
+ # define _PTRACE(_x, _y) ptrace(_x, _y, NULL, 0)
++# define _PTRACE_DETACH(_x) ptrace(PT_DETACH, _x, (void *)1, NULL)
+ # endif
+
+ # ifdef HAVE_CAPABILITY_H
+ # include <sys/capability.h>
+@@ -205,9 +213,9 @@
+ fprintf(stderr, "Writing ptrace status to parent failed: %s", fr_syserror(errno));
+ }
+
+ /* Detach */
+- _PTRACE(PT_DETACH, ppid);
++ _PTRACE_DETACH(ppid);
+ exit(0);
+ }
+
+ ret = DEBUG_STATE_ATTACHED;