⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 276678 in webkit


Ignore:
Timestamp:
Apr 27, 2021, 4:35:22 PM (5 years ago)
Author:
Chris Dumez
Message:

IPC::decoder::decode() should mark decoder as invalid when failing
​https://bugs.webkit.org/show_bug.cgi?id=225117

Reviewed by Darin Adler.

IPC::decoder::decode() should mark decoder as invalid when failing, instead of relying
on individual type decoders to do so. This makes type decoders a bit simpler and less
error-prone.

Source/WebCore:

  • Modules/highlight/AppHighlight.h:

(WebCore::AppHighlight::decode):

Source/WebKit:

  • Platform/IPC/ArgumentCoders.cpp:

(IPC::ArgumentCoder<CString>::decode):
(IPC::decodeStringText):

  • Platform/IPC/ArgumentCoders.h:
  • Platform/IPC/Connection.cpp:

(IPC::Connection::dispatchMessageReceiverMessage):
(IPC::Connection::dispatchSyncMessage):

  • Platform/IPC/Decoder.cpp:

(IPC::m_destinationID):

  • Platform/IPC/Decoder.h:

(IPC::Decoder::decode):
(IPC::Decoder::operator>>):

  • Platform/IPC/HandleMessage.h:

(IPC::handleMessage):
(IPC::handleMessageSynchronous):
(IPC::handleMessageSynchronousWantsConnection):
(IPC::handleMessageAsync):
(IPC::handleMessageAsyncWantsConnection):

  • WebProcess/Plugins/Plugin.cpp:

(WebKit::Plugin::Parameters::decode):

Location:
trunk/Source
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r276677 r276678  
     12021-04-27  Chris Dumez  <cdumez@apple.com>
     2
     3        IPC::decoder::decode() should mark decoder as invalid when failing
     4        https://bugs.webkit.org/show_bug.cgi?id=225117
     5
     6        Reviewed by Darin Adler.
     7
     8        IPC::decoder::decode() should mark decoder as invalid when failing, instead of relying
     9        on individual type decoders to do so. This makes type decoders a bit simpler and less
     10        error-prone.
     11
     12        * Modules/highlight/AppHighlight.h:
     13        (WebCore::AppHighlight::decode):
     14
    1152021-04-27  Alex Christensen  <achristensen@webkit.org>
    216
  • trunk/Source/WebCore/Modules/highlight/AppHighlight.h

    r273826 r276678  
    7171        return WTF::nullopt;
    7272
    73     if (!decoder.template bufferIsLargeEnoughToContain<uint8_t>(length.value())) {
    74         decoder.markInvalid();
     73    if (!decoder.template bufferIsLargeEnoughToContain<uint8_t>(length.value()))
    7574        return WTF::nullopt;
    76     }
    7775
    7876    Vector<uint8_t> highlight;
  • trunk/Source/WebKit/ChangeLog

    r276677 r276678  
     12021-04-27  Chris Dumez  <cdumez@apple.com>
     2
     3        IPC::decoder::decode() should mark decoder as invalid when failing
     4        https://bugs.webkit.org/show_bug.cgi?id=225117
     5
     6        Reviewed by Darin Adler.
     7
     8        IPC::decoder::decode() should mark decoder as invalid when failing, instead of relying
     9        on individual type decoders to do so. This makes type decoders a bit simpler and less
     10        error-prone.
     11
     12        * Platform/IPC/ArgumentCoders.cpp:
     13        (IPC::ArgumentCoder<CString>::decode):
     14        (IPC::decodeStringText):
     15        * Platform/IPC/ArgumentCoders.h:
     16        * Platform/IPC/Connection.cpp:
     17        (IPC::Connection::dispatchMessageReceiverMessage):
     18        (IPC::Connection::dispatchSyncMessage):
     19        * Platform/IPC/Decoder.cpp:
     20        (IPC::m_destinationID):
     21        * Platform/IPC/Decoder.h:
     22        (IPC::Decoder::decode):
     23        (IPC::Decoder::operator>>):
     24        * Platform/IPC/HandleMessage.h:
     25        (IPC::handleMessage):
     26        (IPC::handleMessageSynchronous):
     27        (IPC::handleMessageSynchronousWantsConnection):
     28        (IPC::handleMessageAsync):
     29        (IPC::handleMessageAsyncWantsConnection):
     30        * WebProcess/Plugins/Plugin.cpp:
     31        (WebKit::Plugin::Parameters::decode):
     32
    1332021-04-27  Alex Christensen  <achristensen@webkit.org>
    234
  • trunk/Source/WebKit/Platform/IPC/ArgumentCoders.cpp

    r273204 r276678  
    9999
    100100    // Before allocating the string, make sure that the decoder buffer is big enough.
    101     if (!decoder.bufferIsLargeEnoughToContain<char>(length)) {
    102         decoder.markInvalid();
    103         return false;
    104     }
     101    if (!decoder.bufferIsLargeEnoughToContain<char>(length))
     102        return false;
    105103
    106104    char* buffer;
    … …  
    141139{
    142140    // Before allocating the string, make sure that the decoder buffer is big enough.
    143     if (!decoder.bufferIsLargeEnoughToContain<CharacterType>(length)) {
    144         decoder.markInvalid();
    145         return WTF::nullopt;
    146     }
     141    if (!decoder.bufferIsLargeEnoughToContain<CharacterType>(length))
     142        return WTF::nullopt;
    147143   
    148144    CharacterType* buffer;
  • trunk/Source/WebKit/Platform/IPC/ArgumentCoders.h

    r276510 r276678  
    429429    {
    430430        uint64_t decodedSize;
    431         if (!decoder.decode(decodedSize)) {
    432             decoder.markInvalid();
    433             return false;
    434         }
    435 
    436         if (!isInBounds<size_t>(decodedSize)) {
    437             decoder.markInvalid();
    438             return false;
    439         }
     431        if (!decoder.decode(decodedSize))
     432            return false;
     433
     434        if (!isInBounds<size_t>(decodedSize))
     435            return false;
    440436
    441437        auto size = static_cast<size_t>(decodedSize);
    … …  
    444440        // one fell swoop. Before allocating we must however make sure that the decoder buffer
    445441        // is big enough.
    446         if (!decoder.bufferIsLargeEnoughToContain<T>(size)) {
    447             decoder.markInvalid();
    448             return false;
    449         }
     442        if (!decoder.bufferIsLargeEnoughToContain<T>(size))
     443            return false;
    450444
    451445        Vector<T, inlineCapacity, OverflowHandler, minCapacity> temp;
    452446        temp.grow(size);
    453447
    454         if (!decoder.decodeFixedLengthData(reinterpret_cast<uint8_t*>(temp.data()), size * sizeof(T), alignof(T))) {
    455             decoder.markInvalid();
    456             return false;
    457         }
     448        if (!decoder.decodeFixedLengthData(reinterpret_cast<uint8_t*>(temp.data()), size * sizeof(T), alignof(T)))
     449            return false;
    458450
    459451        vector.swap(temp);
    … …  
    464456    {
    465457        uint64_t decodedSize;
    466         if (!decoder.decode(decodedSize)) {
    467             decoder.markInvalid();
    468             return WTF::nullopt;
    469         }
    470 
    471         if (!isInBounds<size_t>(decodedSize)) {
    472             decoder.markInvalid();
    473             return WTF::nullopt;
    474         }
     458        if (!decoder.decode(decodedSize))
     459            return WTF::nullopt;
     460
     461        if (!isInBounds<size_t>(decodedSize))
     462            return WTF::nullopt;
    475463
    476464        auto size = static_cast<size_t>(decodedSize);
    … …  
    479467        // one fell swoop. Before allocating we must however make sure that the decoder buffer
    480468        // is big enough.
    481         if (!decoder.bufferIsLargeEnoughToContain<T>(size)) {
    482             decoder.markInvalid();
    483             return WTF::nullopt;
    484         }
     469        if (!decoder.bufferIsLargeEnoughToContain<T>(size))
     470            return WTF::nullopt;
    485471       
    486472        Vector<T, inlineCapacity, OverflowHandler, minCapacity> vector;
    487473        vector.grow(size);
    488474
    489         if (!decoder.decodeFixedLengthData(reinterpret_cast<uint8_t*>(vector.data()), size * sizeof(T), alignof(T))) {
    490             decoder.markInvalid();
    491             return WTF::nullopt;
    492         }
     475        if (!decoder.decodeFixedLengthData(reinterpret_cast<uint8_t*>(vector.data()), size * sizeof(T), alignof(T)))
     476            return WTF::nullopt;
    493477
    494478        return vector;
    … …  
    526510                return WTF::nullopt;
    527511
    528             if (UNLIKELY(!HashMapType::isValidKey(*key))) {
    529                 decoder.markInvalid();
    530                 return WTF::nullopt;
    531             }
     512            if (UNLIKELY(!HashMapType::isValidKey(*key)))
     513                return WTF::nullopt;
    532514
    533515            if (UNLIKELY(!hashMap.add(WTFMove(*key), WTFMove(*value)).isNewEntry)) {
    534516                // The hash map already has the specified key, bail.
    535                 decoder.markInvalid();
    536517                return WTF::nullopt;
    537518            }
    … …  
    586567                return WTF::nullopt;
    587568
    588             if (UNLIKELY(!HashSetType::isValidValue(*key))) {
    589                 decoder.markInvalid();
    590                 return WTF::nullopt;
    591             }
     569            if (UNLIKELY(!HashSetType::isValidValue(*key)))
     570                return WTF::nullopt;
    592571
    593572            if (UNLIKELY(!hashSet.add(WTFMove(*key)).isNewEntry)) {
    594573                // The hash set already has the specified key, bail.
    595                 decoder.markInvalid();
    596574                return WTF::nullopt;
    597575            }
    … …  
    631609                return false;
    632610
    633             if (UNLIKELY(!HashCountedSetType::isValidValue(key))) {
    634                 decoder.markInvalid();
     611            if (UNLIKELY(!HashCountedSetType::isValidValue(key)))
    635612                return false;
    636             }
    637613
    638614            if (UNLIKELY(!tempHashCountedSet.add(key, count).isNewEntry)) {
    639615                // The hash counted set already has the specified key, bail.
    640                 decoder.markInvalid();
    641616                return false;
    642617            }
  • trunk/Source/WebKit/Platform/IPC/Connection.cpp

    r276345 r276678  
    3535#include <wtf/Lock.h>
    3636#include <wtf/NeverDestroyed.h>
     37#include <wtf/ObjectIdentifier.h>
    3738#include <wtf/RunLoop.h>
    3839#include <wtf/text/WTFString.h>
    … …  
    236237struct Connection::PendingSyncReply {
    237238    // The request ID.
    238     uint64_t syncRequestID { 0 };
     239    Connection::SyncRequestID syncRequestID;
    239240
    240241    // The reply decoder, will be null if there was an error processing the sync
    … …  
    247248    PendingSyncReply() = default;
    248249
    249     explicit PendingSyncReply(uint64_t syncRequestID)
     250    explicit PendingSyncReply(Connection::SyncRequestID syncRequestID)
    250251        : syncRequestID(syncRequestID)
    251252    {
    … …  
    288289    , m_uniqueID(UniqueID::generate())
    289290    , m_isServer(isServer)
    290     , m_syncRequestID(0)
    291291    , m_onlySendMessagesAsDispatchWhenWaitingForSyncReplyWhenProcessingSuchAMessage(false)
    292292    , m_shouldExitOnSyncMessageSendFailure(false)
    … …  
    391391    }
    392392
    393     uint64_t syncRequestID = 0;
    394     if (!decoder->decode(syncRequestID) || !syncRequestID) {
     393    SyncRequestID syncRequestID;
     394    if (UNLIKELY(!decoder->decode(syncRequestID))) {
    395395        // We received an invalid sync message.
    396396        // FIXME: Handle this.
    397         decoder->markInvalid();
    398         return;
    399     }
    400 
    401     auto replyEncoder = makeUniqueRef<Encoder>(MessageName::SyncMessageReply, syncRequestID);
     397        return;
     398    }
     399
     400    auto replyEncoder = makeUniqueRef<Encoder>(MessageName::SyncMessageReply, syncRequestID.toUInt64());
    402401
    403402    // Hand off both the decoder and encoder to the work queue message receiver.
    … …  
    442441}
    443442
    444 UniqueRef<Encoder> Connection::createSyncMessageEncoder(MessageName messageName, uint64_t destinationID, uint64_t& syncRequestID)
     443UniqueRef<Encoder> Connection::createSyncMessageEncoder(MessageName messageName, uint64_t destinationID, SyncRequestID& syncRequestID)
    445444{
    446445    auto encoder = makeUniqueRef<Encoder>(messageName, destinationID);
    … …  
    473472
    474473    if (isMainRunLoop() && m_inDispatchMessageMarkedToUseFullySynchronousModeForTesting && !encoder->isSyncMessage() && !(encoder->messageReceiverName() == ReceiverName::IPC) && !sendOptions.contains(SendOption::IgnoreFullySynchronousMode)) {
    475         uint64_t syncRequestID;
     474        SyncRequestID syncRequestID;
    476475        auto wrappedMessage = createSyncMessageEncoder(MessageName::WrappedAsyncMessageForTesting, encoder->destinationID(), syncRequestID);
    477476        wrappedMessage->setFullySynchronousModeForTesting();
    … …  
    591590}
    592591
    593 bool Connection::pushPendingSyncRequestID(uint64_t syncRequestID)
     592bool Connection::pushPendingSyncRequestID(SyncRequestID syncRequestID)
    594593{
    595594    {
    … …  
    603602}
    604603
    605 void Connection::popPendingSyncRequestID(uint64_t syncRequestID)
     604void Connection::popPendingSyncRequestID(SyncRequestID syncRequestID)
    606605{
    607606    --m_inSendSyncCount;
    … …  
    611610}
    612611
    613 std::unique_ptr<Decoder> Connection::sendSyncMessage(uint64_t syncRequestID, UniqueRef<Encoder>&& encoder, Timeout timeout, OptionSet<SendSyncOption> sendSyncOptions)
     612std::unique_ptr<Decoder> Connection::sendSyncMessage(SyncRequestID syncRequestID, UniqueRef<Encoder>&& encoder, Timeout timeout, OptionSet<SendSyncOption> sendSyncOptions)
    614613{
    615614    ASSERT(syncRequestID);
    … …  
    649648}
    650649
    651 std::unique_ptr<Decoder> Connection::waitForSyncReply(uint64_t syncRequestID, MessageName messageName, Timeout timeout, OptionSet<SendSyncOption> sendSyncOptions)
     650std::unique_ptr<Decoder> Connection::waitForSyncReply(SyncRequestID syncRequestID, MessageName messageName, Timeout timeout, OptionSet<SendSyncOption> sendSyncOptions)
    652651{
    653652    timeout = timeoutRespectingIgnoreTimeoutsForTesting(timeout);
    … …  
    681680        // any more incoming messages.
    682681        if (!isValid()) {
    683             RELEASE_LOG_ERROR(IPC, "Connection::waitForSyncReply: Connection no longer valid, id=%" PRIu64, syncRequestID);
     682            RELEASE_LOG_ERROR(IPC, "Connection::waitForSyncReply: Connection no longer valid, id=%" PRIu64, syncRequestID.toUInt64());
    684683            didReceiveSyncReply(sendSyncOptions);
    685684            return nullptr;
    … …  
    693692
    694693#if OS(DARWIN)
    695     RELEASE_LOG_ERROR(IPC, "Connection::waitForSyncReply: Timed-out while waiting for reply for %{public}s from process %d, id=%" PRIu64, description(messageName), remoteProcessID(), syncRequestID);
     694    RELEASE_LOG_ERROR(IPC, "Connection::waitForSyncReply: Timed-out while waiting for reply for %{public}s from process %d, id=%" PRIu64, description(messageName), remoteProcessID(), syncRequestID.toUInt64());
    696695#else
    697     RELEASE_LOG_ERROR(IPC, "Connection::waitForSyncReply: Timed-out while waiting for reply for %s, id=%" PRIu64, description(messageName), syncRequestID);
     696    RELEASE_LOG_ERROR(IPC, "Connection::waitForSyncReply: Timed-out while waiting for reply for %s, id=%" PRIu64, description(messageName), syncRequestID.toUInt64());
    698697#endif
    699698
    … …  
    713712            PendingSyncReply& pendingSyncReply = m_pendingSyncReplies[i - 1];
    714713
    715             if (pendingSyncReply.syncRequestID != decoder->destinationID())
     714            if (pendingSyncReply.syncRequestID.toUInt64() != decoder->destinationID())
    716715                continue;
    717716
    … …  
    927926    ASSERT(decoder.isSyncMessage());
    928927
    929     uint64_t syncRequestID = 0;
    930     if (!decoder.decode(syncRequestID) || !syncRequestID) {
     928    SyncRequestID syncRequestID;
     929    if (UNLIKELY(!decoder.decode(syncRequestID))) {
    931930        // We received an invalid sync message.
    932         decoder.markInvalid();
    933         return;
    934     }
    935 
    936     auto replyEncoder = makeUniqueRef<Encoder>(MessageName::SyncMessageReply, syncRequestID);
     931        return;
     932    }
     933
     934    auto replyEncoder = makeUniqueRef<Encoder>(MessageName::SyncMessageReply, syncRequestID.toUInt64());
    937935
    938936    bool wasHandled = false;
  • trunk/Source/WebKit/Platform/IPC/Connection.h

    r276345 r276678  
    107107class Connection : public ThreadSafeRefCounted<Connection, WTF::DestructionThread::MainRunLoop> {
    108108public:
     109    enum SyncRequestIDType { };
     110    using SyncRequestID = ObjectIdentifier<SyncRequestIDType>;
     111
    109112    class Client : public MessageReceiver {
    110113    public:
    … …  
    277280
    278281    bool sendMessage(UniqueRef<Encoder>&&, OptionSet<SendOption> sendOptions);
    279     UniqueRef<Encoder> createSyncMessageEncoder(MessageName, uint64_t destinationID, uint64_t& syncRequestID);
    280     std::unique_ptr<Decoder> sendSyncMessage(uint64_t syncRequestID, UniqueRef<Encoder>&&, Timeout, OptionSet<SendSyncOption> sendSyncOptions);
     282    UniqueRef<Encoder> createSyncMessageEncoder(MessageName, uint64_t destinationID, SyncRequestID&);
     283    std::unique_ptr<Decoder> sendSyncMessage(SyncRequestID, UniqueRef<Encoder>&&, Timeout, OptionSet<SendSyncOption> sendSyncOptions);
    281284    bool sendSyncReply(UniqueRef<Encoder>&&);
    282285
    … …  
    325328   
    326329    std::unique_ptr<Decoder> waitForMessage(MessageName, uint64_t destinationID, Timeout, OptionSet<WaitForOption>);
    327     uint64_t makeSyncRequestID() { return ++m_syncRequestID; }
    328     bool pushPendingSyncRequestID(uint64_t syncRequestID);
    329     void popPendingSyncRequestID(uint64_t syncRequestID);
    330     std::unique_ptr<Decoder> waitForSyncReply(uint64_t syncRequestID, MessageName, Timeout, OptionSet<SendSyncOption>);
     330
     331    SyncRequestID makeSyncRequestID() { return SyncRequestID::generateThreadSafe(); }
     332    bool pushPendingSyncRequestID(SyncRequestID);
     333    void popPendingSyncRequestID(SyncRequestID);
     334    std::unique_ptr<Decoder> waitForSyncReply(SyncRequestID, MessageName, Timeout, OptionSet<SendSyncOption>);
    331335
    332336    void enqueueMatchingMessagesToMessageReceiveQueue(Locker<Lock>& incomingMessagesLocker, MessageReceiveQueue&, ReceiverName, uint64_t destinationID);
    … …  
    383387    bool m_isServer;
    384388    std::atomic<bool> m_isValid { true };
    385     std::atomic<uint64_t> m_syncRequestID;
    386389
    387390    bool m_onlySendMessagesAsDispatchWhenWaitingForSyncReplyWhenProcessingSuchAMessage;
    … …  
    559562    RELEASE_ASSERT(RunLoop::isMain());
    560563
    561     uint64_t syncRequestID = 0;
     564    SyncRequestID syncRequestID;
    562565    auto encoder = createSyncMessageEncoder(T::name(), destinationID, syncRequestID);
    563566
  • trunk/Source/WebKit/Platform/IPC/Decoder.cpp

    r276651 r276678  
    8080    , m_attachments { WTFMove(attachments) }
    8181{
    82     if (reinterpret_cast<uintptr_t>(m_buffer) % alignof(uint64_t)) {
     82    if (UNLIKELY(reinterpret_cast<uintptr_t>(m_buffer) % alignof(uint64_t))) {
    8383        markInvalid();
    8484        return;
    8585    }
    8686
    87     if (!decode(m_messageFlags)) {
    88         markInvalid();
    89         return;
    90     }
    91 
    92     if (!decode(m_messageName)) {
    93         markInvalid();
    94         return;
    95     }
    96 
    97     if (!decode(m_destinationID)) {
    98         markInvalid();
    99         return;
    100     }
     87    if (UNLIKELY(!decode(m_messageFlags)))
     88        return;
     89
     90    if (UNLIKELY(!decode(m_messageName)))
     91        return;
     92
     93    if (UNLIKELY(!decode(m_destinationID)))
     94        return;
    10195}
    10296
    … …  
    107101    , m_bufferDeallocator([] (const uint8_t*, size_t) { })
    108102{
    109     if (reinterpret_cast<uintptr_t>(m_buffer) % alignof(uint64_t))
     103    if (UNLIKELY(reinterpret_cast<uintptr_t>(m_buffer) % alignof(uint64_t)))
    110104        markInvalid();
    111105}
    … …  
    118112    , m_destinationID(destinationID)
    119113{
    120     if (!decode(m_messageName)) {
    121         markInvalid();
    122         return;
    123     }
     114    if (UNLIKELY(!decode(m_messageName)))
     115        return;
    124116}
    125117
    … …  
    200192{
    201193    const uint8_t* alignedPosition = roundUpToAlignment(m_bufferPos, alignment);
    202     if (!alignedBufferIsLargeEnoughToContain(alignedPosition, m_buffer, m_bufferEnd, size)) {
     194    if (UNLIKELY(!alignedBufferIsLargeEnoughToContain(alignedPosition, m_buffer, m_bufferEnd, size))) {
    203195        // We've walked off the end of this buffer.
    204196        markInvalid();
  • trunk/Source/WebKit/Platform/IPC/Decoder.h

    r274565 r276678  
    9090    {
    9191        using Impl = ArgumentCoder<std::remove_const_t<std::remove_reference_t<T>>, void>;
    92         if constexpr(HasLegacyDecoder<T, Impl>::value)
    93             return Impl::decode(*this, t);
    94         else {
     92        if constexpr(HasLegacyDecoder<T, Impl>::value) {
     93            if (UNLIKELY(!Impl::decode(*this, t))) {
     94                markInvalid();
     95                return false;
     96            }
     97        } else {
    9598            Optional<T> optional;
    9699            *this >> optional;
    97             if (!optional)
     100            if (UNLIKELY(!optional)) {
     101                markInvalid();
    98102                return false;
     103            }
    99104            t = WTFMove(*optional);
    100             return true;
    101105        }
     106        return true;
    102107    }
    103108
    … …  
    106111    {
    107112        using Impl = ArgumentCoder<std::remove_const_t<std::remove_reference_t<T>>, void>;
    108         if constexpr(HasModernDecoder<T, Impl>::value)
     113        if constexpr(HasModernDecoder<T, Impl>::value) {
    109114            t = Impl::decode(*this);
    110         else {
     115            if (UNLIKELY(!t))
     116                markInvalid();
     117        } else {
    111118            T v;
    112             if (Impl::decode(*this, v))
     119            if (LIKELY(Impl::decode(*this, v)))
    113120                t = WTFMove(v);
     121            else
     122                markInvalid();
    114123        }
    115124        return *this;
  • trunk/Source/WebKit/Platform/IPC/HandleMessage.h

    r274433 r276678  
    114114    Optional<typename CodingType<typename T::Arguments>::Type> arguments;
    115115    decoder >> arguments;
    116     if (!arguments) {
    117         decoder.markInvalid();
    118         return;
    119     }
     116    if (UNLIKELY(!arguments))
     117        return;
    120118
    121119    callMemberFunction(WTFMove(*arguments), object, function);
    … …  
    127125    Optional<typename CodingType<typename T::Arguments>::Type> arguments;
    128126    decoder >> arguments;
    129     if (!arguments) {
    130         decoder.markInvalid();
    131         return;
    132     }
     127    if (UNLIKELY(!arguments))
     128        return;
    133129    callMemberFunction(connection, WTFMove(*arguments), object, function);
    134130}
    … …  
    139135    Optional<typename CodingType<typename T::Arguments>::Type> arguments;
    140136    decoder >> arguments;
    141     if (!arguments) {
    142         decoder.markInvalid();
     137    if (UNLIKELY(!arguments))
    143138        return false;
    144     }
    145139
    146140    typename T::DelayedReply completionHandler = [replyEncoder = WTFMove(replyEncoder), connection = makeRef(connection)] (auto&&... args) mutable {
    … …  
    156150    Optional<typename CodingType<typename T::Arguments>::Type> arguments;
    157151    decoder >> arguments;
    158     if (!arguments) {
    159         decoder.markInvalid();
     152    if (UNLIKELY(!arguments))
    160153        return false;
    161     }
    162154   
    163155    typename T::DelayedReply completionHandler = [replyEncoder = WTFMove(replyEncoder), connection = makeRef(connection)] (auto&&... args) mutable {
    … …  
    171163void handleMessageSynchronous(StreamServerConnectionBase& connection, Decoder& decoder, C* object, MF function)
    172164{
    173     uint64_t syncRequestID = 0;
    174     if (!decoder.decode(syncRequestID) || !syncRequestID) {
    175         decoder.markInvalid();
    176         return;
    177     }
    178 
    179     Optional<typename CodingType<typename T::Arguments>::Type> arguments;
    180     decoder >> arguments;
    181     if (!arguments) {
    182         decoder.markInvalid();
    183         return;
    184     }
     165    Connection::SyncRequestID syncRequestID;
     166    if (UNLIKELY(!decoder.decode(syncRequestID)))
     167        return;
     168
     169    Optional<typename CodingType<typename T::Arguments>::Type> arguments;
     170    decoder >> arguments;
     171    if (UNLIKELY(!arguments))
     172        return;
    185173
    186174    typename T::DelayedReply completionHandler = [syncRequestID, connection = makeRef(connection)] (auto&&... args) mutable {
    … …  
    195183    Optional<uint64_t> listenerID;
    196184    decoder >> listenerID;
    197     if (!listenerID) {
    198         decoder.markInvalid();
    199         return;
    200     }
    201 
    202     Optional<typename CodingType<typename T::Arguments>::Type> arguments;
    203     decoder >> arguments;
    204     if (!arguments) {
    205         decoder.markInvalid();
    206         return;
    207     }
     185    if (!listenerID)
     186        return;
     187
     188    Optional<typename CodingType<typename T::Arguments>::Type> arguments;
     189    decoder >> arguments;
     190    if (UNLIKELY(!arguments))
     191        return;
    208192
    209193    typename T::AsyncReply completionHandler = { [listenerID = *listenerID, connection = makeRef(connection)] (auto&&... args) mutable {
    … …  
    219203    Optional<typename CodingType<typename T::Arguments>::Type> arguments;
    220204    decoder >> arguments;
    221     if (!arguments) {
    222         decoder.markInvalid();
    223         return;
    224     }
     205    if (UNLIKELY(!arguments))
     206        return;
    225207
    226208    typename T::AsyncReply completionHandler = [listenerID = decoder.destinationID(), connection = makeRef(connection)] (auto&&... args) mutable {
  • trunk/Source/WebKit/Platform/IPC/StreamServerConnection.h

    r276300 r276678  
    5454
    5555    template<typename T, typename... Arguments>
    56     void sendSyncReply(uint64_t syncRequestID, Arguments&&...);
     56    void sendSyncReply(Connection::SyncRequestID, Arguments&&...);
    5757
    5858protected:
    … …  
    103103
    104104template<typename T, typename... Arguments>
    105 void StreamServerConnectionBase::sendSyncReply(uint64_t syncRequestID, Arguments&&... arguments)
     105void StreamServerConnectionBase::sendSyncReply(Connection::SyncRequestID syncRequestID, Arguments&&... arguments)
    106106{
    107107    if constexpr(T::isReplyStreamEncodable) {
    … …  
    116116        }
    117117    }
    118     auto encoder = makeUniqueRef<Encoder>(MessageName::SyncMessageReply, syncRequestID);
     118    auto encoder = makeUniqueRef<Encoder>(MessageName::SyncMessageReply, syncRequestID.toUInt64());
    119119
    120120    (encoder.get() << ... << arguments);
  • trunk/Source/WebKit/WebProcess/Plugins/Plugin.cpp

    r273075 r276678  
    7474        return false;
    7575#endif
    76     if (parameters.names.size() != parameters.values.size()) {
    77         decoder.markInvalid();
     76    if (parameters.names.size() != parameters.values.size())
    7877        return false;
    79     }
    8078
    8179    return true;
  • trunk/Source/WebKit/WebProcess/WebPage/IPCTestingAPI.cpp

    r274189 r276678  
    738738    // FIXME: Support the options.
    739739
    740     uint64_t syncRequestID = 0;
     740    IPC::Connection::SyncRequestID syncRequestID;
    741741    auto messageName = static_cast<IPC::MessageName>(*messageID);
    742742    auto encoder = connection->createSyncMessageEncoder(messageName, *destinationID, syncRequestID);
    … …  
    971971
    972972    if (decoder.isSyncMessage()) {
    973         if (uint64_t syncRequestID = 0; decoder.decode(syncRequestID)) {
    974             jsResult->putDirect(vm, JSC::Identifier::fromString(vm, "syncRequestID"), JSC::JSValue(syncRequestID));
     973        IPC::Connection::SyncRequestID syncRequestID;
     974        if (decoder.decode(syncRequestID)) {
     975            jsResult->putDirect(vm, JSC::Identifier::fromString(vm, "syncRequestID"), JSC::JSValue(syncRequestID.toUInt64()));
    975976            RETURN_IF_EXCEPTION(scope, nullptr);
    976977        }
Note: See TracChangeset for help on using the changeset viewer.