[Lldb-commits] [lldb] r349869 - Fix stack-buffer-overflow in lldb_private::Host::FindProcesses (2/2)

Jonas Devlieghere via lldb-commits lldb-commits at lists.llvm.org
Thu Dec 20 17:22:58 PST 2018


Author: jdevlieghere
Date: Thu Dec 20 17:22:58 2018
New Revision: 349869

URL: http://llvm.org/viewvc/llvm-project?rev=349869&view=rev
Log:
Fix stack-buffer-overflow in lldb_private::Host::FindProcesses (2/2)

This fixes the second call at line 640 that I missed in r349858.

Modified:
    lldb/trunk/source/Host/macosx/objcxx/Host.mm

Modified: lldb/trunk/source/Host/macosx/objcxx/Host.mm
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/macosx/objcxx/Host.mm?rev=349869&r1=349868&r2=349869&view=diff
==============================================================================
--- lldb/trunk/source/Host/macosx/objcxx/Host.mm (original)
+++ lldb/trunk/source/Host/macosx/objcxx/Host.mm Thu Dec 20 17:22:58 2018
@@ -627,7 +627,7 @@ uint32_t Host::FindProcesses(const Proce
   int mib[3] = {CTL_KERN, KERN_PROC, KERN_PROC_ALL};
 
   size_t pid_data_size = 0;
-  if (::sysctl(mib, 3, NULL, &pid_data_size, NULL, 0) != 0)
+  if (::sysctl(mib, 3, nullptr, &pid_data_size, nullptr, 0) != 0)
     return 0;
 
   // Add a few extra in case a few more show up
@@ -637,7 +637,7 @@ uint32_t Host::FindProcesses(const Proce
   kinfos.resize(estimated_pid_count);
   pid_data_size = kinfos.size() * sizeof(struct kinfo_proc);
 
-  if (::sysctl(mib, 4, &kinfos[0], &pid_data_size, NULL, 0) != 0)
+  if (::sysctl(mib, 3, &kinfos[0], &pid_data_size, nullptr, 0) != 0)
     return 0;
 
   const size_t actual_pid_count = (pid_data_size / sizeof(struct kinfo_proc));




More information about the lldb-commits mailing list