refactor: take a uint8_t
span in ValidateIntegrityOrDie()
(#43592)
refactor: take a uint8_t span in ValidateIntegrityOrDie() Doing some groundwork for fixing unsafe base::File() APIs: - Change ValidateIntegrityOrDie() to take a span<const uint8_t> arg. We'll need this to migrate asar's base::File API calls away from the ones tagged `UNSAFE_BUFFER_USAGE` because the safe counterparts use span<uint8_t> too. - Simplify ValidateIntegrityOrDie()'s implementation by using crypto::SHA256Hash() instead of reinventing the wheel.
This commit is contained in:
parent
18b1b33adc
commit
44a4328ea8
4 changed files with 11 additions and 20 deletions
|
@ -67,9 +67,8 @@ bool ScopedTemporaryFile::InitFromFile(
|
|||
if (len != static_cast<int>(size))
|
||||
return false;
|
||||
|
||||
if (integrity.has_value()) {
|
||||
ValidateIntegrityOrDie(buf.data(), buf.size(), integrity.value());
|
||||
}
|
||||
if (integrity)
|
||||
ValidateIntegrityOrDie(base::as_byte_span(buf), *integrity);
|
||||
|
||||
base::File dest(path_, base::File::FLAG_OPEN | base::File::FLAG_WRITE);
|
||||
if (!dest.IsValid())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue