Pass size_t to span functions: storage/
In preparation for upgrading various span args from size_t to StrictNumeric<size_t>, this fixes type mismatches that would cause compile errors with that change. Bug: none Change-Id: Ic76c9975cdb6431d81645e1930e3f1fdd6d6f4f9 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6020585 Commit-Queue: Peter Kasting <pkasting@chromium.org> Auto-Submit: Peter Kasting <pkasting@chromium.org> Commit-Queue: Ayu Ishii <ayui@chromium.org> Code-Coverage: findit-for-me@appspot.gserviceaccount.com <findit-for-me@appspot.gserviceaccount.com> Reviewed-by: Ayu Ishii <ayui@chromium.org> Cr-Commit-Position: refs/heads/main@{#1382665}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
c81ca39ce2
commit
58eb8b48c3
@ -508,20 +508,23 @@ int ObfuscatedFileUtilMemoryDelegate::ReadFile(const base::FilePath& path,
|
||||
if (!dp || dp->entry->type != Entry::kFile)
|
||||
return net::ERR_FILE_NOT_FOUND;
|
||||
|
||||
int64_t remaining = dp->entry->file_content.size() - offset;
|
||||
if (offset < 0)
|
||||
if (offset < 0 || buf_len < 0) {
|
||||
return net::ERR_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
// Seeking past the end of the file is ok, but returns nothing.
|
||||
// This matches FileStream::Context behavior.
|
||||
if (remaining < 0)
|
||||
int64_t remaining = dp->entry->file_content.size() - offset;
|
||||
if (remaining < 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (buf_len > remaining)
|
||||
buf_len = static_cast<int>(remaining);
|
||||
|
||||
base::ranges::copy(
|
||||
base::span(dp->entry->file_content).subspan(offset, buf_len),
|
||||
base::span(dp->entry->file_content)
|
||||
.subspan(static_cast<size_t>(offset), static_cast<size_t>(buf_len)),
|
||||
buf->data());
|
||||
|
||||
return buf_len;
|
||||
|
Reference in New Issue
Block a user