Permalink
Show file tree
Hide file tree
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
String overflow when using StringBuilder in JSC::createError
https://bugs.webkit.org/show_bug.cgi?id=194957 Reviewed by Mark Lam. JSTests: Add test string-overflow-createError-bulder.js that overflows StringBuilder in notAFunctionSourceAppender. The second new test string-overflow-createError-fit.js has an error message that doesn't overflow, it still failed since the String's capacity can't be doubled. Run test string-overflow-createError.js only in the default configuration to reduce memory consumption when running the test in all configurations on multiple CPUs in parallel. * stress/string-overflow-createError-builder.js: Copied from JSTests/stress/string-overflow-createError.js. (catch): * stress/string-overflow-createError-fit.js: Copied from JSTests/stress/string-overflow-createError.js. (catch): * stress/string-overflow-createError.js: Source/JavaScriptCore: StringBuilder in notAFunctionSourceAppender didn't check for overflows but just failed. * runtime/ExceptionHelpers.cpp: (JSC::notAFunctionSourceAppender): Source/WTF: When calculating the new capacity of a StringBuilder object, use a limit of MaxLength instead of MaxLength+1. Allocating a string of size MaxLength+1 always fails. This means that expanding a StringBuilder only worked when the newly doubled capacity is less or equal to MaxLength. * wtf/text/StringBuilder.cpp: Canonical link: https://commits.webkit.org/210001@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@242910 268f45cc-cd09-0410-ab3c-d52691b4dbfc
- Loading branch information
Dominik Infuehr
committed
Mar 13, 2019
1 parent
ae3d2d8
commit b29aa9a48ca3567575800d79e58399d6ae7439bc
Showing
8 changed files
with
88 additions
and
2 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
@@ -0,0 +1,15 @@ | ||
//@ skip if $memoryLimited | ||
//@ runDefault | ||
var exception; | ||
try { | ||
bar = '2.3023e-320' | ||
foo = bar.padEnd(2147483620, 1); | ||
foo(true, 1).value; | ||
} catch (e) { | ||
exception = e; | ||
} | ||
|
||
// when the StringBuilder for the error message overflows, | ||
// "object is not a function" is used as message for the TypeError. | ||
if (exception.message != "object is not a function.") | ||
throw "FAILED"; |
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
@@ -0,0 +1,16 @@ | ||
//@ skip if $memoryLimited | ||
//@ runDefault | ||
var exception; | ||
try { | ||
bar = '2.3023e-320' | ||
foo = bar.padEnd(2147480000, 1); | ||
foo(true, 1).value; | ||
} catch (e) { | ||
exception = e; | ||
} | ||
|
||
// Although the message of the TypeError is quite long, | ||
// it still fits into String::MaxLength. Check the start | ||
// of the error message. | ||
if (!exception.message.startsWith("foo is not a function")) | ||
throw "FAILED"; |
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