mirror of
https://github.com/Evolution-X/hardware_interfaces
synced 2026-02-01 16:50:18 +00:00
Merge "Removed unsafe use of hidl_vec<>.setToExternal"
am: 91a01c5cfc
Change-Id: Iea06598d45b23d6038aeb6ee76ef9d19621a6152
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user