diff options
author | Ondrej Holy <oholy@redhat.com> | 2015-09-10 10:38:16 +0200 |
---|---|---|
committer | Ondrej Holy <oholy@redhat.com> | 2015-11-26 14:41:34 +0100 |
commit | cb950723da8b6817dbe894fed6a78fa77c932d16 (patch) | |
tree | 8909b00972dd99d358d30d288894593152d5aeee | |
parent | ec40e26ac69896e91c128e86b11cddc76e892d12 (diff) | |
download | gvfs-cb950723da8b6817dbe894fed6a78fa77c932d16.tar.gz |
http: Return error if seek was not successful
Some webdav servers doesn't implement range requests, which are
necessary for a seek support. GVfsHttpInputStream doesn't handle this
case. Consequently g_seekable_tell returns a requested offset, however
g_input_stream_read returns bytes from a beginning of a file.
Return error if Content-Range header field is missing, or the range is
not valid. This change is needed to avoid data corruption when reading.
https://bugzilla.gnome.org/show_bug.cgi?id=754824
-rw-r--r-- | daemon/gvfshttpinputstream.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/daemon/gvfshttpinputstream.c b/daemon/gvfshttpinputstream.c index f96f52db..5eafc299 100644 --- a/daemon/gvfshttpinputstream.c +++ b/daemon/gvfshttpinputstream.c @@ -23,6 +23,7 @@ #include <string.h> #include <glib.h> +#include <glib/gi18n.h> #include <gio/gio.h> #include <libsoup/soup.h> @@ -353,6 +354,23 @@ read_send_callback (GObject *object, g_object_unref (task); return; } + if (priv->range) + { + gboolean status; + goffset start, end; + + status = soup_message_headers_get_content_range (priv->msg->response_headers, + &start, &end, NULL); + if (!status || start != priv->request_offset) + { + g_task_return_new_error (task, + G_IO_ERROR, + G_IO_ERROR_FAILED, + _("Error seeking in stream")); + g_object_unref (task); + return; + } + } g_input_stream_read_async (priv->stream, rasd->buffer, rasd->count, g_task_get_priority (task), |