Changeset 238553 in webkit


Ignore:
Timestamp:
Nov 27, 2018 7:51:43 AM (5 years ago)
Author:
Wenson Hsieh
Message:

WebKit.AddAndRemoveDataDetectors hits a debug assertion after r238515
https://bugs.webkit.org/show_bug.cgi?id=191996

Reviewed by Tim Horton.

This assertion is hit because decode(Decoder& decoder, NSArray<Class> *allowedClasses) expects the decoded
object (of class _NSArrayM) to be equal to NSArray.class.

We fix the crash by relaxing the debug assertion when decoding securely-codable objects over IPC. Instead of
checking that the class of the decoded object is equal to one of the allowed classes, check that the object is a
kind of any of the allowed classes.

  • Shared/Cocoa/ArgumentCodersCocoa.h:

(IPC::isObjectClassAllowed):
(IPC::decode):

Location:
trunk/Source/WebKit
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r238552 r238553  
     12018-11-27  Wenson Hsieh  <wenson_hsieh@apple.com>
     2
     3        WebKit.AddAndRemoveDataDetectors hits a debug assertion after r238515
     4        https://bugs.webkit.org/show_bug.cgi?id=191996
     5
     6        Reviewed by Tim Horton.
     7
     8        This assertion is hit because `decode(Decoder& decoder, NSArray<Class> *allowedClasses)` expects the decoded
     9        object (of class `_NSArrayM`) to be equal to `NSArray.class`.
     10
     11        We fix the crash by relaxing the debug assertion when decoding securely-codable objects over IPC. Instead of
     12        checking that the class of the decoded object is equal to one of the allowed classes, check that the object is a
     13        kind of any of the allowed classes.
     14
     15        * Shared/Cocoa/ArgumentCodersCocoa.h:
     16        (IPC::isObjectClassAllowed):
     17        (IPC::decode):
     18
    1192018-11-27  Tomas Popela  <tpopela@redhat.com>
    220
  • trunk/Source/WebKit/Shared/Cocoa/ArgumentCodersCocoa.h

    r238515 r238553  
    4444}
    4545
     46#ifndef NDEBUG
     47
     48static inline bool isObjectClassAllowed(id object, NSArray<Class> *allowedClasses)
     49{
     50    for (Class allowedClass in allowedClasses) {
     51        if ([object isKindOfClass:allowedClass])
     52            return true;
     53    }
     54    return false;
     55}
     56
     57#endif
     58
    4659template<typename T>
    4760std::optional<RetainPtr<T>> decode(Decoder& decoder, NSArray<Class> *allowedClasses)
     
    5568
    5669    id object = result->leakRef();
    57     ASSERT([allowedClasses containsObject:[object class]]);
     70    ASSERT(isObjectClassAllowed(object, allowedClasses));
    5871    return { adoptNS(static_cast<T *>(object)) };
    5972}
Note: See TracChangeset for help on using the changeset viewer.