diff options
Diffstat (limited to 'x11/gtk+3/patches/patch-gtk_gtkmountoperation-x11_c')
| -rw-r--r-- | x11/gtk+3/patches/patch-gtk_gtkmountoperation-x11_c | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/x11/gtk+3/patches/patch-gtk_gtkmountoperation-x11_c b/x11/gtk+3/patches/patch-gtk_gtkmountoperation-x11_c new file mode 100644 index 0000000..42d953e --- /dev/null +++ b/x11/gtk+3/patches/patch-gtk_gtkmountoperation-x11_c | |||
| @@ -0,0 +1,52 @@ | |||
| 1 | From 7d8be1c1ffc31523e2de09d4829169b78dd391e4 Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Antoine Jacoutot <ajacoutot@openbsd.org> | ||
| 3 | Date: Fri, 17 May 2019 11:55:16 +0000 | ||
| 4 | Subject: [PATCH] pid_get_parent: fix potential leak of kp | ||
| 5 | |||
| 6 | From 0334ea1c889331adb02d361670e24b3f85b5b0d6 Mon Sep 17 00:00:00 2001 | ||
| 7 | From: Antoine Jacoutot <ajacoutot@gnome.org> | ||
| 8 | Date: Mon, 13 May 2019 20:47:46 +0200 | ||
| 9 | Subject: [PATCH] pid_get_parent: fix for OpenBSD | ||
| 10 | |||
| 11 | Index: gtk/gtkmountoperation-x11.c | ||
| 12 | --- gtk/gtkmountoperation-x11.c.orig | ||
| 13 | +++ gtk/gtkmountoperation-x11.c | ||
| 14 | @@ -720,22 +720,32 @@ pid_get_command_line (GPid pid) | ||
| 15 | static GPid | ||
| 16 | pid_get_parent (GPid pid) | ||
| 17 | { | ||
| 18 | - struct kinfo_proc kp; | ||
| 19 | + struct kinfo_proc *kp = NULL; | ||
| 20 | size_t len; | ||
| 21 | - GPid ppid; | ||
| 22 | + GPid ppid = 0; | ||
| 23 | |||
| 24 | + /* fail if trying to get the parent of the init process (no such thing) */ | ||
| 25 | + if (pid == 1) | ||
| 26 | + goto out; | ||
| 27 | + | ||
| 28 | int mib[] = { CTL_KERN, KERN_PROC, KERN_PROC_PID, pid, | ||
| 29 | sizeof(struct kinfo_proc), 0 }; | ||
| 30 | |||
| 31 | if (sysctl (mib, G_N_ELEMENTS (mib), NULL, &len, NULL, 0) == -1) | ||
| 32 | - return (-1); | ||
| 33 | + goto out; | ||
| 34 | + | ||
| 35 | mib[5] = (len / sizeof(struct kinfo_proc)); | ||
| 36 | |||
| 37 | - if (sysctl (mib, G_N_ELEMENTS (mib), &kp, &len, NULL, 0) < 0) | ||
| 38 | - return -1; | ||
| 39 | + kp = g_malloc0 (len); | ||
| 40 | |||
| 41 | - ppid = kp.p_ppid; | ||
| 42 | + if (sysctl (mib, G_N_ELEMENTS (mib), kp, &len, NULL, 0) < 0) | ||
| 43 | + goto out; | ||
| 44 | |||
| 45 | + ppid = kp->p_ppid; | ||
| 46 | + | ||
| 47 | +out: | ||
| 48 | + if (kp) | ||
| 49 | + g_free (kp); | ||
| 50 | return ppid; | ||
| 51 | } | ||
| 52 | |||
