From bb7b40faae33b3b764429267df0f7c26c9f468b1 Mon Sep 17 00:00:00 2001 From: Jaroslav Rohel Date: Thu, 6 May 2021 17:59:00 +0200 Subject: [PATCH] lr_get_curl_handle: Strict check of `curl_easy_setopt` return code --- librepo/handle.c | 31 ++++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/librepo/handle.c b/librepo/handle.c index 8db9c16..c44ec61 100644 --- a/librepo/handle.c +++ b/librepo/handle.c @@ -59,17 +59,30 @@ lr_get_curl_handle() if (!h) return NULL; - curl_easy_setopt(h, CURLOPT_FOLLOWLOCATION, 1); - curl_easy_setopt(h, CURLOPT_MAXREDIRS, 6); - curl_easy_setopt(h, CURLOPT_CONNECTTIMEOUT, LRO_CONNECTTIMEOUT_DEFAULT); - curl_easy_setopt(h, CURLOPT_LOW_SPEED_TIME, LRO_LOWSPEEDTIME_DEFAULT); - curl_easy_setopt(h, CURLOPT_LOW_SPEED_LIMIT, LRO_LOWSPEEDLIMIT_DEFAULT); - curl_easy_setopt(h, CURLOPT_SSL_VERIFYHOST, 2); - curl_easy_setopt(h, CURLOPT_SSL_VERIFYPEER, 1); - curl_easy_setopt(h, CURLOPT_FTP_USE_EPSV, LRO_FTPUSEEPSV_DEFAULT); - curl_easy_setopt(h, CURLOPT_FILETIME, 0); + if (curl_easy_setopt(h, CURLOPT_FOLLOWLOCATION, 1) != CURLE_OK) + goto err; + if (curl_easy_setopt(h, CURLOPT_MAXREDIRS, 6) != CURLE_OK) + goto err; + if (curl_easy_setopt(h, CURLOPT_CONNECTTIMEOUT, LRO_CONNECTTIMEOUT_DEFAULT) != CURLE_OK) + goto err; + if (curl_easy_setopt(h, CURLOPT_LOW_SPEED_TIME, LRO_LOWSPEEDTIME_DEFAULT) != CURLE_OK) + goto err; + if (curl_easy_setopt(h, CURLOPT_LOW_SPEED_LIMIT, LRO_LOWSPEEDLIMIT_DEFAULT) != CURLE_OK) + goto err; + if (curl_easy_setopt(h, CURLOPT_SSL_VERIFYHOST, 2) != CURLE_OK) + goto err; + if (curl_easy_setopt(h, CURLOPT_SSL_VERIFYPEER, 1) != CURLE_OK) + goto err; + if (curl_easy_setopt(h, CURLOPT_FTP_USE_EPSV, LRO_FTPUSEEPSV_DEFAULT) != CURLE_OK) + goto err; + if (curl_easy_setopt(h, CURLOPT_FILETIME, 0) != CURLE_OK) + goto err; return h; + +err: + curl_easy_cleanup(h); + return NULL; } void -- 1.8.3.1