[gtk: 1/2] pid_get_parent: fix for OpenBSD
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk: 1/2] pid_get_parent: fix for OpenBSD
- Date: Mon, 13 May 2019 19:09:50 +0000 (UTC)
commit 0334ea1c889331adb02d361670e24b3f85b5b0d6
Author: Antoine Jacoutot <ajacoutot gnome org>
Date: Mon May 13 20:47:46 2019 +0200
pid_get_parent: fix for OpenBSD
This fixes a long standing bug in pid_get_parent on OpenBSD (which was mine
so... my fault). kp wasn't properly allocated and the function could return
random failures.
gtk/gtkmountoperation-x11.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
---
diff --git a/gtk/gtkmountoperation-x11.c b/gtk/gtkmountoperation-x11.c
index 345570c301..1b7bff6aa1 100644
--- a/gtk/gtkmountoperation-x11.c
+++ b/gtk/gtkmountoperation-x11.c
@@ -736,7 +736,7 @@ pid_get_command_line (GPid pid)
static GPid
pid_get_parent (GPid pid)
{
- struct kinfo_proc kp;
+ struct kinfo_proc *kp;
size_t len;
GPid ppid;
@@ -747,11 +747,14 @@ pid_get_parent (GPid pid)
return (-1);
mib[5] = (len / sizeof(struct kinfo_proc));
- if (sysctl (mib, G_N_ELEMENTS (mib), &kp, &len, NULL, 0) < 0)
+ kp = g_malloc0 (len);
+
+ if (sysctl (mib, G_N_ELEMENTS (mib), kp, &len, NULL, 0) < 0)
return -1;
- ppid = kp.p_ppid;
+ ppid = kp->p_ppid;
+ g_free (kp);
return ppid;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]