From 1af736bc15c795b0d3906142a0e77d602b4d74f4 Mon Sep 17 00:00:00 2001 From: "trop[bot]" <37223003+trop[bot]@users.noreply.github.com> Date: Wed, 25 Sep 2024 11:21:47 +0200 Subject: [PATCH] fix: -Wunsafe-buffer-usage warning in asar_util's ReadFileToString() (#43930) Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: Charles Kerr --- shell/common/asar/asar_util.cc | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/shell/common/asar/asar_util.cc b/shell/common/asar/asar_util.cc index cba95a00c428..9acf8293922c 100644 --- a/shell/common/asar/asar_util.cc +++ b/shell/common/asar/asar_util.cc @@ -126,11 +126,8 @@ bool ReadFileToString(const base::FilePath& path, std::string* contents) { return false; contents->resize(info.size); - if (static_cast(info.size) != - src.Read(info.offset, const_cast(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);