]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
test_rgw_crypto: add invalid ranges beyond obj boundary
authorAbhishek Lekshmanan <abhishek@suse.com>
Wed, 27 Mar 2019 12:45:27 +0000 (13:45 +0100)
committerAbhishek Lekshmanan <abhishek@suse.com>
Mon, 1 Apr 2019 15:58:27 +0000 (17:58 +0200)
This is just to assert we're not doing an invalid memory access

Signed-off-by: Abhishek Lekshmanan <abhishek@suse.com>
(cherry picked from commit b34a00de0f6ecea6d97fd80f65d2a2dca0876e6e)

src/test/rgw/test_rgw_crypto.cc

index 9a13acb8aaba2ce0fb46d40302d45976ccee9032..7253771a9d326a6132ed065e383963e129879752 100644 (file)
@@ -673,6 +673,28 @@ TEST(TestRGWCrypto, check_RGWGetObj_BlockDecrypt_fixup_non_aligned)
 
 }
 
+TEST(TestRGWCrypto, check_RGWGetObj_BlockDecrypt_fixup_invalid_ranges)
+{
+
+  ut_get_sink get_sink;
+  auto nonecrypt = std::make_unique<BlockCryptNone>(4096);
+  TestRGWGetObj_BlockDecrypt decrypt(g_ceph_context, &get_sink,
+                                    std::move(nonecrypt));
+
+  decrypt.set_parts_len(create_mp_parts(obj_size, part_size));
+
+  // the ranges below would be mostly unreachable in current code as rgw
+  // would've returned a 411 before reaching, but we're just doing this to make
+  // sure we don't have invalid access
+  ASSERT_EQ(fixup_range(&decrypt, obj_size - 1, obj_size + 100),
+           range_t(obj_size - 4096, obj_size + 4095));
+  ASSERT_EQ(fixup_range(&decrypt, obj_size, obj_size + 1),
+           range_t(obj_size, obj_size + 4095));
+  ASSERT_EQ(fixup_range(&decrypt, obj_size+1, obj_size + 100),
+           range_t(obj_size, obj_size + 4095));
+
+}
+
 TEST(TestRGWCrypto, verify_RGWPutObj_BlockEncrypt_chunks)
 {
   //create some input for encryption