From nobody Mon Feb 9 14:33:56 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1626871621; cv=none; d=zohomail.com; s=zohoarc; b=k4Hvtlcb4M5LaTUXWMLx2wsCZ/KbyPOTHh+RGWBUw3dZPs8IgnbXo+aGTK9ez4Q0ZgH9IiXXMNWXHCRRbbPpPFggDSEsj8Onlz0dmE0S+w2zlGisETQnosh/hsbkLYRH9XjqOAk6cCPEd21vWCq3Sd8Kb3gRz5+r+ZAOmgA8GEg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1626871621; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=PlTXMVTO8P6tjhLDqV+ielEgSz4pjXJSUcX5wCwJWaM=; b=m/u588i+s6ZlKomv96DfXwwBZWLIVS9cNERa5bwk74wnz3Pnnd4uQD2Z7eRJvZyFo1Y8buZWBw70yLGT7V2Vgxr/xSXGgPWbn2lfbOvGAGpDytEaM0YLNCcbNRpvxBmQdFSH3BhQ2R8WMCWASEmqWNCSC+0XGxRb/cXlLFILEPU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1626871621608187.48626188729884; Wed, 21 Jul 2021 05:47:01 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-398-LrAw2hlNPuKHEUfcNocIgw-1; Wed, 21 Jul 2021 08:46:59 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 0192B802B7F; Wed, 21 Jul 2021 12:46:54 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D20AF19C79; Wed, 21 Jul 2021 12:46:53 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 9D5DB4BB7C; Wed, 21 Jul 2021 12:46:53 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 16LCkoiA023562 for ; Wed, 21 Jul 2021 08:46:50 -0400 Received: by smtp.corp.redhat.com (Postfix) id BC51B84A10; Wed, 21 Jul 2021 12:46:50 +0000 (UTC) Received: from work.speedport.ip (ovpn-113-159.ams2.redhat.com [10.36.113.159]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0F97763BAE; Wed, 21 Jul 2021 12:46:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1626871620; h=from:from:sender:sender: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:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=PlTXMVTO8P6tjhLDqV+ielEgSz4pjXJSUcX5wCwJWaM=; b=PyGkR4vmcWeeYIkjzaBfr85Qpgizf05VoBgqEwHCChAjMRDwQXAXxcChlCZKV6WVlLwU6a y0s5Dg8FYsxiIqcs9HtUd+ksi4RPN0yG+A+sgSomDOrLFmhELZx10dBh7CAr6rR44XNJzF mvm9CScOr475c4G4hcRSpEMGRGhaMe4= X-MC-Unique: LrAw2hlNPuKHEUfcNocIgw-1 From: Tim Wiederhake To: libvir-list@redhat.com Subject: [libvirt PATCH 2/4] virfile: Use VIR_MAX_FILE_LEN instead of INT_MAX to limit file size Date: Wed, 21 Jul 2021 14:46:41 +0200 Message-Id: <20210721124643.36824-3-twiederh@redhat.com> In-Reply-To: <20210721124643.36824-1-twiederh@redhat.com> References: <20210721124643.36824-1-twiederh@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Cc: Tim Wiederhake X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1626871622124100005 Content-Type: text/plain; charset="utf-8" The use of INT_MAX as maximum file length is problematic for reasons discussed in the next commit. Signed-off-by: Tim Wiederhake --- tests/networkxml2firewalltest.c | 2 +- tests/testutils.c | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/tests/networkxml2firewalltest.c b/tests/networkxml2firewalltes= t.c index 91336a0c55..114e17fbbd 100644 --- a/tests/networkxml2firewalltest.c +++ b/tests/networkxml2firewalltest.c @@ -176,7 +176,7 @@ mymain(void) =20 basefile =3D g_strdup_printf("%s/networkxml2firewalldata/base.args", a= bs_srcdir); =20 - if (virFileReadAll(basefile, INT_MAX, &baseargs) < 0) + if (virFileReadAll(basefile, VIR_MAX_FILE_LEN, &baseargs) < 0) return EXIT_FAILURE; =20 DO_TEST("nat-default"); diff --git a/tests/testutils.c b/tests/testutils.c index 7d87e30a5c..c71e099bf1 100644 --- a/tests/testutils.c +++ b/tests/testutils.c @@ -313,7 +313,7 @@ virTestLoadFileJSON(const char *p, ...) if (!(path =3D virTestLoadFileGetPath(p, ap))) goto cleanup; =20 - if (virFileReadAll(path, INT_MAX, &jsonstr) < 0) + if (virFileReadAll(path, VIR_MAX_FILE_LEN, &jsonstr) < 0) goto cleanup; =20 if (!(ret =3D virJSONValueFromString(jsonstr))) @@ -562,7 +562,8 @@ virTestCompareToFileFull(const char *actual, if (virTestLoadFile(filename, &filecontent) < 0 && !virTestGetRege= nerate()) return -1; } else { - if (virFileReadAll(filename, INT_MAX, &filecontent) < 0 && !virTes= tGetRegenerate()) + if (virFileReadAll(filename, VIR_MAX_FILE_LEN, &filecontent) < 0 && + !virTestGetRegenerate()) return -1; } =20 --=20 2.31.1