Exploit databaseDownload repository ZIP
GH-cc64c111644d9f76a3f77b0cdaed584e
satheesh575555/system_bt_aosp_10_r33_cve-2021-0316
Sources for CVE-2021-0316
1 sourcePreferred order: Exploit-DB, Metasploit, then GitHub repositories by stars.
Repository files16
satheesh575555/system_bt_aosp_10_r33_cve-2021-0316Revision d291fc085ab3
- ↑..Parent directory
- hci/
- link_layer/
- test/
- Android.bp
- base_packet_builder.h
- counted_builder.cc
- counted_builder.h
- iterator.cc
- iterator.h
- packet_builder.h
- packet_view.cc
- packet_view.h
- raw_builder.cc
- raw_builder.h
- view.cc
- view.h
Files from this repository share one source choice. Supporting files may cover other vulnerabilities.
vendor_libs/test_vendor_lib/packets/packet_view.cc
Text · 3,358 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 "packet_view.h"
#include <algorithm>
#include <base/logging.h>
namespace test_vendor_lib {
namespace packets {
template <bool little_endian>
PacketView<little_endian>::PacketView(const std::forward_list<class View> fragments)
: fragments_(fragments), length_(0) {
for (auto fragment : fragments_) {
length_ += fragment.size();
}
}
template <bool little_endian>
PacketView<little_endian>::PacketView(std::shared_ptr<std::vector<uint8_t>> packet)
: fragments_({View(packet, 0, packet->size())}), length_(packet->size()) {}
template <bool little_endian>
Iterator<little_endian> PacketView<little_endian>::begin() const {
return Iterator<little_endian>(this->fragments_, 0);
}
template <bool little_endian>
Iterator<little_endian> PacketView<little_endian>::end() const {
return Iterator<little_endian>(this->fragments_, size());
}
template <bool little_endian>
uint8_t PacketView<little_endian>::operator[](size_t index) const {
return at(index);
}
template <bool little_endian>
uint8_t PacketView<little_endian>::at(size_t index) const {
CHECK(index < length_) << "Index " << index << " out of bounds";
for (const auto& fragment : fragments_) {
if (index < fragment.size()) {
return fragment[index];
}
index -= fragment.size();
}
CHECK(false) << "Out of fragments searching for Index " << index;
return 0;
}
template <bool little_endian>
size_t PacketView<little_endian>::size() const {
return length_;
}
template <bool little_endian>
std::forward_list<View> PacketView<little_endian>::SubViewList(size_t begin, size_t end) const {
CHECK(begin <= end) << "Begin " << begin << " is past end";
CHECK(end <= length_) << "End " << end << " is too large";
std::forward_list<View> view_list;
std::forward_list<View>::iterator it = view_list.before_begin();
size_t length = end - begin;
for (const auto& fragment : fragments_) {
if (begin >= fragment.size()) {
begin -= fragment.size();
} else {
View view(fragment, begin, begin + std::min(length, fragment.size() - begin));
length -= view.size();
it = view_list.insert_after(it, view);
begin = 0;
}
}
return view_list;
}
template <bool little_endian>
PacketView<true> PacketView<little_endian>::SubViewLittleEndian(size_t begin, size_t end) const {
return PacketView<true>(SubViewList(begin, end));
}
template <bool little_endian>
PacketView<false> PacketView<little_endian>::SubViewBigEndian(size_t begin, size_t end) const {
return PacketView<false>(SubViewList(begin, end));
}
// Explicit instantiations for both types of PacketViews.
template class PacketView<true>;
template class PacketView<false>;
} // namespace packets
} // namespace test_vendor_lib