From nobody Thu May 15 01:58:01 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1514913155298944.504737717588; Tue, 2 Jan 2018 09:12:35 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8C09F802; Tue, 2 Jan 2018 17:12:33 +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 659F81754E; Tue, 2 Jan 2018 17:12:33 +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 2A2EE1801240; Tue, 2 Jan 2018 17:12:33 +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 w02HCPUI003068 for ; Tue, 2 Jan 2018 12:12:25 -0500 Received: by smtp.corp.redhat.com (Postfix) id A9B264D71F; Tue, 2 Jan 2018 17:12:25 +0000 (UTC) Received: from localhost.localdomain (ovpn-204-45.brq.redhat.com [10.40.204.45]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0EDAF5C888 for ; Tue, 2 Jan 2018 17:12:24 +0000 (UTC) From: Michal Privoznik To: libvir-list@redhat.com Date: Tue, 2 Jan 2018 18:11:56 +0100 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 03/18] vshCommandParse: Don't leak @tkdata 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: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Tue, 02 Jan 2018 17:12:34 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" When parsing cmd line which has "--" on it, this is leaked. Problem is, parser->getNextArg() allocates new string and stores it into tkdata. But as soon as "--" is detected 'continue' is issued without any free of the allocated memory. =3D=3D5304=3D=3D 3 bytes in 1 blocks are definitely lost in loss record 1= of 782 =3D=3D5304=3D=3D at 0x4C2AF50: malloc (vg_replace_malloc.c:299) =3D=3D5304=3D=3D by 0x8BB5AA9: strdup (strdup.c:42) =3D=3D5304=3D=3D by 0x55842CA: virStrdup (virstring.c:941) =3D=3D5304=3D=3D by 0x172B21: _vshStrdup (vsh.c:162) =3D=3D5304=3D=3D by 0x175E8E: vshCommandArgvGetArg (vsh.c:1622) =3D=3D5304=3D=3D by 0x17551D: vshCommandParse (vsh.c:1418) =3D=3D5304=3D=3D by 0x175F25: vshCommandArgvParse (vsh.c:1638) =3D=3D5304=3D=3D by 0x130940: virshParseArgv (virsh.c:820) =3D=3D5304=3D=3D by 0x130C49: main (virsh.c:922) Signed-off-by: Michal Privoznik --- tools/vsh.c | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/vsh.c b/tools/vsh.c index a21e1d1de..2366b7b71 100644 --- a/tools/vsh.c +++ b/tools/vsh.c @@ -1491,6 +1491,7 @@ vshCommandParse(vshControl *ctl, vshCommandParser *pa= rser) } } else if (tkdata[0] =3D=3D '-' && tkdata[1] =3D=3D '-' && tkdata[2] =3D=3D '\0') { + VIR_FREE(tkdata); data_only =3D true; continue; } else { --=20 2.13.6 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list