From nobody Mon Feb 9 11:29:43 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=1626944439; cv=none; d=zohomail.com; s=zohoarc; b=KnNyNCl+ghMRRiNaVTuAx4k0KYxZ/UcY5MOSmj9SlfS2God7rMzTFNaMMh0dxay7wGDg5m/SIGH75zQhVspUH4YIRyMKt5kLmXsTYW/K+wLhivzffGtfPIHKVAEx/H5fekXHxsSxemNAn8eGaBML5K03P/jZSqh4fz9Oh9oreZc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1626944439; 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=zviICAzqRG8GmIKeax4EfKn4BQfNgtrS8k89YL8sKGY=; b=HsF4uly1r55ugcVYy7aCXuUvPpLe0A9QICWrn2QsRuWTfb43peiqf9Hqcu+bECUDNuTYotuSpiDaZ+RY/VWn/cP3sLFA3Be2rg3eCUjdGp1efbwllqEhqhe6/XKdX/YVzIWWpLrs+YFy/Fo6imxNETtfVyGN68m2WOVn7ibPs5U= 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 1626944439627279.75685771208805; Thu, 22 Jul 2021 02:00:39 -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-248-hpZX92b1NlOV5K7HefjlsQ-1; Thu, 22 Jul 2021 05:00:36 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 1CDB11084F55; Thu, 22 Jul 2021 09:00:31 +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 EA9202B0A9; Thu, 22 Jul 2021 09:00:30 +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 648294A7C8; Thu, 22 Jul 2021 09:00:28 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 16M90RvN016956 for ; Thu, 22 Jul 2021 05:00:27 -0400 Received: by smtp.corp.redhat.com (Postfix) id 0C2F8100763D; Thu, 22 Jul 2021 09:00:27 +0000 (UTC) Received: from work.redhat.com (ovpn-112-127.ams2.redhat.com [10.36.112.127]) by smtp.corp.redhat.com (Postfix) with ESMTP id 52DEC1007604; Thu, 22 Jul 2021 09:00:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1626944438; 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=zviICAzqRG8GmIKeax4EfKn4BQfNgtrS8k89YL8sKGY=; b=MzDjCCGkvqBvKjHojy64P+vWzSkY72tO9dppFiuWYUExngYoHdYZ5SPkyw0XEvG9Nh7don M65Uo/rVd/uWb2o2x6X0igitQAk35p5z8oN8iQ364ILIJhYx/tOr2U0IY7V0waZLW4wNUi RRzt8L2Rdrc3CMlzxXkKf//BmiuTX6g= X-MC-Unique: hpZX92b1NlOV5K7HefjlsQ-1 From: Tim Wiederhake To: libvir-list@redhat.com Subject: [libvirt PATCH v2 1/2] virFileReadLimFD: Cast maxlen to size_t before adding Date: Thu, 22 Jul 2021 11:00:17 +0200 Message-Id: <20210722090018.46195-2-twiederh@redhat.com> In-Reply-To: <20210722090018.46195-1-twiederh@redhat.com> References: <20210722090018.46195-1-twiederh@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 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.79 on 10.5.11.13 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: 1626944441358100001 Content-Type: text/plain; charset="utf-8" If the function is called with maxlen equal to `INT_MAX`, adding one will trigger a signed integer overflow. Signed-off-by: Tim Wiederhake Reviewed-by: Daniel P. Berrang=C3=A9 --- src/util/virfile.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/util/virfile.c b/src/util/virfile.c index 723e1ca6e5..ad491251a2 100644 --- a/src/util/virfile.c +++ b/src/util/virfile.c @@ -1422,7 +1422,7 @@ virFileReadLimFD(int fd, int maxlen, char **buf) errno =3D EINVAL; return -1; } - s =3D saferead_lim(fd, maxlen+1, &len); + s =3D saferead_lim(fd, (size_t) maxlen + 1, &len); if (s =3D=3D NULL) return -1; if (len > maxlen || (int)len !=3D len) { --=20 2.31.1