From nobody Thu Sep 19 01:08:43 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; 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 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1716801825449372.1903600499842; Mon, 27 May 2024 02:23:45 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 761791918; Mon, 27 May 2024 05:23:44 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id EC2C51BBF; Mon, 27 May 2024 05:19:37 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id E06CA194F; Mon, 27 May 2024 05:19:24 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 25A83194F for ; Mon, 27 May 2024 05:19:10 -0400 (EDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-461-7I9a-36aMwCxblrGAMDRyA-1; Mon, 27 May 2024 05:19:07 -0400 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (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 mimecast-mx02.redhat.com (Postfix) with ESMTPS id E8040185AD2D for ; Mon, 27 May 2024 09:19:06 +0000 (UTC) Received: from maggie.brq.redhat.com (unknown [10.43.3.102]) by smtp.corp.redhat.com (Postfix) with ESMTP id 94220400057 for ; Mon, 27 May 2024 09:19:06 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1716801549; 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=wJd85tLGfFicl5gZMsryzqm19hBWXR3oKEd0ZB1LNpE=; b=DAqOdTO5bBG/AodklrCVpRnyEnggYbqGvzkm2MrT3bbDUIAarWoIg11LCRWtJF5aT75zhH mjlWHtqk9ct+ngJ4ps77rFRoV02WZe74EZGq46tu+bOPUd49ganRNCXx9GERB3LHGbr+xf DTKrQg20eRyql+GYcBWD2V+QPwjJF6s= X-MC-Unique: 7I9a-36aMwCxblrGAMDRyA-1 From: Michal Privoznik To: devel@lists.libvirt.org Subject: [PATCH 6/6] vsh: Don't crash when @text is NULL in vshCompleterFilter() Date: Mon, 27 May 2024 11:18:54 +0200 Message-ID: <415b67be980d63e72f71e4517c0485a4b9d8ebea.1716801414.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.9 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: R2TKT5YRYTUPDM6RP354OOLOCNEKNITL X-Message-ID-Hash: R2TKT5YRYTUPDM6RP354OOLOCNEKNITL X-MailFrom: mprivozn@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1716801825988100001 Content-Type: text/plain; charset="utf-8"; x-default="true" This can happen only for cmdComplete() in interactive mode (which I'm still not convinced is any useful for users and whether we should support it). Anyway, running plain 'complete' command with no additional arguments boils down to @text being NULL in vshReadlineParse() which handles the case just right but is then subsequently passed to vshCompleterFilter() which isn't prepared for this case. Signed-off-by: Michal Privoznik Reviewed-by: Peter Krempa --- tools/vsh.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/vsh.c b/tools/vsh.c index c91d756885..6cc1f60d87 100644 --- a/tools/vsh.c +++ b/tools/vsh.c @@ -2820,7 +2820,7 @@ vshCompleterFilter(char ***list, newList =3D g_new0(char *, list_len + 1); =20 for (i =3D 0; i < list_len; i++) { - if (!STRPREFIX((*list)[i], text)) { + if (text && !STRPREFIX((*list)[i], text)) { g_clear_pointer(&(*list)[i], g_free); continue; } --=20 2.44.1