From: Krzysztof Jackiewicz Date: Fri, 19 Jun 2015 12:34:14 +0000 (+0200) Subject: CKM: Prevent exceptions in gc. Fix buffer comparison. X-Git-Tag: security-manager_5.5_testing~9^2~73 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=93538a726e11a9aa88cfb7e1c11103dc72034eab;p=platform%2Fcore%2Ftest%2Fsecurity-tests.git CKM: Prevent exceptions in gc. Fix buffer comparison. [Problem] Garbage collector destructor may throw exceptions. Buffers can be different even if sizes match. [Solution] Destructor protected with try catch. Buffer comparison fixed. [Verification] Run tests Change-Id: Iae33de10ee9e9b2bde6aa427a4f17b49eed6955e --- diff --git a/src/ckm/ckm-common.cpp b/src/ckm/ckm-common.cpp index 47b4012b..9b5cb77f 100644 --- a/src/ckm/ckm-common.cpp +++ b/src/ckm/ckm-common.cpp @@ -209,8 +209,12 @@ GarbageCollector::~GarbageCollector() { for(auto & item : m_garbage) { - ScopedAccessProvider ap(item.owner_label, item.owner_uid, item.owner_gid); - check_remove_allowed(item.item_alias.c_str()); + try { + ScopedAccessProvider ap(item.owner_label, item.owner_uid, item.owner_gid); + check_remove_allowed(item.item_alias.c_str()); + } catch (...) { + // prevent exceptions in destructor + } } } @@ -542,7 +546,7 @@ void assert_buffers_equal(const ckmc_raw_buffer_s b1, const ckmc_raw_buffer_s b2 RUNNER_ASSERT_MSG(b1.size == b2.size, "Buffer size differs: " << b1.size << "!=" << b2.size); RUNNER_ASSERT_MSG(0 == memcmp(b1.data, b2.data, b1.size), "Buffer contents differ"); } else { - RUNNER_ASSERT_MSG(b1.size != b2.size, "Buffer sizes equal: " << b1.size << "==" << b2.size); - RUNNER_ASSERT_MSG(0 != memcmp(b1.data, b2.data, b1.size), "Buffer contents are identical"); + RUNNER_ASSERT_MSG(b1.size != b2.size || 0 != memcmp(b1.data, b2.data, b1.size), + "Buffers should be different"); } }