diff options
| author | Daniel Malea <daniel.malea@intel.com> | 2012-12-14 21:07:07 +0000 |
|---|---|---|
| committer | Daniel Malea <daniel.malea@intel.com> | 2012-12-14 21:07:07 +0000 |
| commit | c63dddd8007bbdf58ddfc649e74c65aa3bf7254d (patch) | |
| tree | f8d09fff36e3f9d80bf00f2992e3ca84c3179465 /lldb/source/Plugins/Process/Linux/ProcessMonitor.cpp | |
| parent | 7b6376ba574af30df67906ef1ecec054db5dd055 (diff) | |
| download | bcm5719-llvm-c63dddd8007bbdf58ddfc649e74c65aa3bf7254d.tar.gz bcm5719-llvm-c63dddd8007bbdf58ddfc649e74c65aa3bf7254d.zip | |
Avoid possible overflow when reading inferior memory (and logging is enabled)
Patch by Matt Kopec!
llvm-svn: 170242
Diffstat (limited to 'lldb/source/Plugins/Process/Linux/ProcessMonitor.cpp')
| -rw-r--r-- | lldb/source/Plugins/Process/Linux/ProcessMonitor.cpp | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/lldb/source/Plugins/Process/Linux/ProcessMonitor.cpp b/lldb/source/Plugins/Process/Linux/ProcessMonitor.cpp index 483834045cc..25794e80737 100644 --- a/lldb/source/Plugins/Process/Linux/ProcessMonitor.cpp +++ b/lldb/source/Plugins/Process/Linux/ProcessMonitor.cpp @@ -200,8 +200,6 @@ DoReadMemory(lldb::pid_t pid, 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 @@ DoReadMemory(lldb::pid_t pid, (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; |

