Skip to content

Commit d06e53e

Browse files
tkent-googlemibrunin
authored andcommitted
[Backport] Security bug 379254069
Manual cherry-pick of patch originally reviewed on https://chromium-review.googlesource.com/c/chromium/src/+/6055965: Layout: Fix a crash with tex-transform and -webkit-text-security Uppercasing U+1FB7 and applying -webkit-text-security caused a crash. - Changing an existing DCHECK to CHECK to catch errors like this earlier. Bug: 379254069 Change-Id: I50080aee06fdf35124a0b7fa6071a5e9dfe0fa42 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6055965 Auto-Submit: Kent Tamura <[email protected]> Reviewed-by: Koji Ishii <[email protected]> Commit-Queue: Koji Ishii <[email protected]> Cr-Commit-Position: refs/heads/main@{#1390243} Reviewed-on: https://codereview.qt-project.org/c/qt/qtwebengine-chromium/+/611750 Reviewed-by: Anu Aliyas <[email protected]>
1 parent 024489c commit d06e53e

File tree

4 files changed

+21
-6
lines changed

4 files changed

+21
-6
lines changed

chromium/third_party/blink/renderer/core/layout/layout_text.cc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -916,7 +916,9 @@ String LayoutText::TransformAndSecureText(const String& original,
916916
}
917917
auto [masked, secure_map] = SecureText(transformed, mask);
918918
if (!secure_map.IsEmpty()) {
919-
offset_map = TextOffsetMap(offset_map, secure_map);
919+
offset_map = TextOffsetMap(
920+
offset_map, secure_map,
921+
RuntimeEnabledFeatures::TextTransformAndSecurityFixEnabled());
920922
}
921923
return masked;
922924
}

chromium/third_party/blink/renderer/platform/runtime_enabled_features.json5

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4175,6 +4175,11 @@
41754175
status: "stable",
41764176
depends_on: ["ScrollTimeline"]
41774177
},
4178+
{
4179+
// crbug.com/379254069
4180+
name: "TextTransformAndSecurityFix",
4181+
status: "stable",
4182+
},
41784183
{
41794184
name: "TimerThrottlingForBackgroundTabs",
41804185
public: true,

chromium/third_party/blink/renderer/platform/wtf/text/text_offset_map.cc

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ std::ostream& operator<<(std::ostream& stream,
4848
}
4949

5050
TextOffsetMap::TextOffsetMap(const TextOffsetMap& map12,
51-
const TextOffsetMap& map23) {
51+
const TextOffsetMap& map23,
52+
bool fix_crash) {
5253
if (map12.IsEmpty()) {
5354
entries_ = map23.entries_;
5455
return;
@@ -91,7 +92,12 @@ TextOffsetMap::TextOffsetMap(const TextOffsetMap& map12,
9192
++index12;
9293
++index23;
9394
} else {
94-
Append(entry23.source - offset_diff_12, entry23.target);
95+
DCHECK_GT(entry12.target, entry23.source);
96+
if (fix_crash && chunk_length_diff_12 > 0 && chunk_length_diff_23 < 0) {
97+
// No need to append entry23 because it is included in entry12.
98+
} else {
99+
Append(entry23.source - offset_diff_12, entry23.target);
100+
}
95101
offset_diff_23 = entry23.target - entry23.source;
96102
++index23;
97103
}
@@ -107,8 +113,8 @@ TextOffsetMap::TextOffsetMap(const TextOffsetMap& map12,
107113
}
108114

109115
void TextOffsetMap::Append(wtf_size_t source, wtf_size_t target) {
110-
DCHECK(IsEmpty() ||
111-
(source > entries_.back().source && target > entries_.back().target));
116+
CHECK(IsEmpty() ||
117+
(source > entries_.back().source && target > entries_.back().target));
112118
entries_.emplace_back(source, target);
113119
}
114120

chromium/third_party/blink/renderer/platform/wtf/text/text_offset_map.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,9 @@ class WTF_EXPORT TextOffsetMap {
4242
// Suppose that we mapped string-1 to string-2 with producing map12, and
4343
// we mapped string-2 to string-3 with producing map23. This constructor
4444
// creates a TextOffsetMap instance for mapping string-1 to string-3.
45-
TextOffsetMap(const TextOffsetMap& map12, const TextOffsetMap& map23);
45+
TextOffsetMap(const TextOffsetMap& map12,
46+
const TextOffsetMap& map23,
47+
bool fix_crash);
4648

4749
bool IsEmpty() const { return entries_.empty(); }
4850

0 commit comments

Comments
 (0)