From nobody Tue Aug 25 02:51:04 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 38.145.34.151 as permitted sender) client-ip=38.145.34.151; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 38.145.34.151 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass(p=reject dis=none) header.from=lists.libvirt.org ARC-Seal: i=1; a=rsa-sha256; t=1787309630; cv=none; d=zohomail.com; s=zohoarc; b=PJbNwSrzusDTJAzQUA0TVdLH5ZK+MLxagW36j8PLdCj/y3KOIZb870qnB/sbsR7PO6aSrYL0ZX8hBUjBsjwPrm+kUXx7wK6NETt3rG9lrA7s9wWqpx9JHMBy409R3uq7+Px2W96GV3QE2CNfc4rASwujqx5j3N/Bp8m+uv1M+CM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1787309630; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:List-Subscribe:List-Post:List-Owner:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:Subject:Subject:To:To:Message-Id:Cc; bh=DePTX+xJScNnRgOE32FvBINzqmo5jQnDx36wniVAp40=; b=fG/lLsDV6v9E15zY6X/PCSj/voOOL82ntYwWABTjUuP9f7NfNdfkuEKQEpqefx/8LVUvuw6541yGmh6a2Pf2wB931zz2Yfj1OqZZByhUwIpGXCpygHVQPoqHq/p61LubGEEzrn7IiPlT9rU6hfR4vws+A87msPI30retm7fmgUo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 38.145.34.151 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [38.145.34.151]) by mx.zohomail.com with SMTPS id 1787309630522594.2496027610036; Fri, 21 Aug 2026 03:53:50 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 993) id 07B944193A; Fri, 21 Aug 2026 06:53:48 -0400 (EDT) Received: from [172.19.199.13] (unknown [10.16.107.18]) by lists.libvirt.org (Postfix) with ESMTP id F3B1041B2E for ; Fri, 21 Aug 2026 06:52:49 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 993) id C62903F337; Fri, 21 Aug 2026 06:52:41 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (3072 bits) server-digest SHA256) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 265D141AE0 for ; Fri, 21 Aug 2026 06:51:53 -0400 (EDT) Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-692-xQzh7qQoMiGqa34iuFcPSQ-1; Fri, 21 Aug 2026 06:51:51 -0400 Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 6A08B19560A5 for ; Fri, 21 Aug 2026 10:51:50 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.44.32.113]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 9D9521800348 for ; Fri, 21 Aug 2026 10:51:49 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=0.6 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL,RCVD_IN_SBL_CSS,SPF_HELO_PASS autolearn=no autolearn_force=no version=4.0.1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1787309512; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=DePTX+xJScNnRgOE32FvBINzqmo5jQnDx36wniVAp40=; b=h7rbT/edYYIXo6WbrHmKmPKRSLE/6+KvkYzRIzoIRip9lQVFbPk0ID2liMn6qn1jXwMLb5 3itAGZY51mvWqgB7t4VXApTNPBlclKRSsnLPpS58xGwIspuDN3wfTGEGWZNRRbG7upDm/v +AseOKPYaXp9S8vxzJC3+346zBxcTmA= X-MC-Unique: xQzh7qQoMiGqa34iuFcPSQ-1 X-Mimecast-MFC-AGG-ID: xQzh7qQoMiGqa34iuFcPSQ_1787309510 To: devel@lists.libvirt.org Subject: [libvirt PATCH] storage: logical: don't write past buffer bounds Date: Fri, 21 Aug 2026 12:51:37 +0200 Message-ID: <0e9b28fad597faca95799b9f18e04f69c569c296.1787309497.git.jtomko@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: pftfAczwB0PYVhOAFcFQLaBmXkybDNqamAkFwG8_Odk_1787309510 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-ID-Hash: ZUHBBQMQVAO7HLFPGXPQL6QOXLQMNRHU X-Message-ID-Hash: ZUHBBQMQVAO7HLFPGXPQL6QOXLQMNRHU X-MailFrom: jtomko@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; header-match-devel.lists.libvirt.org-0; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: =?utf-8?q?J=C3=A1n_Tomko_via_Devel?= Reply-To: =?UTF-8?q?J=C3=A1n=20Tomko?= X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1787309631134158500 From: J=C3=A1n Tomko If parsed number of extents is 0, the calculated buffer size won't hold the first regex_unit. Closes: https://gitlab.com/libvirt/libvirt/-/work_items/913 Signed-off-by: J=C3=A1n Tomko Reviewed-by: Michal Privoznik --- src/storage/storage_backend_logical.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/storage/storage_backend_logical.c b/src/storage/storage_ba= ckend_logical.c index 51e9337820..81f9d62d8b 100644 --- a/src/storage/storage_backend_logical.c +++ b/src/storage/storage_backend_logical.c @@ -161,12 +161,12 @@ virStorageBackendLogicalParseVolExtents(virStorageVol= Def *vol, =20 /* Allocate space for 'nextents' regex_unit strings plus a comma for e= ach */ regex =3D g_new0(char, nextents * (strlen(regex_unit) + 1) + 1); - strcat(regex, regex_unit); - for (i =3D 1; i < nextents; i++) { + for (i =3D 0; i < nextents; i++) { /* "," is the separator of "devices" field */ - strcat(regex, ","); strcat(regex, regex_unit); + strcat(regex, ","); } + regex[strlen(regex) - 1] =3D '\0'; =20 re =3D g_regex_new(regex, 0, 0, &err); if (!re) { --=20 2.55.0