Exploit databaseDownload repository ZIP
GH-51374c4970287cfc6dca6abc44f73866
satheesh575555/system_bt_aosp10-r33_cve-2021-0397
Sources for CVE-2021-0397
1 sourcePreferred order: Exploit-DB, Metasploit, then GitHub repositories by stars.
Repository files21
satheesh575555/system_bt_aosp10-r33_cve-2021-0397Revision 0e5f2721b71b
- ↑..Parent directory
- test/
- acl_packet_builder.cc
- acl_packet_builder.h
- acl_packet_view.cc
- acl_packet_view.h
- command_packet_builder.cc
- command_packet_builder.h
- command_packet_view.cc
- command_packet_view.h
- event_packet_builder.cc
- event_packet_builder.h
- event_payload_builder.cc
- event_payload_builder.h
- hci_packet_builder.cc
- hci_packet_builder.h
- le_meta_event_builder.cc
- le_meta_event_builder.h
- sco_packet_builder.cc
- sco_packet_builder.h
- sco_packet_view.cc
- sco_packet_view.h
Files from this repository share one source choice. Supporting files may cover other vulnerabilities.
vendor_libs/test_vendor_lib/packets/hci/event_payload_builder.cc
Text · 2,663 bytes/*
* Copyright 2018 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "event_payload_builder.h"
#include <base/logging.h>
#include <algorithm>
using std::vector;
namespace test_vendor_lib {
namespace packets {
EventPayloadBuilder::EventPayloadBuilder(size_t max_bytes) : max_bytes_(max_bytes) {}
bool EventPayloadBuilder::AddPayloadOctets(size_t octets, const vector<uint8_t>& bytes) {
if (payload_.size() + octets > max_bytes_) return false;
if (octets != bytes.size()) return false;
payload_.insert(payload_.end(), bytes.begin(), bytes.end());
return true;
}
bool EventPayloadBuilder::AddPayloadOctets(const vector<uint8_t>& bytes) {
return AddPayloadOctets(bytes.size(), bytes);
}
bool EventPayloadBuilder::AddPayloadOctets(size_t octets, uint64_t value) {
vector<uint8_t> val_vector;
uint64_t v = value;
if (octets > sizeof(uint64_t)) return false;
for (size_t i = 0; i < octets; i++) {
val_vector.push_back(v & 0xff);
v = v >> 8;
}
if (v != 0) return false;
return AddPayloadOctets(octets, val_vector);
}
bool EventPayloadBuilder::AddPayloadAddress(const Address& address) {
if (payload_.size() + Address::kLength > max_bytes_) return false;
for (size_t i = 0; i < Address::kLength; i++) {
payload_.push_back(address.address[i]);
}
return true;
}
bool EventPayloadBuilder::AddPayloadOctets1(uint8_t value) {
return AddPayloadOctets(1, value);
}
bool EventPayloadBuilder::AddPayloadOctets2(uint16_t value) {
return AddPayloadOctets(2, value);
}
bool EventPayloadBuilder::AddPayloadOctets3(uint32_t value) {
return AddPayloadOctets(3, value);
}
bool EventPayloadBuilder::AddPayloadOctets4(uint32_t value) {
return AddPayloadOctets(4, value);
}
bool EventPayloadBuilder::AddPayloadOctets6(uint64_t value) {
return AddPayloadOctets(6, value);
}
bool EventPayloadBuilder::AddPayloadOctets8(uint64_t value) {
return AddPayloadOctets(8, value);
}
bool EventPayloadBuilder::CanAddPayloadOctets(size_t num_bytes) const {
return payload_.size() + num_bytes <= max_bytes_;
}
} // namespace packets
} // namespace test_vendor_lib