From nobody Wed Apr 15 07:00:20 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=1775830448; cv=none; d=zohomail.com; s=zohoarc; b=bYUYQQrwx+dI+rxpd12JGn5D4cZ3XRbjZRAwSl9zxNTAcBnMDgSOGYhSp1Pu2rZ4ueQ/Zep/R90gMiLCsdxAaQCqAP8ozYQP8p+riI5fCkAzcT4j/vLUS93CXfLe1IJdGhTGRX+lG1MYhiO+CxV+USRrtFs4eGknmSe0rHhcIdg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1775830448; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Owner:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Subject:Subject:To:To:Message-Id:Cc; bh=u+2fqXDuDCG3kEwgc48zNz5/Y7SAcXqwdlrr4iGSQEQ=; b=mwXjNtwYuEWr71bKlckJSbZWDvRRQWD/D/EA4ZEOiN7jfoVAuxPxRq2mo6HNIN8v4vqlrCO8o8CSIvyjUkmum81PKFTveLSVcrRuRwtAGAKVBvYbK0Aza0zK7LdDGulxFSUSkeVWJaMM5KamEGLEiGBHcp2o8HE5KhJJ0LIzNLk= 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 1775830448390283.64081664079424; Fri, 10 Apr 2026 07:14:08 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 993) id 319B84189B; Fri, 10 Apr 2026 10:14:07 -0400 (EDT) Received: from [172.19.199.3] (unknown [10.16.107.18]) by lists.libvirt.org (Postfix) with ESMTP id CA3A141945; Fri, 10 Apr 2026 10:12:28 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 993) id C96973F8A7; Fri, 10 Apr 2026 10:12:15 -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 F04E33F359 for ; Fri, 10 Apr 2026 10:12:14 -0400 (EDT) Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-654-gnG-waBuM5qpNPwKRc6QfA-1; Fri, 10 Apr 2026 10:12:12 -0400 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (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-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id BB371180028A for ; Fri, 10 Apr 2026 14:12:11 +0000 (UTC) Received: from antique-work.lan.rosnicka.net (unknown [10.44.48.177]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 0DE9319560AB for ; Fri, 10 Apr 2026 14:12:10 +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=-2.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED,SPF_HELO_PASS autolearn=unavailable autolearn_force=no version=4.0.1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1775830334; 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: in-reply-to:in-reply-to:references:references; bh=u+2fqXDuDCG3kEwgc48zNz5/Y7SAcXqwdlrr4iGSQEQ=; b=dhzIo5kT5GOL77ofb5aDJZs2T3QnYfw69PP59bfInj4FAzgVhSH/jezLHVmjcg50ogwwGT Ld+bpvfSiKNTeCz7hVhNJuZcm0ak+b8poSdYfeT1PDqT/EiJ2DhM+ve3sgoSsKEmMA73df CXfbBsLJHw+G+g/U9TuoESnqzI004+8= X-MC-Unique: gnG-waBuM5qpNPwKRc6QfA-1 X-Mimecast-MFC-AGG-ID: gnG-waBuM5qpNPwKRc6QfA_1775830331 To: devel@lists.libvirt.org Subject: [PATCH 1/2] virNetworkIPDefFormat: Fix memory leaks Date: Fri, 10 Apr 2026 16:12:07 +0200 Message-ID: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: lW6fMcoaVhQDsFRFJcxBprhGlv3B_HKPSHDXWcEXsSM_1775830331 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: Y5WCGVLI6GNNW2QTWCNHGEK7NRFF7CGC X-Message-ID-Hash: Y5WCGVLI6GNNW2QTWCNHGEK7NRFF7CGC X-MailFrom: phrdina@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: Pavel Hrdina via Devel Reply-To: Pavel Hrdina X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1775830449736158500 Content-Type: text/plain; charset="utf-8"; x-default="true" From: Pavel Hrdina Use g_auto() for every virBuffer in this function to make sure none of them will leak memory. It is not necessary to use on all of them because for some of the buffers virXMLFormatElement() is called before any return from the function but for consistency reasons it's better to use g_auto() for all cases. Fixes: d9b34ad12b2da231431a761b03ca038cdd44bd42 Signed-off-by: Pavel Hrdina Reviewed-by: Peter Krempa --- src/conf/network_conf.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/conf/network_conf.c b/src/conf/network_conf.c index 17ef1c2a08..abd4c6eb4e 100644 --- a/src/conf/network_conf.c +++ b/src/conf/network_conf.c @@ -2065,8 +2065,8 @@ static int virNetworkIPDefFormat(virBuffer *buf, const virNetworkIPDef *def) { - virBuffer ipAttrBuf =3D VIR_BUFFER_INITIALIZER; - virBuffer ipChildBuf =3D VIR_BUFFER_INIT_CHILD(buf); + g_auto(virBuffer) ipAttrBuf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) ipChildBuf =3D VIR_BUFFER_INIT_CHILD(buf); =20 if (def->family) virBufferAsprintf(&ipAttrBuf, " family=3D'%s'", def->family); @@ -2093,12 +2093,12 @@ virNetworkIPDefFormat(virBuffer *buf, virBufferEscapeString(&ipChildBuf, "\n", def->tftproot); if ((def->nranges || def->nhosts)) { - virBuffer dhcpChildBuf =3D VIR_BUFFER_INIT_CHILD(&ipChildBuf); + g_auto(virBuffer) dhcpChildBuf =3D VIR_BUFFER_INIT_CHILD(&ipChildB= uf); size_t i; =20 for (i =3D 0; i < def->nranges; i++) { - virBuffer rangeAttrBuf =3D VIR_BUFFER_INITIALIZER; - virBuffer rangeChildBuf =3D VIR_BUFFER_INIT_CHILD(&dhcpChildBu= f); + g_auto(virBuffer) rangeAttrBuf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) rangeChildBuf =3D VIR_BUFFER_INIT_CHILD(&dhc= pChildBuf); virSocketAddrRange addr =3D def->ranges[i].addr; virNetworkDHCPLeaseTimeDef *lease =3D def->ranges[i].lease; g_autofree char *saddr =3D NULL; @@ -2125,8 +2125,8 @@ virNetworkIPDefFormat(virBuffer *buf, virXMLFormatElement(&dhcpChildBuf, "range", &rangeAttrBuf, &ra= ngeChildBuf); } for (i =3D 0; i < def->nhosts; i++) { - virBuffer hostAttrBuf =3D VIR_BUFFER_INITIALIZER; - virBuffer hostChildBuf =3D VIR_BUFFER_INIT_CHILD(&dhcpChildBuf= ); + g_auto(virBuffer) hostAttrBuf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) hostChildBuf =3D VIR_BUFFER_INIT_CHILD(&dhcp= ChildBuf); virNetworkDHCPLeaseTimeDef *lease =3D def->hosts[i].lease; =20 if (def->hosts[i].mac) @@ -2155,7 +2155,7 @@ virNetworkIPDefFormat(virBuffer *buf, virXMLFormatElement(&dhcpChildBuf, "host", &hostAttrBuf, &host= ChildBuf); } if (def->bootfile) { - virBuffer bootpAttrBuf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) bootpAttrBuf =3D VIR_BUFFER_INITIALIZER; =20 virBufferEscapeString(&bootpAttrBuf, " file=3D'%s'", def->boot= file); if (VIR_SOCKET_ADDR_VALID(&def->bootserver)) { --=20 2.53.0 From nobody Wed Apr 15 07:00:20 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=1775830495; cv=none; d=zohomail.com; s=zohoarc; b=UNsVCpf9z5CqfTT/2erURHVeGWgS1soNbbPxknRy6c2jHdxAJdgolMiYcWXBAf66MF69Xjy3xpCUe/5jYIOR/3TjX85Qum8PJp2xHXGDpE7xoFIilPjCwTpU3SWNYLS/5LpPLISsx9yS3wbIuUtjawMFnMWRHFUz9WS5yipnb3o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1775830495; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Owner:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Subject:Subject:To:To:Message-Id:Cc; bh=gQsHva2lFJm8fb8xohmp/Sm/uqBjqsgo8lkXL/RvNYY=; b=KY4R1E4aqWSXpZxAIO5jE7zab80+mIcom9rWh9OGlTxp4XQD4n7LabQdCTitYvnHw/UrKcRk5gzpUdipiaOBVVmOCnwpqY1XAs41Loiv7Xqou4n9WVqvp6/ybIhSzafuWFEmtEQkfkhtQd61AZazKNROGx07RcjTs+RQToRW0JA= 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 177583049513656.56084705025239; Fri, 10 Apr 2026 07:14:55 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 993) id 1B067417DE; Fri, 10 Apr 2026 10:14:53 -0400 (EDT) Received: from [172.19.199.3] (unknown [10.16.107.18]) by lists.libvirt.org (Postfix) with ESMTP id 7BF1C41998; Fri, 10 Apr 2026 10:12:33 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 993) id 5E5B83F87D; Fri, 10 Apr 2026 10:12:16 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.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 C322C3F88F for ; Fri, 10 Apr 2026 10:12:15 -0400 (EDT) Received: from mx-prod-mc-05.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-267-w4_yTZirMSmSasz473XQDw-1; Fri, 10 Apr 2026 10:12:14 -0400 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (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-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 00C0C19560BC for ; Fri, 10 Apr 2026 14:12:13 +0000 (UTC) Received: from antique-work.lan.rosnicka.net (unknown [10.44.48.177]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 3C6F519560AB for ; Fri, 10 Apr 2026 14:12:11 +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_H4, RCVD_IN_MSPIKE_WL,RCVD_IN_SBL_CSS,RCVD_IN_VALIDITY_CERTIFIED_BLOCKED, RCVD_IN_VALIDITY_RPBL_BLOCKED,RCVD_IN_VALIDITY_SAFE_BLOCKED, 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=1775830335; 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: in-reply-to:in-reply-to:references:references; bh=gQsHva2lFJm8fb8xohmp/Sm/uqBjqsgo8lkXL/RvNYY=; b=Dy0/7HbA7/NE9l9ymlkObOWctAn7D1iOeVn9teTLML9NUkeLhCcqUQdQFjtw3G6KVjI5XE rG+UIMNwRaB7YemLD1z1iuadAZ/8xdGittXdStuuS//seUlOmGQV7VIFhVx9SK4egd4IaL LhXUoPdAvbwyHv5996sgI4Qh6Q4/qxA= X-MC-Unique: w4_yTZirMSmSasz473XQDw-1 X-Mimecast-MFC-AGG-ID: w4_yTZirMSmSasz473XQDw_1775830333 To: devel@lists.libvirt.org Subject: [PATCH 2/2] chSocketRecv: Fix memory leak Date: Fri, 10 Apr 2026 16:12:08 +0200 Message-ID: <5e4cf00e27ec380268d454aaf518751a30f484dd.1775830324.git.phrdina@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: nYdC0lm0FLJUYSQvtE0GvjsTTZYBdkVqawzvnVO5q-k_1775830333 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: SOPDDY2FTN2QFKNMC4SYCCL5ES2IBWJH X-Message-ID-Hash: SOPDDY2FTN2QFKNMC4SYCCL5ES2IBWJH X-MailFrom: phrdina@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: Pavel Hrdina via Devel Reply-To: Pavel Hrdina X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1775830495886158500 Content-Type: text/plain; charset="utf-8"; x-default="true" From: Pavel Hrdina Add missing g_autofree as the code looks like it was already written to use it. Fixes: 6f55137a1c465fde5aabca4530031542f751b4ad Signed-off-by: Pavel Hrdina Reviewed-by: Peter Krempa --- src/ch/ch_process.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ch/ch_process.c b/src/ch/ch_process.c index 29db853a7f..a67274b4a5 100644 --- a/src/ch/ch_process.c +++ b/src/ch/ch_process.c @@ -548,7 +548,7 @@ static char * chSocketRecv(int sock, bool use_timeout) { struct pollfd pfds[1]; - char *buf =3D NULL; + g_autofree char *buf =3D NULL; size_t buf_len =3D 1024; int timeout =3D PKT_TIMEOUT_MS; int ret; --=20 2.53.0