]> git.apps.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:56:20 +0000 (17:56 +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 5ab2bf12430b21df36fa91b694953bd8d2245688..5f6e805f83f5cbd03f00c66cd545ae7584ed038b 100644 (file)
@@ -666,6 +666,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