From 4d8267bf4198e5c3ab5a20ab27bbb19144e5023d Mon Sep 17 00:00:00 2001 From: William Douglas Date: Mon, 12 Aug 2024 14:59:15 -0700 Subject: [PATCH] Add error handling for curl_easy_getinfo Set response explicitly in case of curl_easy_getinfo error (though in practice the response isn't modified and so program behavior is the same as before this change). Signed-off-by: William Douglas --- src/swupd_lib/curl.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/swupd_lib/curl.c b/src/swupd_lib/curl.c index 522aed30c..46ed63175 100644 --- a/src/swupd_lib/curl.c +++ b/src/swupd_lib/curl.c @@ -457,7 +457,9 @@ enum download_status process_curl_error_codes(int curl_ret, CURL *curl_handle) } } else { /* download failed but let our caller do it */ long response = 0; - curl_easy_getinfo(curl_handle, CURLINFO_RESPONSE_CODE, &response); + if (curl_easy_getinfo(curl_handle, CURLINFO_RESPONSE_CODE, &response) != CURLE_OK) { + response = -1; // Force error + } debug("Curl - process_curl_error_codes: curl_ret = %d, response = %ld\n", curl_ret, response); switch (response) { case 403: