|
|
9ae3a8 |
From d34f673f0d08eff0dce82db232574fe4b5e9ed95 Mon Sep 17 00:00:00 2001
|
|
|
9ae3a8 |
From: Richard Jones <rjones@redhat.com>
|
|
|
9ae3a8 |
Date: Thu, 11 Jun 2015 11:40:10 +0200
|
|
|
9ae3a8 |
Subject: [PATCH 10/30] curl: Remove unnecessary use of goto
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Message-id: <1434022828-13037-4-git-send-email-rjones@redhat.com>
|
|
|
9ae3a8 |
Patchwork-id: 65838
|
|
|
9ae3a8 |
O-Subject: [RHEL-7.2 qemu-kvm v3 PATCH 03/21] curl: Remove unnecessary use of goto
|
|
|
9ae3a8 |
Bugzilla: 1226684
|
|
|
9ae3a8 |
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
9ae3a8 |
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
|
|
|
9ae3a8 |
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
From: Matthew Booth <mbooth@redhat.com>
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
This isn't any of the usually acceptable uses of goto.
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Signed-off-by: Matthew Booth <mbooth@redhat.com>
|
|
|
9ae3a8 |
Tested-by: Richard W.M. Jones <rjones@redhat.com>
|
|
|
9ae3a8 |
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Upstream-status: 9e550b326076caf4a1756b77eee95ad60b4adc27
|
|
|
9ae3a8 |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
9ae3a8 |
---
|
|
|
9ae3a8 |
block/curl.c | 55 +++++++++++++++++++++++++++----------------------------
|
|
|
9ae3a8 |
1 file changed, 27 insertions(+), 28 deletions(-)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
diff --git a/block/curl.c b/block/curl.c
|
|
|
9ae3a8 |
index f69e337..d399e3a 100644
|
|
|
9ae3a8 |
--- a/block/curl.c
|
|
|
9ae3a8 |
+++ b/block/curl.c
|
|
|
9ae3a8 |
@@ -295,39 +295,38 @@ static CURLState *curl_init_state(BDRVCURLState *s)
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
} while(!state);
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
- if (state->curl)
|
|
|
9ae3a8 |
- goto has_curl;
|
|
|
9ae3a8 |
-
|
|
|
9ae3a8 |
- state->curl = curl_easy_init();
|
|
|
9ae3a8 |
- if (!state->curl)
|
|
|
9ae3a8 |
- return NULL;
|
|
|
9ae3a8 |
- curl_easy_setopt(state->curl, CURLOPT_URL, s->url);
|
|
|
9ae3a8 |
- curl_easy_setopt(state->curl, CURLOPT_TIMEOUT, 5);
|
|
|
9ae3a8 |
- curl_easy_setopt(state->curl, CURLOPT_WRITEFUNCTION, (void *)curl_read_cb);
|
|
|
9ae3a8 |
- curl_easy_setopt(state->curl, CURLOPT_WRITEDATA, (void *)state);
|
|
|
9ae3a8 |
- curl_easy_setopt(state->curl, CURLOPT_PRIVATE, (void *)state);
|
|
|
9ae3a8 |
- curl_easy_setopt(state->curl, CURLOPT_AUTOREFERER, 1);
|
|
|
9ae3a8 |
- curl_easy_setopt(state->curl, CURLOPT_FOLLOWLOCATION, 1);
|
|
|
9ae3a8 |
- curl_easy_setopt(state->curl, CURLOPT_NOSIGNAL, 1);
|
|
|
9ae3a8 |
- curl_easy_setopt(state->curl, CURLOPT_ERRORBUFFER, state->errmsg);
|
|
|
9ae3a8 |
- curl_easy_setopt(state->curl, CURLOPT_FAILONERROR, 1);
|
|
|
9ae3a8 |
-
|
|
|
9ae3a8 |
- /* Restrict supported protocols to avoid security issues in the more
|
|
|
9ae3a8 |
- * obscure protocols. For example, do not allow POP3/SMTP/IMAP see
|
|
|
9ae3a8 |
- * CVE-2013-0249.
|
|
|
9ae3a8 |
- *
|
|
|
9ae3a8 |
- * Restricting protocols is only supported from 7.19.4 upwards.
|
|
|
9ae3a8 |
- */
|
|
|
9ae3a8 |
+ if (!state->curl) {
|
|
|
9ae3a8 |
+ state->curl = curl_easy_init();
|
|
|
9ae3a8 |
+ if (!state->curl) {
|
|
|
9ae3a8 |
+ return NULL;
|
|
|
9ae3a8 |
+ }
|
|
|
9ae3a8 |
+ curl_easy_setopt(state->curl, CURLOPT_URL, s->url);
|
|
|
9ae3a8 |
+ curl_easy_setopt(state->curl, CURLOPT_TIMEOUT, 5);
|
|
|
9ae3a8 |
+ curl_easy_setopt(state->curl, CURLOPT_WRITEFUNCTION,
|
|
|
9ae3a8 |
+ (void *)curl_read_cb);
|
|
|
9ae3a8 |
+ curl_easy_setopt(state->curl, CURLOPT_WRITEDATA, (void *)state);
|
|
|
9ae3a8 |
+ curl_easy_setopt(state->curl, CURLOPT_PRIVATE, (void *)state);
|
|
|
9ae3a8 |
+ curl_easy_setopt(state->curl, CURLOPT_AUTOREFERER, 1);
|
|
|
9ae3a8 |
+ curl_easy_setopt(state->curl, CURLOPT_FOLLOWLOCATION, 1);
|
|
|
9ae3a8 |
+ curl_easy_setopt(state->curl, CURLOPT_NOSIGNAL, 1);
|
|
|
9ae3a8 |
+ curl_easy_setopt(state->curl, CURLOPT_ERRORBUFFER, state->errmsg);
|
|
|
9ae3a8 |
+ curl_easy_setopt(state->curl, CURLOPT_FAILONERROR, 1);
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
+ /* Restrict supported protocols to avoid security issues in the more
|
|
|
9ae3a8 |
+ * obscure protocols. For example, do not allow POP3/SMTP/IMAP see
|
|
|
9ae3a8 |
+ * CVE-2013-0249.
|
|
|
9ae3a8 |
+ *
|
|
|
9ae3a8 |
+ * Restricting protocols is only supported from 7.19.4 upwards.
|
|
|
9ae3a8 |
+ */
|
|
|
9ae3a8 |
#if LIBCURL_VERSION_NUM >= 0x071304
|
|
|
9ae3a8 |
- curl_easy_setopt(state->curl, CURLOPT_PROTOCOLS, PROTOCOLS);
|
|
|
9ae3a8 |
- curl_easy_setopt(state->curl, CURLOPT_REDIR_PROTOCOLS, PROTOCOLS);
|
|
|
9ae3a8 |
+ curl_easy_setopt(state->curl, CURLOPT_PROTOCOLS, PROTOCOLS);
|
|
|
9ae3a8 |
+ curl_easy_setopt(state->curl, CURLOPT_REDIR_PROTOCOLS, PROTOCOLS);
|
|
|
9ae3a8 |
#endif
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
#ifdef DEBUG_VERBOSE
|
|
|
9ae3a8 |
- curl_easy_setopt(state->curl, CURLOPT_VERBOSE, 1);
|
|
|
9ae3a8 |
+ curl_easy_setopt(state->curl, CURLOPT_VERBOSE, 1);
|
|
|
9ae3a8 |
#endif
|
|
|
9ae3a8 |
-
|
|
|
9ae3a8 |
-has_curl:
|
|
|
9ae3a8 |
+ }
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
state->s = s;
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
--
|
|
|
9ae3a8 |
1.8.3.1
|
|
|
9ae3a8 |
|