From patchwork Fri Sep 10 17:06:55 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 508776 Delivered-To: patch@linaro.org Received: by 2002:a02:8629:0:0:0:0:0 with SMTP id e38csp1510422jai; Fri, 10 Sep 2021 10:07:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzZVOBgPMT+//Oe0jVYH+cAs3nsN8MLAJ9BN2aSqxSQKExZqZ92gP0W8rsq993aPe6TfvI7 X-Received: by 2002:a05:6000:18a:: with SMTP id p10mr10648837wrx.40.1631293672319; Fri, 10 Sep 2021 10:07:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631293672; cv=none; d=google.com; s=arc-20160816; b=MzOdaVkfz4A2W2yGNYyN6ROQhMBBdxfIdq2K08fGyqaAI7L5m576vMKt//p6boKIcu mj5mCUhXSe5nF3Naknx/Ck2jzm2hp3zy3l6Kt5q6qxh8AA0B9RnwPRzMQoEWRnN3v5Vj v1+AjHTMYmIBtpecHR6B5lltoD6Nm7Yo29Ovp+v6Fig+K7B8rZZqxJt/vbQgZhFVwVcE s1kBDiuGcCRQRCh9WdZm1LWLWaVDeN7yeXniwoNwNqKkPOpLVRBgOMgwadn5TpEee9wA 5PSNvO/nNxWLC0TZ/GujtRHBAwfJ/+dQPXGP7K5z4qS2F2FeBMoBJY20U109UVi859BW b4wA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=+J6grQHEVtN6t6ceYCiTjy1J8psdb3VCBa42DzLh0ro=; b=KXfcxKJL51VuJc0O4CIeeNMGT5gHcFlT7PyBtFon/aq3UFnJwAyn7w04LXVf1VRXfL 5AZLoxATd5eb+d0C5ik+BfcEzARNzgMbVzeiAMByZcj+niHxUdcFmUYriB1eJF84mlCz /oMDaAF1ntjILntn6JcUYOhejIuefYrhrh5X+eW2ZK1lrEyKNhPexDNrUC16CJsuuvwI 4NTSim6A04UQ3yGvoS6OVaUsf1h20D7D0eH80oyo6+P4S/OzbYatPtnDQo3gzRL/vE46 gbhOX3Srxjv/1uIkOPd0zgu/Ixfkn8nUK7IlcOQmLUTb5HRDQ/EUqDcI1+NT60WsYv4Y nPWg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@redhat.com header.s=mimecast20190719 header.b=Wz1G1lUT; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 9si6094717wrz.531.2021.09.10.10.07.52 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 10 Sep 2021 10:07:52 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@redhat.com header.s=mimecast20190719 header.b=Wz1G1lUT; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from localhost ([::1]:38554 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mOk0F-0000c2-Di for patch@linaro.org; Fri, 10 Sep 2021 13:07:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56826) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mOjzY-0000aL-0a for qemu-devel@nongnu.org; Fri, 10 Sep 2021 13:07:08 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:40025) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mOjzW-0004a1-H5 for qemu-devel@nongnu.org; Fri, 10 Sep 2021 13:07:07 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1631293625; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=+J6grQHEVtN6t6ceYCiTjy1J8psdb3VCBa42DzLh0ro=; b=Wz1G1lUT4qZLfBQWVezrKm40Lsi5P04dx/4lLBRmE3/LoJ08b3o3/inkLbWdoKcz2td2+B BfbITM1wdqKMja4DIadEefgI5FsfgKtu55DJi5onSqWaRcyK8WvSNgvS3mx/ASDm0uHXcs oT0kvHkXGesVZVMFLK5oCMlBQlqLpW8= Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-427-Pz_zh2KQPVOFadhictixpQ-1; Fri, 10 Sep 2021 13:07:04 -0400 X-MC-Unique: Pz_zh2KQPVOFadhictixpQ-1 Received: by mail-wr1-f72.google.com with SMTP id t15-20020a5d42cf000000b001565f9c9ee8so761878wrr.2 for ; Fri, 10 Sep 2021 10:07:04 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=+J6grQHEVtN6t6ceYCiTjy1J8psdb3VCBa42DzLh0ro=; b=6ksnvVNRA1cZ6zl4W3qDw1vZjl12cxiWYokP55qhndN/NhWzq5cWs0Jd0/rUobqkCF OtHFzfphe/ukifmbbXcfn8IMAnZmAXOBQfqgGNrB6X7v5B0soS7KeHF2ezF9IhEa6RvM Cc45dwh3sW9U1PnMTvnz9ZnFmwNqpSP++uPgxnW/1LJFIc0rutAA1qtM555YSBtdKfoI 4Wb2747K9Ll9UKKOvUhHodvqvVNwK2y7gX5of+vOiFFOfrPwiDXM7X1zn/uc8u3E/Pu7 ZxIXsvAoI7c++zoOmvhGeMFpgFNx99EyJYekWkWQC0/3/t9Lezvx/ptV7VKndVmooiub FHfQ== X-Gm-Message-State: AOAM530qpYpP1q6ZXM1IjbjvDx832f7ILQyciE7mtDeOjrgD1ChkE0pw QIzwhcgpEzarWAlKL7UpOHvNY3cqpC6WmgOH88HQfoedtCvJqP/PgNYhIppjNHrXEsuLoZNMynj ZDVlsttIBDdgLJndruv3v76OZMWocdxdZ54+WzFRpVaSaxol7e1w8/+qlNqIu1sIA X-Received: by 2002:adf:e10c:: with SMTP id t12mr11044275wrz.36.1631293622959; Fri, 10 Sep 2021 10:07:02 -0700 (PDT) X-Received: by 2002:adf:e10c:: with SMTP id t12mr11044239wrz.36.1631293622698; Fri, 10 Sep 2021 10:07:02 -0700 (PDT) Received: from x1w.. (21.red-83-52-55.dynamicip.rima-tde.net. [83.52.55.21]) by smtp.gmail.com with ESMTPSA id u16sm5233423wmc.41.2021.09.10.10.07.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Sep 2021 10:07:02 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v2 1/2] elf2dmp: Check curl_easy_setopt() return value Date: Fri, 10 Sep 2021 19:06:55 +0200 Message-Id: <20210910170656.366592-2-philmd@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210910170656.366592-1-philmd@redhat.com> References: <20210910170656.366592-1-philmd@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=philmd@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=216.205.24.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.392, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , =?utf-8?q?Philippe_Mathieu-D?= =?utf-8?b?YXVkw6k=?= , Viktor Prutyanov Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Peter Maydell Coverity points out that we aren't checking the return value from curl_easy_setopt(). Fixes: Coverity CID 1458895 Inspired-by: Peter Maydell Signed-off-by: Philippe Mathieu-Daudé --- Informal T-b tag on https://lore.kernel.org/qemu-devel/20210909004313.1dadb24e@192.168.1.7/ Tested-by: Viktor Prutyanov v1 from Peter: https://lore.kernel.org/qemu-devel/20210901143910.17112-2-peter.maydell@linaro.org/ --- contrib/elf2dmp/download.c | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) -- 2.31.1 Reviewed-by: Viktor Prutyanov Tested-by: Viktor Prutyanov diff --git a/contrib/elf2dmp/download.c b/contrib/elf2dmp/download.c index d09e607431f..bd7650a7a27 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);