diff options
author | Peter Maydell | 2021-09-20 10:54:32 +0200 |
---|---|---|
committer | Peter Maydell | 2021-09-20 10:54:32 +0200 |
commit | e59a7e0ec5be2ef3a71b70ddeefc564af9c104c3 (patch) | |
tree | d709871c53695834638319907b0687f619701866 /contrib | |
parent | Merge remote-tracking branch 'remotes/dgilbert-gitlab/tags/pull-virtiofs-2021... (diff) | |
download | qemu-e59a7e0ec5be2ef3a71b70ddeefc564af9c104c3.tar.gz qemu-e59a7e0ec5be2ef3a71b70ddeefc564af9c104c3.tar.xz qemu-e59a7e0ec5be2ef3a71b70ddeefc564af9c104c3.zip |
elf2dmp: Check curl_easy_setopt() return value
Coverity points out that we aren't checking the return value
from curl_easy_setopt().
Fixes: Coverity CID 1458895
Inspired-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Reviewed-by: Viktor Prutyanov <viktor.prutyanov@phystech.edu>
Tested-by: Viktor Prutyanov <viktor.prutyanov@phystech.edu>
Message-id: 20210910170656.366592-2-philmd@redhat.com
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'contrib')
-rw-r--r-- | contrib/elf2dmp/download.c | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/contrib/elf2dmp/download.c b/contrib/elf2dmp/download.c index d09e607431..bd7650a7a2 100644 --- a/contrib/elf2dmp/download.c +++ b/contrib/elf2dmp/download.c @@ -25,21 +25,19 @@ int download_url(const char *name, const char *url) goto out_curl; } - curl_easy_setopt(curl, CURLOPT_URL, url); - curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, NULL); - curl_easy_setopt(curl, CURLOPT_WRITEDATA, file); - curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1); - curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 0); - - if (curl_easy_perform(curl) != CURLE_OK) { - err = 1; - fclose(file); + if (curl_easy_setopt(curl, CURLOPT_URL, url) != CURLE_OK + || curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, NULL) != CURLE_OK + || curl_easy_setopt(curl, CURLOPT_WRITEDATA, file) != CURLE_OK + || curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1) != CURLE_OK + || curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 0) != CURLE_OK + || curl_easy_perform(curl) != CURLE_OK) { unlink(name); - goto out_curl; + fclose(file); + err = 1; + } else { + err = fclose(file); } - err = fclose(file); - out_curl: curl_easy_cleanup(curl); |