Skip to content

Commit

Permalink
Test only for stack overflow in CVE-2023-31922
Browse files Browse the repository at this point in the history
Don't merge this is only the test from PR quickjs-ng#157
  • Loading branch information
nickva committed Dec 1, 2023
1 parent a5b9e54 commit 9d3ed07
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions tests/test_builtin.js
Original file line number Diff line number Diff line change
Expand Up @@ -707,6 +707,25 @@ function test_generator()
assert(v.value === undefined && v.done === true);
}

/* CVE-2023-31922 */
function test_proxy_is_array()
{
for (var r = new Proxy ([],{}) , y = 0 ; y < 331072 ; y ++ )
r = new Proxy (r, {});

try {
/* Without ASAN */
assert(Array.isArray(r));
} catch(e) {
/* With ASAN expect InternalError "stack overflow" to be raised */
if (e instanceof InternalError) {
assert(e.message, "stack overflow", "Stack overflow error was not raised")
} else {
throw(e);
}
}
}

test();
test_function();
test_enum();
Expand All @@ -724,3 +743,4 @@ test_map();
test_weak_map();
test_weak_set();
test_generator();
test_proxy_is_array();

0 comments on commit 9d3ed07

Please sign in to comment.