[Lldb-commits] [lldb] r170242 - /lldb/trunk/source/Plugins/Process/Linux/ProcessMonitor.cpp
Daniel Malea
daniel.malea at intel.com
Fri Dec 14 13:07:07 PST 2012
Author: dmalea
Date: Fri Dec 14 15:07:07 2012
New Revision: 170242
URL: http://llvm.org/viewvc/llvm-project?rev=170242&view=rev
Log:
Avoid possible overflow when reading inferior memory (and logging is enabled)
Patch by Matt Kopec!
Modified:
lldb/trunk/source/Plugins/Process/Linux/ProcessMonitor.cpp
Modified: lldb/trunk/source/Plugins/Process/Linux/ProcessMonitor.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Linux/ProcessMonitor.cpp?rev=170242&r1=170241&r2=170242&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Linux/ProcessMonitor.cpp (original)
+++ lldb/trunk/source/Plugins/Process/Linux/ProcessMonitor.cpp Fri Dec 14 15:07:07 2012
@@ -200,8 +200,6 @@
remainder = remainder > word_size ? word_size : remainder;
// Copy the data into our buffer
- if (log)
- memset(dst, 0, sizeof(unsigned char));
for (unsigned i = 0; i < remainder; ++i)
dst[i] = ((data >> i*8) & 0xFF);
@@ -209,8 +207,14 @@
(log->GetMask().Test(POSIX_LOG_MEMORY_DATA_LONG) ||
(log->GetMask().Test(POSIX_LOG_MEMORY_DATA_SHORT) &&
size <= POSIX_LOG_MEMORY_SHORT_BYTES)))
- log->Printf ("ProcessMonitor::%s() [%p]:0x%lx (0x%lx)", __FUNCTION__,
- (void*)vm_addr, *(unsigned long*)dst, (unsigned long)data);
+ {
+ uintptr_t print_dst = 0;
+ // Format bytes from data by moving into print_dst for log output
+ for (unsigned i = 0; i < remainder; ++i)
+ print_dst |= (((data >> i*8) & 0xFF) << i*8);
+ log->Printf ("ProcessMonitor::%s() [%p]:0x%lx (0x%lx)", __FUNCTION__,
+ (void*)vm_addr, print_dst, (unsigned long)data);
+ }
vm_addr += word_size;
dst += word_size;
More information about the lldb-commits
mailing list