[compiler-rt] r307696 - Use internal_strncpy to copy filename in linux procmaps
Francis Ricci via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 11 12:40:55 PDT 2017
Author: fjricci
Date: Tue Jul 11 12:40:54 2017
New Revision: 307696
URL: http://llvm.org/viewvc/llvm-project?rev=307696&view=rev
Log:
Use internal_strncpy to copy filename in linux procmaps
Cleaner than using a while loop to copy the string character by character.
Reviewers: alekseyshl, glider
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D35136
Modified:
compiler-rt/trunk/lib/sanitizer_common/sanitizer_procmaps_linux.cc
Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_procmaps_linux.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_procmaps_linux.cc?rev=307696&r1=307695&r2=307696&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_procmaps_linux.cc (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_procmaps_linux.cc Tue Jul 11 12:40:54 2017
@@ -62,13 +62,12 @@ bool MemoryMappingLayout::Next(MemoryMap
while (current_ < next_line && *current_ == ' ')
current_++;
// Fill in the filename.
- uptr i = 0;
- while (current_ < next_line) {
- if (segment->filename && i < segment->filename_size - 1)
- segment->filename[i++] = *current_;
- current_++;
+ if (segment->filename) {
+ uptr len = Min((uptr)(next_line - current_), segment->filename_size - 1);
+ internal_strncpy(segment->filename, current_, len);
+ segment->filename[len] = 0;
}
- if (segment->filename && i < segment->filename_size) segment->filename[i] = 0;
+
current_ = next_line + 1;
return true;
}
More information about the llvm-commits
mailing list