chore: fix compile errors (#30903)
This commit is contained in:
parent
57d088517c
commit
fb539f15d0
5 changed files with 25 additions and 11 deletions
|
@ -24,6 +24,8 @@ AsarFileValidator::AsarFileValidator(IntegrityPayload integrity,
|
||||||
max_block_ = integrity_.blocks.size() - 1;
|
max_block_ = integrity_.blocks.size() - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
AsarFileValidator::~AsarFileValidator() = default;
|
||||||
|
|
||||||
void AsarFileValidator::OnRead(base::span<char> buffer,
|
void AsarFileValidator::OnRead(base::span<char> buffer,
|
||||||
mojo::FileDataSource::ReadResult* result) {
|
mojo::FileDataSource::ReadResult* result) {
|
||||||
DCHECK(!done_reading_);
|
DCHECK(!done_reading_);
|
||||||
|
|
|
@ -19,11 +19,12 @@ namespace asar {
|
||||||
class AsarFileValidator : public mojo::FilteredDataSource::Filter {
|
class AsarFileValidator : public mojo::FilteredDataSource::Filter {
|
||||||
public:
|
public:
|
||||||
AsarFileValidator(IntegrityPayload integrity, base::File file);
|
AsarFileValidator(IntegrityPayload integrity, base::File file);
|
||||||
|
~AsarFileValidator() override;
|
||||||
|
|
||||||
void OnRead(base::span<char> buffer,
|
void OnRead(base::span<char> buffer,
|
||||||
mojo::FileDataSource::ReadResult* result);
|
mojo::FileDataSource::ReadResult* result) override;
|
||||||
|
|
||||||
void OnDone();
|
void OnDone() override;
|
||||||
|
|
||||||
void SetRange(uint64_t read_start, uint64_t extra_read, uint64_t read_max);
|
void SetRange(uint64_t read_start, uint64_t extra_read, uint64_t read_max);
|
||||||
void SetCurrentBlock(int current_block);
|
void SetCurrentBlock(int current_block);
|
||||||
|
|
|
@ -157,7 +157,9 @@ class AsarURLLoader : public network::mojom::URLLoader {
|
||||||
std::unique_ptr<mojo::DataPipeProducer::DataSource> readable_data_source;
|
std::unique_ptr<mojo::DataPipeProducer::DataSource> readable_data_source;
|
||||||
mojo::FileDataSource* file_data_source_raw = file_data_source.get();
|
mojo::FileDataSource* file_data_source_raw = file_data_source.get();
|
||||||
AsarFileValidator* file_validator_raw = nullptr;
|
AsarFileValidator* file_validator_raw = nullptr;
|
||||||
|
uint32_t block_size = 0;
|
||||||
if (info.integrity.has_value()) {
|
if (info.integrity.has_value()) {
|
||||||
|
block_size = info.integrity.value().block_size;
|
||||||
auto asar_validator = std::make_unique<AsarFileValidator>(
|
auto asar_validator = std::make_unique<AsarFileValidator>(
|
||||||
std::move(info.integrity.value()), std::move(file));
|
std::move(info.integrity.value()), std::move(file));
|
||||||
file_validator_raw = asar_validator.get();
|
file_validator_raw = asar_validator.get();
|
||||||
|
@ -232,15 +234,13 @@ class AsarURLLoader : public network::mojom::URLLoader {
|
||||||
first_byte_to_send = read_result.bytes_read;
|
first_byte_to_send = read_result.bytes_read;
|
||||||
total_bytes_to_send -= write_size;
|
total_bytes_to_send -= write_size;
|
||||||
} else if (is_verifying_file &&
|
} else if (is_verifying_file &&
|
||||||
first_byte_to_send >=
|
first_byte_to_send >= static_cast<uint64_t>(block_size)) {
|
||||||
static_cast<uint64_t>(info.integrity.value().block_size)) {
|
|
||||||
// If validation is active and the range of bytes the request wants starts
|
// If validation is active and the range of bytes the request wants starts
|
||||||
// beyond the first block we need to read the next 4MB-1KB to validate
|
// beyond the first block we need to read the next 4MB-1KB to validate
|
||||||
// that block. Then we can skip ahead to the target block in the SetRange
|
// that block. Then we can skip ahead to the target block in the SetRange
|
||||||
// call below If we hit this case it is assumed that none of the data read
|
// call below If we hit this case it is assumed that none of the data read
|
||||||
// will be needed by the producer
|
// will be needed by the producer
|
||||||
uint64_t bytes_to_drop =
|
uint64_t bytes_to_drop = block_size - net::kMaxBytesToSniff;
|
||||||
info.integrity.value().block_size - net::kMaxBytesToSniff;
|
|
||||||
total_bytes_dropped_from_head += bytes_to_drop;
|
total_bytes_dropped_from_head += bytes_to_drop;
|
||||||
std::vector<char> abandoned_buffer(bytes_to_drop);
|
std::vector<char> abandoned_buffer(bytes_to_drop);
|
||||||
auto abandon_read_result =
|
auto abandon_read_result =
|
||||||
|
@ -282,7 +282,6 @@ class AsarURLLoader : public network::mojom::URLLoader {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_verifying_file) {
|
if (is_verifying_file) {
|
||||||
uint32_t block_size = info.integrity.value().block_size;
|
|
||||||
int start_block = first_byte_to_send / block_size;
|
int start_block = first_byte_to_send / block_size;
|
||||||
|
|
||||||
// If we're starting from the first block, we might not be starting from
|
// If we're starting from the first block, we might not be starting from
|
||||||
|
|
|
@ -157,6 +157,15 @@ bool FillFileInfoWithNode(Archive::FileInfo* info,
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
|
IntegrityPayload::IntegrityPayload()
|
||||||
|
: algorithm(HashAlgorithm::NONE), block_size(0) {}
|
||||||
|
IntegrityPayload::~IntegrityPayload() = default;
|
||||||
|
IntegrityPayload::IntegrityPayload(const IntegrityPayload& other) = default;
|
||||||
|
|
||||||
|
Archive::FileInfo::FileInfo()
|
||||||
|
: unpacked(false), executable(false), size(0), offset(0) {}
|
||||||
|
Archive::FileInfo::~FileInfo() = default;
|
||||||
|
|
||||||
Archive::Archive(const base::FilePath& path)
|
Archive::Archive(const base::FilePath& path)
|
||||||
: initialized_(false), path_(path), file_(base::File::FILE_OK) {
|
: initialized_(false), path_(path), file_(base::File::FILE_OK) {
|
||||||
base::ThreadRestrictions::ScopedAllowIO allow_io;
|
base::ThreadRestrictions::ScopedAllowIO allow_io;
|
||||||
|
@ -270,11 +279,11 @@ bool Archive::Init() {
|
||||||
|
|
||||||
#if !defined(OS_MAC)
|
#if !defined(OS_MAC)
|
||||||
absl::optional<IntegrityPayload> Archive::HeaderIntegrity() const {
|
absl::optional<IntegrityPayload> Archive::HeaderIntegrity() const {
|
||||||
return absl::optional<IntegrityPayload>();
|
return absl::nullopt;
|
||||||
}
|
}
|
||||||
|
|
||||||
absl::optional<base::FilePath> Archive::RelativePath() const {
|
absl::optional<base::FilePath> Archive::RelativePath() const {
|
||||||
return absl::optional<base::FilePath>();
|
return absl::nullopt;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,9 @@ enum HashAlgorithm {
|
||||||
};
|
};
|
||||||
|
|
||||||
struct IntegrityPayload {
|
struct IntegrityPayload {
|
||||||
IntegrityPayload() : algorithm(HashAlgorithm::NONE), block_size(0) {}
|
IntegrityPayload();
|
||||||
|
~IntegrityPayload();
|
||||||
|
IntegrityPayload(const IntegrityPayload& other);
|
||||||
HashAlgorithm algorithm;
|
HashAlgorithm algorithm;
|
||||||
std::string hash;
|
std::string hash;
|
||||||
uint32_t block_size;
|
uint32_t block_size;
|
||||||
|
@ -41,7 +43,8 @@ struct IntegrityPayload {
|
||||||
class Archive {
|
class Archive {
|
||||||
public:
|
public:
|
||||||
struct FileInfo {
|
struct FileInfo {
|
||||||
FileInfo() : unpacked(false), executable(false), size(0), offset(0) {}
|
FileInfo();
|
||||||
|
~FileInfo();
|
||||||
bool unpacked;
|
bool unpacked;
|
||||||
bool executable;
|
bool executable;
|
||||||
uint32_t size;
|
uint32_t size;
|
||||||
|
|
Loading…
Reference in a new issue