Changeset 251274 in webkit


Ignore:
Timestamp:
Oct 17, 2019, 9:35:28 PM (6 years ago)
Author:
mark.lam@apple.com
Message:

Add missing checks after calls to the sameValue() JSValue comparator.
https://bugs.webkit.org/show_bug.cgi?id=203126
<rdar://problem/56366561>

Reviewed by Saam Barati.

JSTests:

  • stress/validate-exception-check-in-proxy-object-put.js: Added.

Source/JavaScriptCore:

  • runtime/JSFunction.cpp:

(JSC::JSFunction::defineOwnProperty):

  • runtime/JSObject.cpp:

(JSC::JSObject::defineOwnIndexedProperty):
(JSC::validateAndApplyPropertyDescriptor):

  • runtime/PropertyDescriptor.cpp:

(JSC::PropertyDescriptor::equalTo const):

  • runtime/ProxyObject.cpp:

(JSC::performProxyGet):
(JSC::ProxyObject::performPut):
(JSC::ProxyObject::performSetPrototype):
(JSC::ProxyObject::performGetPrototype):

  • runtime/RegExpObject.cpp:

(JSC::RegExpObject::defineOwnProperty):

Location:
trunk
Files:
1 added
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/JSTests/ChangeLog

    r251271 r251274  
     12019-10-17  Mark Lam  <mark.lam@apple.com>
     2
     3        Add missing checks after calls to the sameValue() JSValue comparator.
     4        https://bugs.webkit.org/show_bug.cgi?id=203126
     5        <rdar://problem/56366561>
     6
     7        Reviewed by Saam Barati.
     8
     9        * stress/validate-exception-check-in-proxy-object-put.js: Added.
     10
    1112019-10-17  Saam Barati  <sbarati@apple.com>
    212
  • trunk/Source/JavaScriptCore/ChangeLog

    r251271 r251274  
     12019-10-17  Mark Lam  <mark.lam@apple.com>
     2
     3        Add missing checks after calls to the sameValue() JSValue comparator.
     4        https://bugs.webkit.org/show_bug.cgi?id=203126
     5        <rdar://problem/56366561>
     6
     7        Reviewed by Saam Barati.
     8
     9        * runtime/JSFunction.cpp:
     10        (JSC::JSFunction::defineOwnProperty):
     11        * runtime/JSObject.cpp:
     12        (JSC::JSObject::defineOwnIndexedProperty):
     13        (JSC::validateAndApplyPropertyDescriptor):
     14        * runtime/PropertyDescriptor.cpp:
     15        (JSC::PropertyDescriptor::equalTo const):
     16        * runtime/ProxyObject.cpp:
     17        (JSC::performProxyGet):
     18        (JSC::ProxyObject::performPut):
     19        (JSC::ProxyObject::performSetPrototype):
     20        (JSC::ProxyObject::performGetPrototype):
     21        * runtime/RegExpObject.cpp:
     22        (JSC::RegExpObject::defineOwnProperty):
     23
    1242019-10-17  Saam Barati  <sbarati@apple.com>
    225
  • trunk/Source/JavaScriptCore/runtime/JSFunction.cpp

    r250803 r251274  
    592592            RELEASE_AND_RETURN(scope, Base::defineOwnProperty(object, exec, propertyName, descriptor, throwException));
    593593
    594         valueCheck = !descriptor.value() || sameValue(exec, descriptor.value(), retrieveArguments(exec, thisObject));
     594        valueCheck = !descriptor.value();
     595        if (!valueCheck) {
     596            valueCheck = sameValue(exec, descriptor.value(), retrieveArguments(exec, thisObject));
     597            RETURN_IF_EXCEPTION(scope, false);
     598        }
    595599    } else if (propertyName == vm.propertyNames->caller) {
    596600        if (!thisObject->jsExecutable()->hasCallerAndArgumentsProperties())
    597601            RELEASE_AND_RETURN(scope, Base::defineOwnProperty(object, exec, propertyName, descriptor, throwException));
    598602
    599         valueCheck = !descriptor.value() || sameValue(exec, descriptor.value(), retrieveCallerFunction(exec, thisObject));
     603        valueCheck = !descriptor.value();
     604        if (!valueCheck) {
     605            valueCheck = sameValue(exec, descriptor.value(), retrieveCallerFunction(exec, thisObject));
     606            RETURN_IF_EXCEPTION(scope, false);
     607        }
    600608    } else {
    601609        thisObject->reifyLazyPropertyIfNeeded(vm, exec, propertyName);
  • trunk/Source/JavaScriptCore/runtime/JSObject.cpp

    r250803 r251274  
    26842684                // 10.a.ii. If the [[Writable]] field of current is false, then
    26852685                // 10.a.ii.1. Reject, if the [[Value]] field of Desc is present and SameValue(Desc.[[Value]], current.[[Value]]) is false.
    2686                 if (descriptor.value() && !sameValue(exec, descriptor.value(), current.value()))
    2687                     return typeError(exec, scope, throwException, ReadonlyPropertyChangeError);
     2686                if (descriptor.value()) {
     2687                    bool isSame = sameValue(exec, descriptor.value(), current.value());
     2688                    RETURN_IF_EXCEPTION(scope, false);
     2689                    if (!isSame)
     2690                        return typeError(exec, scope, throwException, ReadonlyPropertyChangeError);
     2691                }
    26882692            }
    26892693            // 10.b. else, the [[Configurable]] field of current is true, so any change is acceptable.
     
    36423646                return typeError(exec, scope, throwException, UnconfigurablePropertyChangeWritabilityError);
    36433647            if (!current.writable()) {
    3644                 if (descriptor.value() && !sameValue(exec, current.value(), descriptor.value()))
    3645                     return typeError(exec, scope, throwException, ReadonlyPropertyChangeError);
     3648                if (descriptor.value()) {
     3649                    bool isSame = sameValue(exec, current.value(), descriptor.value());
     3650                    RETURN_IF_EXCEPTION(scope, false);
     3651                    if (!isSame)
     3652                        return typeError(exec, scope, throwException, ReadonlyPropertyChangeError);
     3653                }
    36463654            }
    36473655        }
  • trunk/Source/JavaScriptCore/runtime/PropertyDescriptor.cpp

    r239062 r251274  
    11/*
    2  * Copyright (C) 2009, 2016 Apple Inc. All rights reserved.
     2 * Copyright (C) 2009-2019 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    196196bool PropertyDescriptor::equalTo(ExecState* exec, const PropertyDescriptor& other) const
    197197{
     198    VM& vm = exec->vm();
     199    auto scope = DECLARE_THROW_SCOPE(vm);
    198200    if (other.m_value.isEmpty() != m_value.isEmpty()
    199201        || other.m_getter.isEmpty() != m_getter.isEmpty()
    200202        || other.m_setter.isEmpty() != m_setter.isEmpty())
    201203        return false;
    202     return (!m_value || sameValue(exec, other.m_value, m_value))
    203         && (!m_getter || JSValue::strictEqual(exec, other.m_getter, m_getter))
     204    if (m_value) {
     205        bool isSame = sameValue(exec, other.m_value, m_value);
     206        RETURN_IF_EXCEPTION(scope, false);
     207        if (!isSame)
     208            return false;
     209    }
     210    return (!m_getter || JSValue::strictEqual(exec, other.m_getter, m_getter))
    204211        && (!m_setter || JSValue::strictEqual(exec, other.m_setter, m_setter))
    205212        && attributesEqual(other);
  • trunk/Source/JavaScriptCore/runtime/ProxyObject.cpp

    r250803 r251274  
    178178    if (result) {
    179179        if (descriptor.isDataDescriptor() && !descriptor.configurable() && !descriptor.writable()) {
    180             if (!sameValue(exec, descriptor.value(), trapResult))
     180            bool isSame = sameValue(exec, descriptor.value(), trapResult);
     181            RETURN_IF_EXCEPTION(scope, { });
     182            if (!isSame)
    181183                return throwTypeError(exec, scope, "Proxy handler's 'get' result of a non-configurable and non-writable property should be the same value as the target's property"_s);
    182184        } else if (descriptor.isAccessorDescriptor() && !descriptor.configurable() && descriptor.getter().isUndefined()) {
     
    466468    if (hasProperty) {
    467469        if (descriptor.isDataDescriptor() && !descriptor.configurable() && !descriptor.writable()) {
    468             if (!sameValue(exec, descriptor.value(), putValue)) {
     470            bool isSame = sameValue(exec, descriptor.value(), putValue);
     471            RETURN_IF_EXCEPTION(scope, false);
     472            if (!isSame) {
    469473                throwVMTypeError(exec, scope, "Proxy handler's 'set' on a non-configurable and non-writable property on 'target' should either return false or be the same value already on the 'target'"_s);
    470474                return false;
     
    11481152    JSValue targetPrototype = target->getPrototype(vm, exec);
    11491153    RETURN_IF_EXCEPTION(scope, false);
    1150     if (!sameValue(exec, prototype, targetPrototype)) {
     1154    bool isSame = sameValue(exec, prototype, targetPrototype);
     1155    RETURN_IF_EXCEPTION(scope, false);
     1156    if (!isSame) {
    11511157        throwVMTypeError(exec, scope, "Proxy 'setPrototypeOf' trap returned true when its target is non-extensible and the new prototype value is not the same as the current prototype value. It should have returned false"_s);
    11521158        return false;
     
    12061212    JSValue targetPrototype = target->getPrototype(vm, exec);
    12071213    RETURN_IF_EXCEPTION(scope, { });
    1208     if (!sameValue(exec, targetPrototype, trapResult)) {
     1214    bool isSame = sameValue(exec, targetPrototype, trapResult);
     1215    RETURN_IF_EXCEPTION(scope, { });
     1216    if (!isSame) {
    12091217        throwVMTypeError(exec, scope, "Proxy's 'getPrototypeOf' trap for a non-extensible target should return the same value as the target's prototype"_s);
    12101218        return { };
  • trunk/Source/JavaScriptCore/runtime/RegExpObject.cpp

    r243364 r251274  
    11/*
    22 *  Copyright (C) 1999-2000 Harri Porten (porten@kde.org)
    3  *  Copyright (C) 2003-2018 Apple Inc. All Rights Reserved.
     3 *  Copyright (C) 2003-2019 Apple Inc. All Rights Reserved.
    44 *
    55 *  This library is free software; you can redistribute it and/or
     
    120120            if (descriptor.writablePresent() && descriptor.writable())
    121121                return typeError(exec, scope, shouldThrow, UnconfigurablePropertyChangeWritabilityError);
    122             if (descriptor.value() && !sameValue(exec, regExp->getLastIndex(), descriptor.value()))
    123                 return typeError(exec, scope, shouldThrow, ReadonlyPropertyChangeError);
     122            if (descriptor.value()) {
     123                bool isSame = sameValue(exec, regExp->getLastIndex(), descriptor.value());
     124                RETURN_IF_EXCEPTION(scope, false);
     125                if (!isSame)
     126                    return typeError(exec, scope, shouldThrow, ReadonlyPropertyChangeError);
     127            }
    124128            return true;
    125129        }
Note: See TracChangeset for help on using the changeset viewer.