mrc0mmand / rpms / libguestfs

Forked from rpms/libguestfs 3 years ago
Clone

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

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