Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit cc243999 authored by David Anderson's avatar David Anderson Committed by Automerger Merge Worker
Browse files

libdm: Redact keys from dm-crypt targets when calling GetTable. am: c434d801...

libdm: Redact keys from dm-crypt targets when calling GetTable. am: c434d801 am: 8dce05a1 am: 47bfad8f am: 5d784be3

Original change: https://googleplex-android-review.googlesource.com/c/platform/system/core/+/29655996



Change-Id: I4f45209eeeecedd59301deca9f28fac75d3362cc
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents 6ea147d6 5d784be3
Loading
Loading
Loading
Loading
+14 −0
Original line number Diff line number Diff line
@@ -512,6 +512,17 @@ bool DeviceMapper::GetTableInfo(const std::string& name, std::vector<TargetInfo>
    return GetTable(name, DM_STATUS_TABLE_FLAG, table);
}

void RedactTableInfo(const struct dm_target_spec& spec, std::string* data) {
    if (DeviceMapper::GetTargetType(spec) == "crypt") {
        auto parts = android::base::Split(*data, " ");
        if (parts.size() < 2) {
            return;
        }
        parts[1] = "redacted";
        *data = android::base::Join(parts, " ");
    }
}

// private methods of DeviceMapper
bool DeviceMapper::GetTable(const std::string& name, uint32_t flags,
                            std::vector<TargetInfo>* table) {
@@ -550,6 +561,9 @@ bool DeviceMapper::GetTable(const std::string& name, uint32_t flags,
            // Note: we use c_str() to eliminate any extra trailing 0s.
            data = std::string(&buffer[data_offset], next_cursor - data_offset).c_str();
        }
        if (flags & DM_STATUS_TABLE_FLAG) {
            RedactTableInfo(*spec, &data);
        }
        table->emplace_back(*spec, data);
        cursor = next_cursor;
    }