[trace][intelpt] Fix out-of-bounds access.
authorWeverything <rtrieu@google.com>
Tue, 3 May 2022 21:55:34 +0000 (14:55 -0700)
committerWeverything <rtrieu@google.com>
Tue, 3 May 2022 23:07:58 +0000 (16:07 -0700)
The StringRef single argument constructor expects a null-terminated
string.  Explicitly pass the size to prevent reading pass the end
of the array.

lldb/source/Plugins/Process/Linux/Procfs.cpp

index 1ff7c56..756749e 100644 (file)
@@ -60,8 +60,8 @@ lldb_private::process_linux::GetAvailableLogicalCoreIDs() {
     if (!cpuinfo)
       return cpuinfo.takeError();
 
-    Expected<std::vector<int>> core_ids = GetAvailableLogicalCoreIDs(
-        StringRef(reinterpret_cast<const char *>(cpuinfo->data())));
+    Expected<std::vector<int>> core_ids = GetAvailableLogicalCoreIDs(StringRef(
+        reinterpret_cast<const char *>(cpuinfo->data()), cpuinfo->size()));
     if (!core_ids)
       return core_ids.takeError();