-
Notifications
You must be signed in to change notification settings - Fork 6.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ensure serialized size_t can be passed between 32bit and 64bit processes
https://crrev.com/c/4205862 broken some WebView environment which uses 32bit renderer process and 64bit browser process because size_t was serialized as the native type uint32_t or uint64_t. Now partly revert the CL about size_t to always serialize size_t as uint64_t. The current PaintOpReader and PaintOpWriter are still fragile because the caller can use Write/Read() instead of WriteSize()/ReadSize() for size_t and cause problems. I will follow up to refactor this to prevent the problem. Bug: 1414445, 1414686 Change-Id: I9c427950fd3559c5c1f79d019c7a0f8131a01b17 Cq-Include-Trybots: luci.chromium.try:android-webview-pie-arm64-dbg,android-webview-oreo-arm64-dbg Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4237958 Commit-Queue: Xianzhu Wang <wangxianzhu@chromium.org> Reviewed-by: Sunny Sachanandani <sunnyps@chromium.org> Reviewed-by: Philip Rogers <pdr@chromium.org> Cr-Commit-Position: refs/heads/main@{#1104172}
- Loading branch information
1 parent
c9fecbd
commit 96619a3
Showing
5 changed files
with
95 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
// Copyright 2023 The Chromium Authors | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#include "cc/paint/paint_op_reader.h" | ||
#include "cc/paint/paint_op_writer.h" | ||
|
||
#include "cc/test/test_options_provider.h" | ||
#include "testing/gtest/include/gtest/gtest.h" | ||
|
||
namespace cc { | ||
|
||
TEST(PaintOpWriterReaderTest, SizeT) { | ||
static_assert(PaintOpWriter::SerializedSize<int>() == 4u); | ||
static_assert(PaintOpWriter::SerializedSize<size_t>() == 8u); | ||
static_assert(PaintOpWriter::SerializedSize(static_cast<size_t>(0u)) == 8u); | ||
|
||
char buffer[128]; | ||
TestOptionsProvider options_provider; | ||
memset(buffer, 0xa5, std::size(buffer)); | ||
PaintOpWriter writer(buffer, std::size(buffer), | ||
options_provider.serialize_options(), | ||
/*enable_security_constraints*/ true); | ||
int i = 0x5555aaaa; | ||
size_t s1 = static_cast<size_t>(0x123456789abcdef0L); | ||
size_t s2 = static_cast<size_t>(0xfedcba9876543210L); | ||
writer.WriteSize(s1); | ||
writer.Write(i); | ||
writer.WriteSize(s2); | ||
EXPECT_EQ(20u, writer.size()); | ||
|
||
PaintOpReader reader(buffer, writer.size(), | ||
options_provider.deserialize_options(), | ||
/*enable_security_constraints*/ true); | ||
int read_i; | ||
size_t read_s1, read_s2; | ||
reader.ReadSize(&read_s1); | ||
reader.Read(&read_i); | ||
reader.ReadSize(&read_s2); | ||
EXPECT_EQ(i, read_i); | ||
EXPECT_EQ(s1, read_s1); | ||
EXPECT_EQ(s2, read_s2); | ||
EXPECT_TRUE(reader.valid()); | ||
EXPECT_EQ(0u, reader.remaining_bytes()); | ||
|
||
reader.ReadSize(&read_s2); | ||
EXPECT_FALSE(reader.valid()); | ||
} | ||
|
||
} // namespace cc |