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

Changeset 274640 in webkit


Ignore:
Timestamp:
Mar 18, 2021, 4:12:35 AM (5 years ago)
Author:
Carlos Garcia Campos
Message:

[SOUP] SOUP3 crashes inside soup_message_set_request_body
https://bugs.webkit.org/show_bug.cgi?id=223236

Reviewed by Adrian Perez de Castro.

Make WebKitFormDataInputStream implement GPollableInputStream.

  • platform/network/soup/WebKitFormDataInputStream.cpp:

(webkitFormDataInputStreamNew):
(webkitFormDataInputStreamCanPoll):
(webkitFormDataInputStreamIsReadable):
(webkitFormDataInputStreamCreateSource):
(webkitFormDataInputStreamPollableInterfaceInit):

Location:
trunk/Source/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r274639 r274640  
     12021-03-18  Carlos Garcia Campos  <cgarcia@igalia.com>
     2
     3        [SOUP] SOUP3 crashes inside soup_message_set_request_body
     4        https://bugs.webkit.org/show_bug.cgi?id=223236
     5
     6        Reviewed by Adrian Perez de Castro.
     7
     8        Make WebKitFormDataInputStream implement GPollableInputStream.
     9
     10        * platform/network/soup/WebKitFormDataInputStream.cpp:
     11        (webkitFormDataInputStreamNew):
     12        (webkitFormDataInputStreamCanPoll):
     13        (webkitFormDataInputStreamIsReadable):
     14        (webkitFormDataInputStreamCreateSource):
     15        (webkitFormDataInputStreamPollableInterfaceInit):
     16
    1172021-03-18  Lauro Moura  <lmoura@igalia.com>
    218
  • trunk/Source/WebCore/platform/network/soup/WebKitFormDataInputStream.cpp

    r272410 r274640  
    3838    unsigned nextIndex;
    3939    long long currentStreamRangeLength;
     40    bool canPoll;
    4041};
    4142
    42 WEBKIT_DEFINE_TYPE(WebKitFormDataInputStream, webkit_form_data_input_stream, G_TYPE_INPUT_STREAM)
     43static void webkitFormDataInputStreamPollableInterfaceInit(GPollableInputStreamInterface*);
     44
     45WEBKIT_DEFINE_TYPE_WITH_CODE(WebKitFormDataInputStream, webkit_form_data_input_stream, G_TYPE_INPUT_STREAM,
     46    G_IMPLEMENT_INTERFACE(G_TYPE_POLLABLE_INPUT_STREAM, webkitFormDataInputStreamPollableInterfaceInit))
    4347
    4448static bool webkitFormDataInputStreamCreateNextStream(WebKitFormDataInputStream* stream, GCancellable* cancellable)
     
    131135    stream->priv->currentStreamRangeLength = BlobDataItem::toEndOfFile;
    132136
     137    // GFileInputStream is not pollable, so the stream is only pollable if FormData doesn't contain EncodedFileData elements.
     138    stream->priv->canPoll = true;
     139    for (const auto& element : stream->priv->formData->elements()) {
     140        if (WTF::holds_alternative<FormDataElement::EncodedFileData>(element.data)) {
     141            stream->priv->canPoll = false;
     142            break;
     143        }
     144    }
     145
    133146    return adoptGRef(G_INPUT_STREAM((stream)));
    134147}
     
    146159    return g_memory_output_stream_steal_as_bytes(G_MEMORY_OUTPUT_STREAM(outputStream.get()));
    147160}
     161
     162static gboolean webkitFormDataInputStreamCanPoll(GPollableInputStream* stream)
     163{
     164    auto* priv = WEBKIT_FORM_DATA_INPUT_STREAM(stream)->priv;
     165    return priv->canPoll;
     166}
     167
     168static gboolean webkitFormDataInputStreamIsReadable(GPollableInputStream* stream)
     169{
     170    auto* priv = WEBKIT_FORM_DATA_INPUT_STREAM(stream)->priv;
     171    return priv->currentStream || priv->nextIndex < priv->formData->elements().size();
     172}
     173
     174static GSource* webkitFormDataInputStreamCreateSource(GPollableInputStream* stream, GCancellable* cancellable)
     175{
     176    GRefPtr<GSource> base = adoptGRef(g_timeout_source_new(0));
     177    return g_pollable_source_new_full(stream, base.get(), cancellable);
     178}
     179
     180static void webkitFormDataInputStreamPollableInterfaceInit(GPollableInputStreamInterface* iface)
     181{
     182    iface->can_poll = webkitFormDataInputStreamCanPoll;
     183    iface->is_readable = webkitFormDataInputStreamIsReadable;
     184    iface->create_source = webkitFormDataInputStreamCreateSource;
     185}
Note: See TracChangeset for help on using the changeset viewer.