[Lldb-commits] [lldb] 603d5a8 - Fix out-of-bounds memory access in test
Adrian Prantl via lldb-commits
lldb-commits at lists.llvm.org
Fri Sep 2 18:14:38 PDT 2022
Author: Adrian Prantl
Date: 2022-09-02T18:14:23-07:00
New Revision: 603d5a8d632164038a869c200818c4cc238bb85a
URL: https://github.com/llvm/llvm-project/commit/603d5a8d632164038a869c200818c4cc238bb85a
DIFF: https://github.com/llvm/llvm-project/commit/603d5a8d632164038a869c200818c4cc238bb85a.diff
LOG: Fix out-of-bounds memory access in test
Added:
Modified:
lldb/test/API/functionalities/gdb_remote_client/TestDynamicLoaderDarwin.py
Removed:
################################################################################
diff --git a/lldb/test/API/functionalities/gdb_remote_client/TestDynamicLoaderDarwin.py b/lldb/test/API/functionalities/gdb_remote_client/TestDynamicLoaderDarwin.py
index 72f9c47890652..1580746c67378 100644
--- a/lldb/test/API/functionalities/gdb_remote_client/TestDynamicLoaderDarwin.py
+++ b/lldb/test/API/functionalities/gdb_remote_client/TestDynamicLoaderDarwin.py
@@ -88,7 +88,7 @@
}
"""
-arm64_binary = "cffaedfe0c000001000000000200000010000000e8020000850020000000000019000000480000005f5f504147455a45524f00000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000019000000e80000005f5f54455854000000000000000000000000000001000000004000000000000000000000000000000040000000000000050000000500000002000000000000005f5f74657874000000000000000000005f5f5445585400000000000000000000b03f0000010000000800000000000000b03f0000020000000000000000000000000400800000000000000000000000005f5f756e77696e645f696e666f0000005f5f5445585400000000000000000000b83f0000010000004800000000000000b83f00000200000000000000000000000000000000000000000000000000000019000000480000005f5f4c494e4b45444954000000000000004000000100000000400000000000000040000000000000b8010000000000000100000001000000000000000000000034000080100000000040000038000000330000801000000038400000300000000200000018000000704000000100000080400000180000000b000000500000000000000000000000000000000100000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e000000200000000c0000002f7573722f6c69622f64796c64000000000000001b00000018000000a9981092eb3632f4afd9957e769160d932000000200000000100000000000c0000050c000100000003000000000633032a0000001000000000000000000000002800008018000000b03f00000000000000000000000000000c00000038000000180000000200000001781f05000001002f7573722f6c69622f6c696253797374656d2e422e64796c696200000000000026000000100000006840000008000000290000001000000070400000000000001d00000010000000a04000001801" + '0'*16384
+arm64_binary = "cffaedfe0c000001000000000200000010000000e8020000850020000000000019000000480000005f5f504147455a45524f00000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000019000000e80000005f5f54455854000000000000000000000000000001000000004000000000000000000000000000000040000000000000050000000500000002000000000000005f5f74657874000000000000000000005f5f5445585400000000000000000000b03f0000010000000800000000000000b03f0000020000000000000000000000000400800000000000000000000000005f5f756e77696e645f696e666f0000005f5f5445585400000000000000000000b83f0000010000004800000000000000b83f00000200000000000000000000000000000000000000000000000000000019000000480000005f5f4c494e4b45444954000000000000004000000100000000400000000000000040000000000000b8010000000000000100000001000000000000000000000034000080100000000040000038000000330000801000000038400000300000000200000018000000704000000100000080400000180000000b000000500000000000000000000000000000000100000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e000000200000000c0000002f7573722f6c69622f64796c64000000000000001b00000018000000a9981092eb3632f4afd9957e769160d932000000200000000100000000000c0000050c000100000003000000000633032a0000001000000000000000000000002800008018000000b03f00000000000000000000000000000c00000038000000180000000200000001781f05000001002f7573722f6c69622f6c696253797374656d2e422e64796c696200000000000026000000100000006840000008000000290000001000000070400000000000001d00000010000000a04000001801"
class TestDynamicLoaderDarwin(GDBRemoteTestBase):
@@ -119,7 +119,15 @@ def vCont(self):
return "vCont;"
def readMemory(self, addr, length):
- return arm64_binary[addr-4369842176:length]
+ vm_addr = 4369842176
+ file_offset = addr - vm_addr
+ if file_offset < 0:
+ return None
+ # arm64_binary is just a hex-encoded (hence the 2*) Mach-O
+ # header, pad out the rest with NUL characters, it doesn't
+ # matter for this test.
+ memory = arm64_binary + '00'*(length-len(arm64_binary)<<1)
+ return memory[2*file_offset:]
def setBreakpoint(self, packet):
return ""
More information about the lldb-commits
mailing list