aboutsummaryrefslogtreecommitdiff
path: root/www/chromium/files/patch-base_process_process__handle__freebsd.cc
blob: e938b55bfa05659a556509c98a11f7b0366aa489 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
--- base/process/process_handle_freebsd.cc.orig	2021-07-19 18:45:05 UTC
+++ base/process/process_handle_freebsd.cc
@@ -3,7 +3,6 @@
 // found in the LICENSE file.
 
 #include "base/process/process_handle.h"
-#include "base/stl_util.h"
 
 #include <limits.h>
 #include <stddef.h>
@@ -12,14 +11,20 @@
 #include <sys/user.h>
 #include <unistd.h>
 
+#include "base/files/file_path.h"
+#include "base/stl_util.h"
+
 namespace base {
 
 ProcessId GetParentProcessId(ProcessHandle process) {
   struct kinfo_proc info;
-  size_t length;
+  size_t length = sizeof(struct kinfo_proc);
   int mib[] = { CTL_KERN, KERN_PROC, KERN_PROC_PID, process };
 
   if (sysctl(mib, base::size(mib), &info, &length, NULL, 0) < 0)
+    return -1;
+
+  if (length < sizeof(struct kinfo_proc))
     return -1;
 
   return info.ki_ppid;