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

Changeset 259789 in webkit


Ignore:
Timestamp:
Apr 9, 2020, 4:01:58 AM (6 years ago)
Author:
ddkilzer@apple.com
Message:

UserData::decode should add bounds checks
<https://webkit.org/b/210247>
<rdar://problem/61467748>

Reviewed by Alex Christensen.

  • Shared/UserData.cpp:

(WebKit::UserData::decode):

  • Add bounds checks using WTF::isInBounds<size_t>.
  • Shared/UserData.h:

(WebKit::UserData::decode):

  • Add WARN_UNUSED_RETURN.
Location:
trunk/Source/WebKit
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r259788 r259789  
     12020-04-09  David Kilzer  <ddkilzer@apple.com>
     2
     3        UserData::decode should add bounds checks
     4        <https://webkit.org/b/210247>
     5        <rdar://problem/61467748>
     6
     7        Reviewed by Alex Christensen.
     8
     9        * Shared/UserData.cpp:
     10        (WebKit::UserData::decode):
     11        - Add bounds checks using WTF::isInBounds<size_t>.
     12        * Shared/UserData.h:
     13        (WebKit::UserData::decode):
     14        - Add WARN_UNUSED_RETURN.
     15
    1162020-04-09  David Kilzer  <ddkilzer@apple.com>
    217
  • trunk/Source/WebKit/Shared/UserData.cpp

    r251436 r259789  
    5050#include "WebRenderLayer.h"
    5151#include "WebRenderObject.h"
     52#include <wtf/CheckedArithmetic.h>
    5253
    5354#if PLATFORM(COCOA)
     
    341342    switch (type) {
    342343    case API::Object::Type::Array: {
    343         uint64_t size;
    344         if (!decoder.decode(size))
    345             return false;
     344        uint64_t decodedSize;
     345        if (!decoder.decode(decodedSize))
     346            return false;
     347
     348        if (!WTF::isInBounds<size_t>(decodedSize))
     349            return false;
     350
     351        auto size = static_cast<size_t>(decodedSize);
    346352
    347353        Vector<RefPtr<API::Object>> elements;
     
    377383
    378384    case API::Object::Type::Dictionary: {
    379         uint64_t size;
    380         if (!decoder.decode(size))
    381             return false;
     385        uint64_t decodedSize;
     386        if (!decoder.decode(decodedSize))
     387            return false;
     388
     389        if (!WTF::isInBounds<size_t>(decodedSize))
     390            return false;
     391
     392        auto size = static_cast<size_t>(decodedSize);
    382393
    383394        API::Dictionary::MapType map;
  • trunk/Source/WebKit/Shared/UserData.h

    r204668 r259789  
    5353
    5454    void encode(IPC::Encoder&) const;
    55     static bool decode(IPC::Decoder&, UserData&);
     55    static bool decode(IPC::Decoder&, UserData&) WARN_UNUSED_RETURN;
    5656
    5757    static void encode(IPC::Encoder&, const API::Object*);
    58     static bool decode(IPC::Decoder&, RefPtr<API::Object>&);
     58    static bool decode(IPC::Decoder&, RefPtr<API::Object>&) WARN_UNUSED_RETURN;
    5959
    6060private:
Note: See TracChangeset for help on using the changeset viewer.