mirror of
https://github.com/chromium/crashpad.git
synced 2024-12-25 22:30:49 +08:00
Use the span version of RandBytes
Some unique_ptr<T[]> are also changed to HeapArray in order to facilitate the change. Bug: chromuim: 40284755 Change-Id: I30b9d55ff81f23c63ad4958786740f67ee612024 Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/5512569 Reviewed-by: Mark Mentovai <mark@chromium.org> Commit-Queue: danakj <danakj@chromium.org>
This commit is contained in:
parent
bff9873242
commit
84c87739e8
2
DEPS
2
DEPS
@ -47,7 +47,7 @@ deps = {
|
||||
'9719c1e1e676814c456b55f5f070eabad6709d31',
|
||||
'crashpad/third_party/mini_chromium/mini_chromium':
|
||||
Var('chromium_git') + '/chromium/mini_chromium@' +
|
||||
'8b56c7718412ec7d12d05522f7af0cbb787cbb00',
|
||||
'f3bf9dce1e62c8ab8c15130c9829255879cd0e4d',
|
||||
'crashpad/third_party/libfuzzer/src':
|
||||
Var('chromium_git') + '/chromium/llvm-project/compiler-rt/lib/fuzzer.git@' +
|
||||
'fda403cf93ecb8792cb1d061564d89a6553ca020',
|
||||
|
@ -116,7 +116,7 @@ bool UUID::InitializeWithNew() {
|
||||
// from libuuid is not available everywhere.
|
||||
// On Windows, do not use UuidCreate() to avoid a dependency on rpcrt4, so
|
||||
// that this function is usable early in DllMain().
|
||||
base::RandBytes(this, sizeof(*this));
|
||||
base::RandBytes(base::byte_span_from_ref(*this));
|
||||
|
||||
// Set six bits per RFC 4122 §4.4 to identify this as a pseudo-random UUID.
|
||||
data_3 = (4 << 12) | (data_3 & 0x0fff); // §4.1.3
|
||||
|
@ -20,6 +20,7 @@
|
||||
#include <iterator>
|
||||
#include <sstream>
|
||||
|
||||
#include "base/containers/heap_array.h"
|
||||
#include "base/rand_util.h"
|
||||
#include "base/strings/stringprintf.h"
|
||||
#include "gtest/gtest.h"
|
||||
@ -71,17 +72,16 @@ class Base94OutputStreamTest : public testing::Test {
|
||||
}
|
||||
|
||||
const uint8_t* BuildDeterministicInput(size_t size) {
|
||||
deterministic_input_ = std::make_unique<uint8_t[]>(size);
|
||||
uint8_t* deterministic_input_base = deterministic_input_.get();
|
||||
deterministic_input_ = base::HeapArray<uint8_t>::WithSize(size);
|
||||
while (size-- > 0)
|
||||
deterministic_input_base[size] = static_cast<uint8_t>(size);
|
||||
return deterministic_input_base;
|
||||
deterministic_input_[size] = static_cast<uint8_t>(size);
|
||||
return deterministic_input_.data();
|
||||
}
|
||||
|
||||
const uint8_t* BuildRandomInput(size_t size) {
|
||||
input_ = std::make_unique<uint8_t[]>(size);
|
||||
base::RandBytes(&input_[0], size);
|
||||
return input_.get();
|
||||
input_ = base::HeapArray<uint8_t>::Uninit(size);
|
||||
base::RandBytes(input_);
|
||||
return input_.data();
|
||||
}
|
||||
|
||||
Base94OutputStream* round_trip() const { return round_trip_.get(); }
|
||||
@ -127,8 +127,8 @@ class Base94OutputStreamTest : public testing::Test {
|
||||
TestOutputStream* encode_test_output_stream_;
|
||||
TestOutputStream* decode_test_output_stream_;
|
||||
TestOutputStream* round_trip_test_output_stream_;
|
||||
std::unique_ptr<uint8_t[]> input_;
|
||||
std::unique_ptr<uint8_t[]> deterministic_input_;
|
||||
base::HeapArray<uint8_t> input_;
|
||||
base::HeapArray<uint8_t> deterministic_input_;
|
||||
};
|
||||
|
||||
TEST_F(Base94OutputStreamTest, Encoding) {
|
||||
|
@ -19,6 +19,7 @@
|
||||
#include <algorithm>
|
||||
#include <iterator>
|
||||
|
||||
#include "base/containers/heap_array.h"
|
||||
#include "base/rand_util.h"
|
||||
#include "base/strings/stringprintf.h"
|
||||
#include "gtest/gtest.h"
|
||||
@ -46,17 +47,16 @@ class ZlibOutputStreamTest : public testing::Test {
|
||||
ZlibOutputStreamTest& operator=(const ZlibOutputStreamTest&) = delete;
|
||||
|
||||
const uint8_t* BuildDeterministicInput(size_t size) {
|
||||
deterministic_input_ = std::make_unique<uint8_t[]>(size);
|
||||
uint8_t* deterministic_input_base = deterministic_input_.get();
|
||||
deterministic_input_ = base::HeapArray<uint8_t>::WithSize(size);
|
||||
while (size-- > 0)
|
||||
deterministic_input_base[size] = static_cast<uint8_t>(size);
|
||||
return deterministic_input_base;
|
||||
deterministic_input_[size] = static_cast<uint8_t>(size);
|
||||
return deterministic_input_.data();
|
||||
}
|
||||
|
||||
const uint8_t* BuildRandomInput(size_t size) {
|
||||
input_ = std::make_unique<uint8_t[]>(size);
|
||||
base::RandBytes(&input_[0], size);
|
||||
return input_.get();
|
||||
input_ = base::HeapArray<uint8_t>::Uninit(size);
|
||||
base::RandBytes(input_);
|
||||
return input_.data();
|
||||
}
|
||||
|
||||
const TestOutputStream& test_output_stream() const {
|
||||
@ -69,8 +69,8 @@ class ZlibOutputStreamTest : public testing::Test {
|
||||
|
||||
private:
|
||||
std::unique_ptr<ZlibOutputStream> zlib_output_stream_;
|
||||
std::unique_ptr<uint8_t[]> input_;
|
||||
std::unique_ptr<uint8_t[]> deterministic_input_;
|
||||
base::HeapArray<uint8_t> input_;
|
||||
base::HeapArray<uint8_t> deterministic_input_;
|
||||
TestOutputStream* test_output_stream_; // weak, owned by zlib_output_stream_
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user