diff options
Diffstat (limited to 'www/chromium-uc/patches/patch-base_process_process_handle_openbsd_cc')
| -rw-r--r-- | www/chromium-uc/patches/patch-base_process_process_handle_openbsd_cc | 92 |
1 files changed, 0 insertions, 92 deletions
diff --git a/www/chromium-uc/patches/patch-base_process_process_handle_openbsd_cc b/www/chromium-uc/patches/patch-base_process_process_handle_openbsd_cc deleted file mode 100644 index 621dbef..0000000 --- a/www/chromium-uc/patches/patch-base_process_process_handle_openbsd_cc +++ /dev/null | |||
| @@ -1,92 +0,0 @@ | |||
| 1 | $OpenBSD: patch-base_process_process_handle_openbsd_cc,v 1.6 2021/09/01 16:54:38 robert Exp $ | ||
| 2 | |||
| 3 | Index: base/process/process_handle_openbsd.cc | ||
| 4 | --- base/process/process_handle_openbsd.cc.orig | ||
| 5 | +++ base/process/process_handle_openbsd.cc | ||
| 6 | @@ -3,8 +3,11 @@ | ||
| 7 | // found in the LICENSE file. | ||
| 8 | |||
| 9 | #include "base/process/process_handle.h" | ||
| 10 | +#include "base/files/file_util.h" | ||
| 11 | |||
| 12 | #include <stddef.h> | ||
| 13 | +#include <sys/param.h> | ||
| 14 | +#include <sys/proc.h> | ||
| 15 | #include <sys/sysctl.h> | ||
| 16 | #include <sys/types.h> | ||
| 17 | #include <unistd.h> | ||
| 18 | @@ -14,39 +17,59 @@ | ||
| 19 | namespace base { | ||
| 20 | |||
| 21 | ProcessId GetParentProcessId(ProcessHandle process) { | ||
| 22 | - struct kinfo_proc info; | ||
| 23 | + struct kinfo_proc *info; | ||
| 24 | size_t length; | ||
| 25 | + pid_t ppid; | ||
| 26 | int mib[] = { CTL_KERN, KERN_PROC, KERN_PROC_PID, process, | ||
| 27 | sizeof(struct kinfo_proc), 0 }; | ||
| 28 | |||
| 29 | if (sysctl(mib, base::size(mib), NULL, &length, NULL, 0) < 0) | ||
| 30 | return -1; | ||
| 31 | |||
| 32 | + info = (struct kinfo_proc *)malloc(length); | ||
| 33 | + | ||
| 34 | mib[5] = (length / sizeof(struct kinfo_proc)); | ||
| 35 | |||
| 36 | - if (sysctl(mib, base::size(mib), &info, &length, NULL, 0) < 0) | ||
| 37 | - return -1; | ||
| 38 | + if (sysctl(mib, base::size(mib), info, &length, NULL, 0) < 0) { | ||
| 39 | + ppid = -1; | ||
| 40 | + goto out; | ||
| 41 | + } | ||
| 42 | |||
| 43 | - return info.p_ppid; | ||
| 44 | + ppid = info->p_ppid; | ||
| 45 | + | ||
| 46 | +out: | ||
| 47 | + free(info); | ||
| 48 | + return ppid; | ||
| 49 | } | ||
| 50 | |||
| 51 | FilePath GetProcessExecutablePath(ProcessHandle process) { | ||
| 52 | - struct kinfo_proc kp; | ||
| 53 | - size_t len; | ||
| 54 | + struct kinfo_proc *info; | ||
| 55 | + size_t length; | ||
| 56 | + char *path = NULL; | ||
| 57 | int mib[] = { CTL_KERN, KERN_PROC, KERN_PROC_PID, process, | ||
| 58 | sizeof(struct kinfo_proc), 0 }; | ||
| 59 | |||
| 60 | - if (sysctl(mib, base::size(mib), NULL, &len, NULL, 0) == -1) | ||
| 61 | + if (sysctl(mib, base::size(mib), NULL, &length, NULL, 0) == -1) | ||
| 62 | return FilePath(); | ||
| 63 | - mib[5] = (len / sizeof(struct kinfo_proc)); | ||
| 64 | - if (sysctl(mib, base::size(mib), &kp, &len, NULL, 0) < 0) | ||
| 65 | - return FilePath(); | ||
| 66 | - if ((kp.p_flag & P_SYSTEM) != 0) | ||
| 67 | - return FilePath(); | ||
| 68 | - if (strcmp(kp.p_comm, "chrome") == 0) | ||
| 69 | - return FilePath(kp.p_comm); | ||
| 70 | |||
| 71 | - return FilePath(); | ||
| 72 | + info = (struct kinfo_proc *)malloc(length); | ||
| 73 | + | ||
| 74 | + mib[5] = (length / sizeof(struct kinfo_proc)); | ||
| 75 | + | ||
| 76 | + if (sysctl(mib, base::size(mib), info, &length, NULL, 0) < 0) | ||
| 77 | + goto out; | ||
| 78 | + | ||
| 79 | + if ((info->p_flag & P_SYSTEM) != 0) | ||
| 80 | + goto out; | ||
| 81 | + | ||
| 82 | + if (strcmp(info->p_comm, "chrome") == 0) { | ||
| 83 | + path = info->p_comm; | ||
| 84 | + goto out; | ||
| 85 | + } | ||
| 86 | + | ||
| 87 | +out: | ||
| 88 | + free(info); | ||
| 89 | + return FilePath(path); | ||
| 90 | } | ||
| 91 | |||
| 92 | } // namespace base | ||
