Merge "adbd: Fix check against valid payload size" am: 596f3b5384 am: 9a80494702 am: aeb5be6f45

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

Change-Id: I8edbc03fa678a549cf037699b7ab2f6d953b4a44
This commit is contained in:
Josh Gao 2020-09-19 07:04:39 +00:00 committed by Automerger Merge Worker
commit 74246334dd

View file

@ -584,12 +584,11 @@ struct UsbFfsConnection : public Connection {
incoming_header_ = msg;
} else {
size_t bytes_left = incoming_header_->data_length - incoming_payload_.size();
Block payload = std::move(block->payload);
if (block->payload.size() > bytes_left) {
HandleError("received too many bytes while waiting for payload");
return false;
}
incoming_payload_.append(std::move(payload));
incoming_payload_.append(std::move(block->payload));
}
if (incoming_header_->data_length == incoming_payload_.size()) {