From nobody Sat Feb 7 08:13:45 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.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.129.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=1674728983; cv=none; d=zohomail.com; s=zohoarc; b=ObO3n8hpj9pjZZGgDKqn5NuLCPv0EwtOQGjBTaa3pMT77ZtS7Q7cvKmvJXIRvNEHjKb3vsNcCod3wkaOBS+Zdbn3r3agcNqIJwGvuGzIU/08CdnUYA3ISXuhJYviVLU/GJYP+qkR1fF/c8USpNV6pNIscZ9Ni467juUTqx3b6kE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1674728983; h=Content-Type:Content-Transfer-Encoding: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=3AIC8BETkG9tanf5vd4XSKdtf9oFmCVRaDqUzL7hJas=; b=BV+tHqjk8AOldW0rTRr0zEgCNzYznBRCdtSZfkAitR20nh+j596zvi4fGRPI7VBtp7j1ZgukwPOCpv8I6Ygumd+Vvj9O3328Y80n+LU7FimmDyAEFdOrgZLOqkA6yk9bJ2TW//tNcdYzT3W4Op/GEgswpnU5WDqhQUEnMiVaWys= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.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.129.124]) by mx.zohomail.com with SMTPS id 1674728983272389.4434076634693; Thu, 26 Jan 2023 02:29:43 -0800 (PST) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-137-opDnOLvZNqyRnN7VSCr8YQ-1; Thu, 26 Jan 2023 05:29:40 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 3387A805579; Thu, 26 Jan 2023 10:29:37 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id EDB151121333; Thu, 26 Jan 2023 10:29:35 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id CEFE119465B9; Thu, 26 Jan 2023 10:29:34 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id BB984194658D for ; Thu, 26 Jan 2023 10:29:29 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 92AEF2026D2A; Thu, 26 Jan 2023 10:29:29 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.43.2.227]) by smtp.corp.redhat.com (Postfix) with ESMTP id 55D502026D76 for ; Thu, 26 Jan 2023 10:29:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1674728982; h=from:from:sender:sender: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:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=3AIC8BETkG9tanf5vd4XSKdtf9oFmCVRaDqUzL7hJas=; b=UjykDWJt2y3B5KnikvSpggO81ZeGEcsF1rHI6hGfossw/tAaX9EXuo8PQpNjNClZ2qcl3e TsjejaahLbxlZvmWMLgC0vwK4Ea0NvoqBW7JBbF9ZpYcBGKaQYjJViaJideo917n29WAH2 KTDQZS8w+fQWhjH+OBWgo89H8o7eaew= X-MC-Unique: opDnOLvZNqyRnN7VSCr8YQ-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Jiri Denemark To: libvir-list@redhat.com Subject: [libvirt PATCH 3/4] remote: Avoid leaking uri_out Date: Thu, 26 Jan 2023 11:29:23 +0100 Message-Id: <29acf782a7d677e6fe0b9d6de0f883136a87fa6c.1674728899.git.jdenemar@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 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: 1674728984998100001 Content-Type: text/plain; charset="utf-8" In case the API returned success and a NULL pointer in uri_out, we would leak the preallocated buffer used for storing the uri_out pointer. Signed-off-by: Jiri Denemark --- src/remote/remote_daemon_dispatch.c | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/src/remote/remote_daemon_dispatch.c b/src/remote/remote_daemon= _dispatch.c index dbe6825fb8..6cf88e22c3 100644 --- a/src/remote/remote_daemon_dispatch.c +++ b/src/remote/remote_daemon_dispatch.c @@ -3061,15 +3061,14 @@ remoteDispatchDomainMigratePrepare2(virNetServer *s= erver G_GNUC_UNUSED, */ ret->cookie.cookie_len =3D cookielen; ret->cookie.cookie_val =3D cookie; - ret->uri_out =3D *uri_out =3D=3D NULL ? NULL : uri_out; + ret->uri_out =3D *uri_out =3D=3D NULL ? NULL : g_steal_pointer(&uri_ou= t); =20 rv =3D 0; =20 cleanup: - if (rv < 0) { + if (rv < 0) virNetMessageSaveError(rerr); - VIR_FREE(uri_out); - } + VIR_FREE(uri_out); return rv; } =20 @@ -4776,15 +4775,14 @@ remoteDispatchDomainMigratePrepare3(virNetServer *s= erver G_GNUC_UNUSED, */ ret->cookie_out.cookie_out_len =3D cookieoutlen; ret->cookie_out.cookie_out_val =3D cookieout; - ret->uri_out =3D *uri_out =3D=3D NULL ? NULL : uri_out; + ret->uri_out =3D *uri_out =3D=3D NULL ? NULL : g_steal_pointer(&uri_ou= t); =20 rv =3D 0; =20 cleanup: - if (rv < 0) { + if (rv < 0) virNetMessageSaveError(rerr); - VIR_FREE(uri_out); - } + VIR_FREE(uri_out); return rv; } =20 @@ -5572,16 +5570,15 @@ remoteDispatchDomainMigratePrepare3Params(virNetSer= ver *server G_GNUC_UNUSED, =20 ret->cookie_out.cookie_out_len =3D cookieoutlen; ret->cookie_out.cookie_out_val =3D cookieout; - ret->uri_out =3D !*uri_out ? NULL : uri_out; + ret->uri_out =3D !*uri_out ? NULL : g_steal_pointer(&uri_out); =20 rv =3D 0; =20 cleanup: virTypedParamsFree(params, nparams); - if (rv < 0) { + if (rv < 0) virNetMessageSaveError(rerr); - VIR_FREE(uri_out); - } + VIR_FREE(uri_out); return rv; } =20 --=20 2.39.1