Skip to content

Commit

Permalink
[Backport] CVE-2023-3216: Type Confusion in V8
Browse files Browse the repository at this point in the history
Manual cherry-pick of patch originally reviewed on
https://chromium-review.googlesource.com/c/v8/v8/+/4591495:
Check for encoding when appending in string builder

Fixed: chromium:1450114
Change-Id: I6d1a790b213d24d2737f4b268e8c35ba999f8adf
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/4591495
Reviewed-by: Jakob Linke <jgruber@chromium.org>
Reviewed-by: Jakob Kummerow <jkummerow@chromium.org>
Commit-Queue: Shu-yu Guo <syg@chromium.org>
Cr-Commit-Position: refs/heads/main@{#88091}
Reviewed-on: https://codereview.qt-project.org/c/qt/qtwebengine-chromium/+/487334
Reviewed-by: Michal Klocek <michal.klocek@qt.io>
  • Loading branch information
syg authored and mibrunin committed Jun 22, 2023
1 parent f59c618 commit a41f9a7
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions chromium/v8/src/strings/string-builder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -301,12 +301,21 @@ bool IncrementalStringBuilder::CanAppendByCopy(Handle<String> string) {
void IncrementalStringBuilder::AppendStringByCopy(Handle<String> string) {
DCHECK(CanAppendByCopy(string));

Handle<SeqOneByteString> part =
Handle<SeqOneByteString>::cast(current_part());
{
DisallowHeapAllocation no_gc;
String::WriteToFlat(*string, part->GetChars(no_gc) + current_index_, 0,
string->length());
if (encoding_ == String::ONE_BYTE_ENCODING) {
String::WriteToFlat(
*string,
Handle<SeqOneByteString>::cast(current_part())->GetChars(no_gc) +
current_index_,
0, string->length());
} else {
String::WriteToFlat(
*string,
Handle<SeqTwoByteString>::cast(current_part())->GetChars(no_gc) +
current_index_,
0, string->length());
}
}
current_index_ += string->length();
DCHECK(current_index_ <= part_length_);
Expand Down

0 comments on commit a41f9a7

Please sign in to comment.