Fix crash when loading 4GB+ local files on 32-bit Windows |total_bytes_to_send| is of type uint64_t, which indicates the size of the local file (when the Range field is not specified in the headers), and its value may exceed 4GB. On Windows 32-bit operating systems, size_t is represented by uint32_t. `base::checked_cast<size_t>(total_bytes_to_send)` actually checks the conversion of uint64_t to uint32_t. When the value of |total_bytes_to_send| exceeds 4GB, it cannot pass the check and will cause a crash. Why this change is safe: The maximum data size that `producer_handle->WriteData` can handle is uint32_t, so the size of |bytes_to_write| should be guaranteed to be within the range of uint32_t. We should first take the minimum value of |bytes_to_write.size()| and |total_bytes_to_send| to ensure that it does not exceed the size of |bytes_to_write| as the count value of `bytes_to_write.first`. Finally, the conversion of uint64_t type to size_t needs to be safety checked, which is reasonable and safe. Bug: 369739222 Change-Id: I10944479a67f1f9a9c0ca16973ab8de51aac15b6 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5892980 Reviewed-by: Kenichi Ishibashi <bashi@chromium.org> Reviewed-by: Erik Staab <estaab@chromium.org> Reviewed-by: Takashi Toyoshima <toyoshim@chromium.org> Auto-Submit: 吴金立 <wujinli@bytedance.com> Commit-Queue: Takashi Toyoshima <toyoshim@chromium.org> Cr-Commit-Position: refs/heads/main@{#1366682}
Chromium is an open-source browser project that aims to build a safer, faster, and more stable way for all users to experience the web.
The project's web site is https://www.chromium.org.
To check out the source code locally, don't use git clone! Instead, follow the instructions on how to get the code.
Documentation in the source is rooted in docs/README.md.
Learn how to Get Around the Chromium Source Code Directory Structure.
For historical reasons, there are some small top level directories. Now the guidance is that new top level directories are for product (e.g. Chrome, Android WebView, Ash). Even if these products have multiple executables, the code should be in subdirectories of the product.
If you found a bug, please file it at https://crbug.com/new.