summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichal Sojka2018-07-30 07:31:09 +0000
committerJohn Crispin2018-07-30 13:24:15 +0000
commit5f57223913a9657bc1ff14284b01ffcb8dbe0eba (patch)
tree63a045ba5901e19bfa3c100a0afbf5d134a287dc
parent747efb6255cb06e1cd0a8553fd12b9c1f6537d95 (diff)
downloadprocd-5f57223913a9657bc1ff14284b01ffcb8dbe0eba.tar.gz
trace: Use properly sized type for PTRACE_GETEVENTMSG
Without this, on 64-bit systems, ptrace call corrupts memory because it stores 64bit value to 32bit pid_t variable. Signed-off-by: Michal Sojka <michal.sojka@cvut.cz>
-rw-r--r--trace/trace.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/trace/trace.c b/trace/trace.c
index 27cf108..665c22e 100644
--- a/trace/trace.c
+++ b/trace/trace.c
@@ -211,7 +211,9 @@ static void tracer_cb(struct uloop_process *c, int ret)
(ret >> 8) == (SIGTRAP | (PTRACE_EVENT_CLONE << 8))) {
struct tracee *child = calloc(1, sizeof(struct tracee));
- ptrace(PTRACE_GETEVENTMSG, c->pid, 0, &child->proc.pid);
+ unsigned long msg;
+ ptrace(PTRACE_GETEVENTMSG, c->pid, 0, &msg);
+ child->proc.pid = msg;
child->proc.cb = tracer_cb;
ptrace(ptrace_restart, child->proc.pid, 0, 0);
uloop_process_add(&child->proc);