diff options
author | Andrew Scull <ascull@google.com> | 2017-11-22 11:42:49 +0000 |
---|---|---|
committer | Andrew Scull <ascull@google.com> | 2017-11-22 11:42:49 +0000 |
commit | 261fc1dd9b93430f7b3b45e4980071c28b8b56ed (patch) | |
tree | 99f2a8a31a2ee9c4b747948ad651f1ffa611a697 /citadel | |
parent | c4301a3777ac831ba91316fa9d30ea96a93017b4 (diff) | |
download | android-261fc1dd9b93430f7b3b45e4980071c28b8b56ed.tar.gz |
citadeld proxy: pass correct response buffer size
Binder does not pass the capacity of a vector so the size needs to be
set before making the binder call.
Change-Id: I742db281dde93cc4179b2fea0df09c4a8474957f
Diffstat (limited to 'citadel')
-rw-r--r-- | citadel/citadeld/CitadeldProxyClient.cpp | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/citadel/citadeld/CitadeldProxyClient.cpp b/citadel/citadeld/CitadeldProxyClient.cpp index e88e824..a5d0378 100644 --- a/citadel/citadeld/CitadeldProxyClient.cpp +++ b/citadel/citadeld/CitadeldProxyClient.cpp @@ -53,17 +53,19 @@ bool CitadeldProxyClient::IsOpen() const { uint32_t CitadeldProxyClient::CallApp(uint32_t appId, uint16_t arg, const std::vector<uint8_t>& request, - std::vector<uint8_t>* response) { - // Can't pass a nullptr over binder so convert to an empty vector - std::vector<uint8_t> empty; - if (response == nullptr) { - response = ∅ - } + std::vector<uint8_t>* _response) { + // Binder doesn't pass a nullptr or the capacity so resolve the response + // buffer size before making the call. The response vector may be the same + // as the request vector so the response cannot be directly resized. + std::vector<uint8_t> response(_response == nullptr ? 0 : _response->capacity()); uint32_t appStatus; - Status status = _citadeld->callApp(appId, arg, request, response, + Status status = _citadeld->callApp(appId, arg, request, &response, reinterpret_cast<int32_t*>(&appStatus)); if (status.isOk()) { + if (_response != nullptr) { + *_response = std::move(response); + } return appStatus; } LOG(ERROR) << "Failed to call app via citadeld: " << status.toString8(); |