fix: -Wunsafe-buffer-usage warnings in asar file IO (#43624)
* fix: -Wunsafe-buffer-usage warnings in ScopedTemporaryFile::InitFromFile() * fix: -Wunsafe-buffer-usage warnings in Archive::Init()
This commit is contained in:
parent
5718ea4e1e
commit
f1019c2c4a
2 changed files with 15 additions and 25 deletions
|
@ -62,20 +62,15 @@ bool ScopedTemporaryFile::InitFromFile(
|
|||
return false;
|
||||
|
||||
electron::ScopedAllowBlockingForElectron allow_blocking;
|
||||
std::vector<char> buf(size);
|
||||
int len = src->Read(offset, buf.data(), buf.size());
|
||||
if (len != static_cast<int>(size))
|
||||
std::vector<uint8_t> buf(size);
|
||||
if (!src->ReadAndCheck(offset, buf))
|
||||
return false;
|
||||
|
||||
if (integrity)
|
||||
ValidateIntegrityOrDie(base::as_byte_span(buf), *integrity);
|
||||
ValidateIntegrityOrDie(buf, *integrity);
|
||||
|
||||
base::File dest(path_, base::File::FLAG_OPEN | base::File::FLAG_WRITE);
|
||||
if (!dest.IsValid())
|
||||
return false;
|
||||
|
||||
return dest.WriteAtCurrentPos(buf.data(), buf.size()) ==
|
||||
static_cast<int>(size);
|
||||
return dest.IsValid() && dest.WriteAtCurrentPosAndCheck(buf);
|
||||
}
|
||||
|
||||
} // namespace asar
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue