From 1a17e18f176ba073321732dc03b26396dbf5bcf4 Mon Sep 17 00:00:00 2001 From: David Anderson Date: Thu, 27 Feb 2020 13:31:40 -0800 Subject: [PATCH] libdm: Make static std::string inline for DmTargetDefaultKey. Bug: 149942628 Test: snapshotctl w/ ASAN build Change-Id: I0f40b1f29e46bc9afaf19d8c21d62280e2c01074 --- fs_mgr/libdm/dm_target.cpp | 4 +--- fs_mgr/libdm/include/libdm/dm_target.h | 5 +++-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/fs_mgr/libdm/dm_target.cpp b/fs_mgr/libdm/dm_target.cpp index 646178891..29b103282 100644 --- a/fs_mgr/libdm/dm_target.cpp +++ b/fs_mgr/libdm/dm_target.cpp @@ -243,12 +243,10 @@ std::string DmTargetCrypt::GetParameterString() const { return android::base::Join(argv, " "); } -const std::string DmTargetDefaultKey::name_ = "default-key"; - bool DmTargetDefaultKey::IsLegacy(bool* result) { DeviceMapper& dm = DeviceMapper::Instance(); DmTargetTypeInfo info; - if (!dm.GetTargetByName(name_, &info)) return false; + if (!dm.GetTargetByName(kName, &info)) return false; // dm-default-key was modified to be like dm-crypt with version 2 *result = !info.IsAtLeast(2, 0, 0); return true; diff --git a/fs_mgr/libdm/include/libdm/dm_target.h b/fs_mgr/libdm/include/libdm/dm_target.h index d2e50d321..050d0b645 100644 --- a/fs_mgr/libdm/include/libdm/dm_target.h +++ b/fs_mgr/libdm/include/libdm/dm_target.h @@ -287,7 +287,7 @@ class DmTargetDefaultKey final : public DmTarget { blockdev_(blockdev), start_sector_(start_sector) {} - std::string name() const override { return name_; } + std::string name() const override { return kName; } bool Valid() const override; std::string GetParameterString() const override; static bool IsLegacy(bool* result); @@ -296,7 +296,8 @@ class DmTargetDefaultKey final : public DmTarget { void SetWrappedKeyV0() { is_hw_wrapped_ = true; } private: - static const std::string name_; + inline static const std::string kName = "default-key"; + std::string cipher_; std::string key_; std::string blockdev_;