block/curl: HTTP header fields allow whitespace around values
RH-Author: Richard Jones <rjones@redhat.com> Message-id: <20200528142737.17318-2-rjones@redhat.com> Patchwork-id: 96894 O-Subject: [RHEL-AV-8.2.1 qemu-kvm PATCH 1/2] block/curl: HTTP header fields allow whitespace around values Bugzilla: 1841038 RH-Acked-by: Eric Blake <eblake@redhat.com> RH-Acked-by: Max Reitz <mreitz@redhat.com> RH-Acked-by: Danilo de Paula <ddepaula@redhat.com> From: David Edmondson <david.edmondson@oracle.com> RFC 7230 section 3.2 indicates that whitespace is permitted between the field name and field value and after the field value. Signed-off-by: David Edmondson <david.edmondson@oracle.com> Message-Id: <20200224101310.101169-2-david.edmondson@oracle.com> Reviewed-by: Max Reitz <mreitz@redhat.com> Signed-off-by: Max Reitz <mreitz@redhat.com> (cherry picked from commit 7788a319399f17476ff1dd43164c869e320820a2) Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
This commit is contained in:
parent
7cdb42a8eb
commit
a3094362d2
75
block-curl-HTTP-header-fields-allow-whitespace-aroun.patch
Normal file
75
block-curl-HTTP-header-fields-allow-whitespace-aroun.patch
Normal file
@ -0,0 +1,75 @@
|
|||||||
|
From c8fd37c06fd24d1242629dda329dd16bea20f319 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Richard Jones <rjones@redhat.com>
|
||||||
|
Date: Thu, 28 May 2020 14:27:36 +0100
|
||||||
|
Subject: [PATCH] block/curl: HTTP header fields allow whitespace around values
|
||||||
|
|
||||||
|
RH-Author: Richard Jones <rjones@redhat.com>
|
||||||
|
Message-id: <20200528142737.17318-2-rjones@redhat.com>
|
||||||
|
Patchwork-id: 96894
|
||||||
|
O-Subject: [RHEL-AV-8.2.1 qemu-kvm PATCH 1/2] block/curl: HTTP header fields allow whitespace around values
|
||||||
|
Bugzilla: 1841038
|
||||||
|
RH-Acked-by: Eric Blake <eblake@redhat.com>
|
||||||
|
RH-Acked-by: Max Reitz <mreitz@redhat.com>
|
||||||
|
RH-Acked-by: Danilo de Paula <ddepaula@redhat.com>
|
||||||
|
|
||||||
|
From: David Edmondson <david.edmondson@oracle.com>
|
||||||
|
|
||||||
|
RFC 7230 section 3.2 indicates that whitespace is permitted between
|
||||||
|
the field name and field value and after the field value.
|
||||||
|
|
||||||
|
Signed-off-by: David Edmondson <david.edmondson@oracle.com>
|
||||||
|
Message-Id: <20200224101310.101169-2-david.edmondson@oracle.com>
|
||||||
|
Reviewed-by: Max Reitz <mreitz@redhat.com>
|
||||||
|
Signed-off-by: Max Reitz <mreitz@redhat.com>
|
||||||
|
(cherry picked from commit 7788a319399f17476ff1dd43164c869e320820a2)
|
||||||
|
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
|
||||||
|
---
|
||||||
|
block/curl.c | 31 +++++++++++++++++++++++++++----
|
||||||
|
1 file changed, 27 insertions(+), 4 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/block/curl.c b/block/curl.c
|
||||||
|
index d4c8e94f3e..bfabe7eabd 100644
|
||||||
|
--- a/block/curl.c
|
||||||
|
+++ b/block/curl.c
|
||||||
|
@@ -212,11 +212,34 @@ static size_t curl_header_cb(void *ptr, size_t size, size_t nmemb, void *opaque)
|
||||||
|
{
|
||||||
|
BDRVCURLState *s = opaque;
|
||||||
|
size_t realsize = size * nmemb;
|
||||||
|
- const char *accept_line = "Accept-Ranges: bytes";
|
||||||
|
+ const char *header = (char *)ptr;
|
||||||
|
+ const char *end = header + realsize;
|
||||||
|
+ const char *accept_ranges = "Accept-Ranges:";
|
||||||
|
+ const char *bytes = "bytes";
|
||||||
|
|
||||||
|
- if (realsize >= strlen(accept_line)
|
||||||
|
- && strncmp((char *)ptr, accept_line, strlen(accept_line)) == 0) {
|
||||||
|
- s->accept_range = true;
|
||||||
|
+ if (realsize >= strlen(accept_ranges)
|
||||||
|
+ && strncmp(header, accept_ranges, strlen(accept_ranges)) == 0) {
|
||||||
|
+
|
||||||
|
+ char *p = strchr(header, ':') + 1;
|
||||||
|
+
|
||||||
|
+ /* Skip whitespace between the header name and value. */
|
||||||
|
+ while (p < end && *p && g_ascii_isspace(*p)) {
|
||||||
|
+ p++;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ if (end - p >= strlen(bytes)
|
||||||
|
+ && strncmp(p, bytes, strlen(bytes)) == 0) {
|
||||||
|
+
|
||||||
|
+ /* Check that there is nothing but whitespace after the value. */
|
||||||
|
+ p += strlen(bytes);
|
||||||
|
+ while (p < end && *p && g_ascii_isspace(*p)) {
|
||||||
|
+ p++;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ if (p == end || !*p) {
|
||||||
|
+ s->accept_range = true;
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
}
|
||||||
|
|
||||||
|
return realsize;
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
||||||
Loading…
x
Reference in New Issue
Block a user