Browse Source

fix: -Wunsafe-buffer-usage warning in asar_util's ReadFileToString() (#43929)

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Charles Kerr <[email protected]>
trop[bot] 6 months ago
parent
commit
d8e3555e01
1 changed files with 1 additions and 4 deletions
  1. 1 4
      shell/common/asar/asar_util.cc

+ 1 - 4
shell/common/asar/asar_util.cc

@@ -127,11 +127,8 @@ bool ReadFileToString(const base::FilePath& path, std::string* contents) {
     return false;
 
   contents->resize(info.size);
-  if (static_cast<int>(info.size) !=
-      src.Read(info.offset, const_cast<char*>(contents->data()),
-               contents->size())) {
+  if (!src.ReadAndCheck(info.offset, base::as_writable_byte_span(*contents)))
     return false;
-  }
 
   if (info.integrity)
     ValidateIntegrityOrDie(base::as_byte_span(*contents), *info.integrity);