summaryrefslogtreecommitdiff
path: root/libunwindstack/tests/MemoryLocalTest.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'libunwindstack/tests/MemoryLocalTest.cpp')
-rw-r--r--libunwindstack/tests/MemoryLocalTest.cpp27
1 files changed, 9 insertions, 18 deletions
diff --git a/libunwindstack/tests/MemoryLocalTest.cpp b/libunwindstack/tests/MemoryLocalTest.cpp
index 0ba5f1c37..ab999dafc 100644
--- a/libunwindstack/tests/MemoryLocalTest.cpp
+++ b/libunwindstack/tests/MemoryLocalTest.cpp
@@ -47,29 +47,20 @@ TEST(MemoryLocalTest, read) {
}
}
-TEST(MemoryLocalTest, read_string) {
- std::string name("string_in_memory");
-
+TEST(MemoryLocalTest, read_illegal) {
MemoryLocal local;
- std::vector<uint8_t> dst(1024);
- std::string dst_name;
- ASSERT_TRUE(local.ReadString(reinterpret_cast<uint64_t>(name.c_str()), &dst_name));
- ASSERT_EQ("string_in_memory", dst_name);
-
- ASSERT_TRUE(local.ReadString(reinterpret_cast<uint64_t>(&name[7]), &dst_name));
- ASSERT_EQ("in_memory", dst_name);
-
- ASSERT_TRUE(local.ReadString(reinterpret_cast<uint64_t>(&name[7]), &dst_name, 10));
- ASSERT_EQ("in_memory", dst_name);
-
- ASSERT_FALSE(local.ReadString(reinterpret_cast<uint64_t>(&name[7]), &dst_name, 9));
+ std::vector<uint8_t> dst(100);
+ ASSERT_FALSE(local.Read(0, dst.data(), 1));
+ ASSERT_FALSE(local.Read(0, dst.data(), 100));
}
-TEST(MemoryLocalTest, read_illegal) {
+TEST(MemoryLocalTest, read_overflow) {
MemoryLocal local;
+ // On 32 bit this test doesn't necessarily cause an overflow. The 64 bit
+ // version will always go through the overflow check.
std::vector<uint8_t> dst(100);
- ASSERT_FALSE(local.Read(0, dst.data(), 1));
- ASSERT_FALSE(local.Read(0, dst.data(), 100));
+ uint64_t value;
+ ASSERT_FALSE(local.Read(reinterpret_cast<uint64_t>(&value), dst.data(), SIZE_MAX));
}