From nobody Fri Dec 19 04:23:16 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) client-ip=207.211.31.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 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=1596406351; cv=none; d=zohomail.com; s=zohoarc; b=LzqU1kh7F7v6Z5F9wiueJ4anUf3O1c/lUOyPYYIH7WoRsr5DEHMwT5kpgNSLPOguZFj6RnRGBhL3ZZ3rMlJMFY65JkG7zsYJT1BfO2R4EW6fM7XeWV9WDgx8DF+pZKUI0N9x9aLLKi2eg2uckoCwhI4Xixp3dHBkTy0y4np7dxs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1596406351; 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=jbsRosP4f2+ouecxavF8jOOa9+0avisObVylBbl5wtE=; b=PVxqSqJG/ikxHy8PtAuoi+GzA1xeyQ16s9NFW2TUlBn+uMWeUlI2IlkbCP9b2wlFWbBPFrwiM/BdxLYiPHIlNWplITx825NJarsNiiRoOAoxXqgsAeOjiyD7lC9SjrRylXLpPst+VN4abEKNaWkdDReBLX5AvknK7UIW2O+TaYc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by mx.zohomail.com with SMTPS id 1596406351584328.2571364730859; Sun, 2 Aug 2020 15:12:31 -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-21-t5jmb3jYN6OobcNZ1qrvCQ-1; Sun, 02 Aug 2020 18:12:28 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 48A5610059A9; Sun, 2 Aug 2020 22:12:22 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2A98387E27; Sun, 2 Aug 2020 22:12:22 +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 E88181800BB2; Sun, 2 Aug 2020 22:12:21 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 072MBrXA010670 for ; Sun, 2 Aug 2020 18:11:53 -0400 Received: by smtp.corp.redhat.com (Postfix) id 3A11E5C5B7; Sun, 2 Aug 2020 22:11:53 +0000 (UTC) Received: from lpt.redhat.com (unknown [10.40.208.7]) by smtp.corp.redhat.com (Postfix) with ESMTP id A68AF5FC2F for ; Sun, 2 Aug 2020 22:11:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1596406350; 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=jbsRosP4f2+ouecxavF8jOOa9+0avisObVylBbl5wtE=; b=Dvn5FVY7Zy4YCz5dewW9P+kfM3uSnmAxa1++rcedWM4OCqO04kkFQlYTHJ7GjT88wGCJs1 PZ2cbwEO/DGoA04Bi/8lVyRTkWwAGFB3/YvbitBeyHJtYBglYRj8wB5OIHh9hEqbj1v7N3 BYv0phgKh6giZ115mNsR07Y9fnWFKPs= X-MC-Unique: t5jmb3jYN6OobcNZ1qrvCQ-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 8/8] tools: virt-admin: do not leak daemon-log settings Date: Mon, 3 Aug 2020 00:11:31 +0200 Message-Id: <2c9c05a1f5e942a6fa610b364098bb5670fde9a7.1596406221.git.jtomko@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com 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.11 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-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) The commands daemon-log-filters and daemon-log-outputs are used both for getting and setting the variables. But the getter receives an allocated string, which we do not free. Use separate variables for the getter and the setter to get rid of the memory leak and to stop casting away the const. Signed-off-by: J=C3=A1n Tomko --- tools/virt-admin.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tools/virt-admin.c b/tools/virt-admin.c index 4856758b4e..07d5f49825 100644 --- a/tools/virt-admin.c +++ b/tools/virt-admin.c @@ -1040,17 +1040,17 @@ static const vshCmdOptDef opts_daemon_log_filters[]= =3D { static bool cmdDaemonLogFilters(vshControl *ctl, const vshCmd *cmd) { - char *filters =3D NULL; vshAdmControlPtr priv =3D ctl->privData; =20 if (vshCommandOptBool(cmd, "filters")) { - if ((vshCommandOptStringReq(ctl, cmd, "filters", - (const char **) &filters) < 0 || + const char *filters =3D NULL; + if ((vshCommandOptStringReq(ctl, cmd, "filters", &filters) < 0 || virAdmConnectSetLoggingFilters(priv->conn, filters, 0) < 0)) { vshError(ctl, _("Unable to change daemon logging settings")); return false; } } else { + g_autofree char *filters =3D NULL; if (virAdmConnectGetLoggingFilters(priv->conn, &filters, 0) < 0) { vshError(ctl, _("Unable to get daemon logging filters informat= ion")); @@ -1093,17 +1093,17 @@ static const vshCmdOptDef opts_daemon_log_outputs[]= =3D { static bool cmdDaemonLogOutputs(vshControl *ctl, const vshCmd *cmd) { - char *outputs =3D NULL; vshAdmControlPtr priv =3D ctl->privData; =20 if (vshCommandOptBool(cmd, "outputs")) { - if ((vshCommandOptStringReq(ctl, cmd, "outputs", - (const char **) &outputs) < 0 || + const char *outputs =3D NULL; + if ((vshCommandOptStringReq(ctl, cmd, "outputs", &outputs) < 0 || virAdmConnectSetLoggingOutputs(priv->conn, outputs, 0) < 0)) { vshError(ctl, _("Unable to change daemon logging settings")); return false; } } else { + g_autofree char *outputs =3D NULL; if (virAdmConnectGetLoggingOutputs(priv->conn, &outputs, 0) < 0) { vshError(ctl, _("Unable to get daemon logging outputs informat= ion")); return false; --=20 2.26.2