[Lldb-commits] [lldb] r324156 - Fix a copy of a fixed length, possibly non-nul terminated, string

Jason Molenda via lldb-commits lldb-commits at lists.llvm.org
Fri Feb 2 14:48:45 PST 2018


Author: jmolenda
Date: Fri Feb  2 14:48:45 2018
New Revision: 324156

URL: http://llvm.org/viewvc/llvm-project?rev=324156&view=rev
Log:
Fix a copy of a fixed length, possibly non-nul terminated, string
into a std::string so we don't run off the end of the array when
there is no nul byte in ProcessElfCore::parseLinuxNotes.  
Found with ASAN testing.

<rdar://problem/37134319> 

Differential revision: https://reviews.llvm.org/D42828

Modified:
    lldb/trunk/source/Plugins/Process/elf-core/ProcessElfCore.cpp

Modified: lldb/trunk/source/Plugins/Process/elf-core/ProcessElfCore.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/elf-core/ProcessElfCore.cpp?rev=324156&r1=324155&r2=324156&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/elf-core/ProcessElfCore.cpp (original)
+++ lldb/trunk/source/Plugins/Process/elf-core/ProcessElfCore.cpp Fri Feb  2 14:48:45 2018
@@ -665,7 +665,7 @@ llvm::Error ProcessElfCore::parseLinuxNo
       Status status = prpsinfo.Parse(note.data, arch);
       if (status.Fail())
         return status.ToError();
-      thread_data.name = prpsinfo.pr_fname;
+      thread_data.name.assign (prpsinfo.pr_fname, strnlen (prpsinfo.pr_fname, sizeof (prpsinfo.pr_fname)));
       SetID(prpsinfo.pr_pid);
       break;
     }




More information about the lldb-commits mailing list