summaryrefslogtreecommitdiff
path: root/daemon/gvfshttpinputstream.c
diff options
context:
space:
mode:
authorOndrej Holy <oholy@redhat.com>2015-09-10 10:38:16 +0200
committerOndrej Holy <oholy@redhat.com>2015-11-26 14:41:34 +0100
commitcb950723da8b6817dbe894fed6a78fa77c932d16 (patch)
tree8909b00972dd99d358d30d288894593152d5aeee /daemon/gvfshttpinputstream.c
parentec40e26ac69896e91c128e86b11cddc76e892d12 (diff)
downloadgvfs-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
Diffstat (limited to 'daemon/gvfshttpinputstream.c')
-rw-r--r--daemon/gvfshttpinputstream.c18
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),