diff options
author | Janis Danisevskis <jdanis@google.com> | 2018-11-15 05:55:17 -0800 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2018-11-15 05:55:17 -0800 |
commit | 679515f5c7f61d059040c20fd1496f263c09555f (patch) | |
tree | 01458680403d2f25c553878245e3d1d76b0d1418 /keymaster | |
parent | b4c967c1200f22939352f16142af4248eb0308db (diff) | |
parent | 6ad8d58110230672e7a74c428f6cfbc3ce7e0eb7 (diff) | |
download | android_hardware_interfaces-679515f5c7f61d059040c20fd1496f263c09555f.tar.gz android_hardware_interfaces-679515f5c7f61d059040c20fd1496f263c09555f.tar.bz2 android_hardware_interfaces-679515f5c7f61d059040c20fd1496f263c09555f.zip |
Merge "Removed unsafe use of hidl_vec<>.setToExternal" am: 91a01c5cfc am: 7b5b901b62
am: 6ad8d58110
Change-Id: Ia00aa483e97481b350f0e6f9e5138d46c84e7755
Diffstat (limited to 'keymaster')
3 files changed, 13 insertions, 21 deletions
diff --git a/keymaster/3.0/vts/functional/authorization_set.h b/keymaster/3.0/vts/functional/authorization_set.h index 5f92d816a..60b00e432 100644 --- a/keymaster/3.0/vts/functional/authorization_set.h +++ b/keymaster/3.0/vts/functional/authorization_set.h @@ -201,7 +201,7 @@ class AuthorizationSet { void push_back(TypedTag<TagType::BYTES, tag> ttag, const uint8_t* data, size_t data_length) { hidl_vec<uint8_t> new_blob; new_blob.setToExternal(const_cast<uint8_t*>(data), data_length); - push_back(ttag, std::move(new_blob)); + push_back(ttag, new_blob); } /** @@ -225,8 +225,7 @@ class AuthorizationSet { } hidl_vec<KeyParameter> hidl_data() const { - hidl_vec<KeyParameter> result; - result.setToExternal(const_cast<KeyParameter*>(data()), size()); + hidl_vec<KeyParameter> result(begin(), end()); return result; } @@ -252,7 +251,7 @@ class AuthorizationSetBuilder : public AuthorizationSet { size_t data_length) { hidl_vec<uint8_t> new_blob; new_blob.setToExternal(const_cast<uint8_t*>(data), data_length); - push_back(ttag, std::move(new_blob)); + push_back(ttag, new_blob); return *this; } diff --git a/keymaster/4.0/support/include/keymasterV4_0/authorization_set.h b/keymaster/4.0/support/include/keymasterV4_0/authorization_set.h index ac96c863a..a131423f6 100644 --- a/keymaster/4.0/support/include/keymasterV4_0/authorization_set.h +++ b/keymaster/4.0/support/include/keymasterV4_0/authorization_set.h @@ -214,9 +214,8 @@ class AuthorizationSet { } } - const hidl_vec<KeyParameter> hidl_data() const { - hidl_vec<KeyParameter> result; - result.setToExternal(const_cast<KeyParameter*>(data()), size()); + hidl_vec<KeyParameter> hidl_data() const { + hidl_vec<KeyParameter> result(begin(), end()); return result; } @@ -242,7 +241,7 @@ class AuthorizationSetBuilder : public AuthorizationSet { size_t data_length) { hidl_vec<uint8_t> new_blob; new_blob.setToExternal(const_cast<uint8_t*>(data), data_length); - push_back(ttag, std::move(new_blob)); + push_back(ttag, new_blob); return *this; } diff --git a/keymaster/4.0/support/include/keymasterV4_0/keymaster_utils.h b/keymaster/4.0/support/include/keymasterV4_0/keymaster_utils.h index 90a0f1b29..5e5ae8d0e 100644 --- a/keymaster/4.0/support/include/keymasterV4_0/keymaster_utils.h +++ b/keymaster/4.0/support/include/keymasterV4_0/keymaster_utils.h @@ -33,25 +33,19 @@ bool operator<(const HmacSharingParameters& a, const HmacSharingParameters& b); namespace support { -inline static hidl_vec<uint8_t> blob2hidlVec(const uint8_t* data, const size_t length, - bool inPlace = true) { - hidl_vec<uint8_t> result; - result.setToExternal(const_cast<unsigned char*>(data), length, !inPlace); +inline static hidl_vec<uint8_t> blob2hidlVec(const uint8_t* data, const size_t length) { + hidl_vec<uint8_t> result(data, data + length); return result; } -inline static hidl_vec<uint8_t> blob2hidlVec(const std::string& value, bool inPlace = true) { - hidl_vec<uint8_t> result; - result.setToExternal(const_cast<uint8_t*>(reinterpret_cast<const uint8_t*>(value.data())), - static_cast<size_t>(value.size()), !inPlace); +inline static hidl_vec<uint8_t> blob2hidlVec(const std::string& value) { + hidl_vec<uint8_t> result(reinterpret_cast<const uint8_t*>(value.data()), + reinterpret_cast<const uint8_t*>(value.data()) + value.size()); return result; } -inline static hidl_vec<uint8_t> blob2hidlVec(const std::vector<uint8_t>& blob, - bool inPlace = true) { - hidl_vec<uint8_t> result; - result.setToExternal(const_cast<uint8_t*>(blob.data()), static_cast<size_t>(blob.size()), - !inPlace); +inline static hidl_vec<uint8_t> blob2hidlVec(const std::vector<uint8_t>& blob) { + hidl_vec<uint8_t> result(blob.data(), blob.data() + static_cast<size_t>(blob.size())); return result; } |