Make use of base::fixed_extent<>.

Bug: none
Change-Id: Ia07ebfdd5927e545e3c19b98dc545e7f75ef46ac
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/6091638
Commit-Queue: Peter Kasting <pkasting@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
This commit is contained in:
Peter Kasting 2024-12-12 12:36:31 -08:00 committed by Crashpad LUCI CQ
parent 4826f5a3b0
commit 6419a2e697

View File

@ -60,12 +60,12 @@ void UUID::InitializeToZero() {
void UUID::InitializeFromBytes(const uint8_t* bytes_ptr) {
// TODO(crbug.com/40284755): This span construction is unsound. The caller
// should provide a span instead of an unbounded pointer.
base::span<const uint8_t, sizeof(UUID)> bytes(bytes_ptr, sizeof(UUID));
base::span bytes(bytes_ptr, base::fixed_extent<sizeof(UUID)>());
data_1 = base::numerics::U32FromBigEndian(bytes.subspan<0u, 4u>());
data_2 = base::numerics::U16FromBigEndian(bytes.subspan<4u, 2u>());
data_3 = base::numerics::U16FromBigEndian(bytes.subspan<6u, 2u>());
std::ranges::copy(bytes.subspan<8u, 2u>(), data_4);
std::ranges::copy(bytes.subspan<10u, 6u>(), data_5);
std::ranges::copy(bytes.subspan<8, 2>(), data_4);
std::ranges::copy(bytes.subspan<10, 6>(), data_5);
}
bool UUID::InitializeFromString(const base::StringPiece& string) {