Skip to content

Commit a096da7

Browse files
committed
Add stack limit check to proxy operations
Fixes jerryscript-project#3785. JerryScript-DCO-1.0-Signed-off-by: Dániel Bátyai [email protected]
1 parent edaf4ef commit a096da7

File tree

3 files changed

+42
-1
lines changed

3 files changed

+42
-1
lines changed

Diff for: .travis.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ matrix:
7777
env:
7878
# Skipping maximum stack usage related tests due to 'detect_stack_use_after_return=1' ASAN option.
7979
# For more detailed description: https://github.com/google/sanitizers/wiki/AddressSanitizerUseAfterReturn#compatibility
80-
- OPTS="--quiet --jerry-tests --jerry-test-suite --skip-list=parser-oom.js,parser-oom2.js,stack-limit.js,regression-test-issue-2190.js,regression-test-issue-2258-2963.js,regression-test-issue-2448.js,regression-test-issue-2905.js --buildoptions=--stack-limit=0,--compile-flag=-fsanitize=address,--compile-flag=-m32,--compile-flag=-fno-omit-frame-pointer,--compile-flag=-fno-common,--compile-flag=-O2,--debug,--system-allocator=on,--linker-flag=-fuse-ld=gold"
80+
- OPTS="--quiet --jerry-tests --jerry-test-suite --skip-list=parser-oom.js,parser-oom2.js,stack-limit.js,regression-test-issue-2190.js,regression-test-issue-2258-2963.js,regression-test-issue-2448.js,regression-test-issue-2905.js,regression-test-issue-3785.js --buildoptions=--stack-limit=0,--compile-flag=-fsanitize=address,--compile-flag=-m32,--compile-flag=-fno-omit-frame-pointer,--compile-flag=-fno-common,--compile-flag=-O2,--debug,--system-allocator=on,--linker-flag=-fuse-ld=gold"
8181
- ASAN_OPTIONS=detect_stack_use_after_return=1:check_initialization_order=true:strict_init_order=true
8282
- TIMEOUT=600
8383
addons:

Diff for: jerry-core/ecma/operations/ecma-proxy-object.c

+4
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include "ecma-objects.h"
2626
#include "ecma-objects-general.h"
2727
#include "ecma-proxy-object.h"
28+
#include "jcontext.h"
2829

2930
/** \addtogroup ecma ECMA
3031
* @{
@@ -994,6 +995,7 @@ ecma_proxy_object_has (ecma_object_t *obj_p, /**< proxy object */
994995
ecma_string_t *prop_name_p) /**< property name */
995996
{
996997
JERRY_ASSERT (ECMA_OBJECT_IS_PROXY (obj_p));
998+
ECMA_CHECK_STACK_USAGE ();
997999

9981000
ecma_proxy_object_t *proxy_obj_p = (ecma_proxy_object_t *) obj_p;
9991001

@@ -1097,6 +1099,7 @@ ecma_proxy_object_get (ecma_object_t *obj_p, /**< proxy object */
10971099
ecma_value_t receiver) /**< receiver to invoke getter function */
10981100
{
10991101
JERRY_ASSERT (ECMA_OBJECT_IS_PROXY (obj_p));
1102+
ECMA_CHECK_STACK_USAGE ();
11001103

11011104
ecma_proxy_object_t *proxy_obj_p = (ecma_proxy_object_t *) obj_p;
11021105

@@ -1201,6 +1204,7 @@ ecma_proxy_object_set (ecma_object_t *obj_p, /**< proxy object */
12011204
ecma_value_t receiver) /**< receiver to invoke setter function */
12021205
{
12031206
JERRY_ASSERT (ECMA_OBJECT_IS_PROXY (obj_p));
1207+
ECMA_CHECK_STACK_USAGE ();
12041208

12051209
ecma_proxy_object_t *proxy_obj_p = (ecma_proxy_object_t *) obj_p;
12061210

Diff for: tests/jerry/es2015/regression-test-issue-3785.js

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
// Copyright JS Foundation and other contributors, http://js.foundation
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
var a = new Proxy({length:2}, {});
16+
a.__proto__ = a;
17+
18+
try {
19+
a[1];
20+
assert (false);
21+
} catch (e) {
22+
assert (e instanceof RangeError);
23+
}
24+
25+
try {
26+
a[1] = 2;
27+
assert (false);
28+
} catch (e) {
29+
assert (e instanceof RangeError);
30+
}
31+
32+
try {
33+
Array.prototype.forEach.call(a, ()=>{});
34+
assert (false);
35+
} catch (e) {
36+
assert (e instanceof RangeError);
37+
}

0 commit comments

Comments
 (0)