[Lldb-commits] [PATCH] D15738: [LLDB] Fix Read/Write memory to be compatible with both endians
Tamas Berghammer via lldb-commits
lldb-commits at lists.llvm.org
Wed Dec 23 02:57:42 PST 2015
tberghammer added a subscriber: tberghammer.
tberghammer requested changes to this revision.
tberghammer added a reviewer: tberghammer.
This revision now requires changes to proceed.
================
Comment at: source/Plugins/Process/Linux/NativeProcessLinux.cpp:2549-2550
@@ -2548,6 +2548,4 @@
// Copy the data into our buffer
- for (unsigned i = 0; i < remainder; ++i)
- dst[i] = ((data >> i*8) & 0xFF);
-
+ *((long*)(dst)) = data;
if (log && ProcessPOSIXLog::AtTopNestLevel() &&
----------------
This will be a buffer overrun if "size % sizeof(long) != 0" (and also violating strict aliasing). I suggest to use memcpy instead what fixes both of these issue.
================
Comment at: source/Plugins/Process/Linux/NativeProcessLinux.cpp:2601
@@ -2602,4 +2600,3 @@
unsigned long data = 0;
- for (unsigned i = 0; i < k_ptrace_word_size; ++i)
- data |= (unsigned long)src[i] << i*8;
+ data = *((unsigned long*)src);
----------------
Same here
Repository:
rL LLVM
http://reviews.llvm.org/D15738
More information about the lldb-commits
mailing list