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

Changeset 262242 in webkit


Ignore:
Timestamp:
May 28, 2020, 8:28:26 AM (6 years ago)
Author:
commit-queue@webkit.org
Message:

[WPE][GTK] GVariant decoding must copy the serialized data
​https://bugs.webkit.org/show_bug.cgi?id=212441

Patch by Michael Catanzaro <Michael Catanzaro> on 2020-05-28
Reviewed by Carlos Garcia Campos.

I tracked this down to ArgumentCodersGLib.cpp. The problem is that we construct a GVariant
using g_variant_new_from_data(), which does not copy or take ownership of the data, so here
we accidentally create the GVariant using data we don't own. (Here, the data is owned by the
Decoder itself in its internal m_buffer.) Anyway, this is fixable by manually copying and
freeing it with the GDestroyNotify parameter, but it's easier to switch to
g_variant_new_from_bytes() because GBytes takes ownership when constructed.

  • Shared/glib/ArgumentCodersGLib.cpp:

(IPC::decode):

Location:
trunk/Source/WebKit
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r262240 r262242  
     12020-05-28  Michael Catanzaro  <mcatanzaro@gnome.org>
     2
     3        [WPE][GTK] GVariant decoding must copy the serialized data
     4        https://bugs.webkit.org/show_bug.cgi?id=212441
     5
     6        Reviewed by Carlos Garcia Campos.
     7
     8        I tracked this down to ArgumentCodersGLib.cpp. The problem is that we construct a GVariant
     9        using g_variant_new_from_data(), which does not copy or take ownership of the data, so here
     10        we accidentally create the GVariant using data we don't own. (Here, the data is owned by the
     11        Decoder itself in its internal m_buffer.) Anyway, this is fixable by manually copying and
     12        freeing it with the GDestroyNotify parameter, but it's easier to switch to
     13        g_variant_new_from_bytes() because GBytes takes ownership when constructed.
     14
     15        * Shared/glib/ArgumentCodersGLib.cpp:
     16        (IPC::decode):
     17
    1182020-05-28  Youenn Fablet  <youenn@apple.com>
    219
  • trunk/Source/WebKit/Shared/glib/ArgumentCodersGLib.cpp

    r251181 r262242  
    2929#include "DataReference.h"
    3030#include <glib.h>
     31#include <wtf/glib/GUniquePtr.h>
    3132#include <wtf/text/CString.h>
    3233
    … …  
    6061        return WTF::nullopt;
    6162
    62     auto* variantType = g_variant_type_new(variantTypeString.data());
    63     GRefPtr<GVariant> variant = g_variant_new_from_data(variantType, data.data(), data.size(), FALSE, nullptr, nullptr);
    64     g_variant_type_free(variantType);
    65     return variant;
     63    GUniquePtr<GVariantType> variantType(g_variant_type_new(variantTypeString.data()));
     64    GRefPtr<GBytes> bytes = adoptGRef(g_bytes_new(data.data(), data.size()));
     65    return g_variant_new_from_bytes(variantType.get(), bytes.get(), FALSE);
    6666}
    6767
Note: See TracChangeset for help on using the changeset viewer.