mrc0mmand / rpms / libguestfs

Forked from rpms/libguestfs 3 years ago
Clone

Blame SOURCES/0074-vCenter-fix-parsing-of-HTTP-status-string-RHBZ-18373.patch

da373f
From 318aa975b212c9b8778606ce440c95682f99c700 Mon Sep 17 00:00:00 2001
da373f
From: Pino Toscano <ptoscano@redhat.com>
da373f
Date: Tue, 19 May 2020 12:14:18 +0200
da373f
Subject: [PATCH] vCenter: fix parsing of HTTP status string (RHBZ#1837328)
da373f
da373f
vCenter 7 answers with an HTTP/2 status string, so we cannot extract
da373f
the status code from it by using fixed positions in that string.
da373f
Hence, pick the status code by reading what's after the whitespace.
da373f
da373f
Tested with vCenter 6.5 and 7.
da373f
da373f
(cherry picked from commit d2aa82317964d62fcc8dc7b6737773003d04b998
da373f
in virt-v2v)
da373f
---
da373f
 v2v/vCenter.ml | 4 +++-
da373f
 1 file changed, 3 insertions(+), 1 deletion(-)
da373f
da373f
diff --git a/v2v/vCenter.ml b/v2v/vCenter.ml
da373f
index b1b9f9b15..b15e2f7d0 100644
da373f
--- a/v2v/vCenter.ml
da373f
+++ b/v2v/vCenter.ml
da373f
@@ -213,7 +213,9 @@ and fetch_headers_from_url password_file uri sslverify https_url =
da373f
     | [] ->
da373f
        dump_response stderr;
da373f
        error (f_"vcenter: no status code in output of ‘curl’ command.  Is ‘curl’ installed?")
da373f
-    | ss -> String.sub (List.hd (List.rev ss)) 9 3 in
da373f
+    | ss ->
da373f
+      let s = List.hd (List.rev ss) in
da373f
+      String.sub s (String.index s ' ' + 1) 3 in
da373f
 
da373f
   let headers =
da373f
     List.map (
da373f
-- 
da373f
2.18.4
da373f