From nobody Mon Feb 9 04:45:50 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=1647328109; cv=none; d=zohomail.com; s=zohoarc; b=ID0Or5gJ61oif6GcgMlUIF98AhawpI2tmAcUjhgh6QgFLMolZkmzz8f/MBGi2f0GPW7mSUATLnBO/ogni124LgaXJkTtdsQay56MZ6mlsb28o8JHlh7PrDyoTMZcQD5x5WTE25OlCUKcJnQ303344mCpropYYGkPhfPTKi+qNKU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1647328109; 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=1PuRqU9W1POIjEIEaIu1CXLf8MQd75ppLsneD6NOMhY=; b=hbt10qhIYhyYi8uKS0CpVWgpwEwuJ2BCue1REAx7hwujilaTKHS9p89P7NogvAGsmfsE2IlM47OMH7mae6jWpS53tdg74cSeiRquDrCTW2Db92XalGSu3Uh1DFCAFIfbdnA8nHiDCIpM4zw+9frXNE5VGZ3VHKxxtR6CEu7pIf0= 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 1647328109217401.62501317087697; Tue, 15 Mar 2022 00:08:29 -0700 (PDT) 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-311-PkcghMU4Ns65SkQdNm2huA-1; Tue, 15 Mar 2022 03:08:26 -0400 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id D90AB18A6583; Tue, 15 Mar 2022 07:08:24 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id C4D754B8D4D; Tue, 15 Mar 2022 07:08:22 +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 536371953550; Tue, 15 Mar 2022 07:08:21 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 3D2AD194E021 for ; Tue, 15 Mar 2022 07:08:20 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 1F2BC40C1247; Tue, 15 Mar 2022 07:08:20 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.193.11]) by smtp.corp.redhat.com (Postfix) with ESMTP id B0FAD400F8FE for ; Tue, 15 Mar 2022 07:08:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1647328108; 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=1PuRqU9W1POIjEIEaIu1CXLf8MQd75ppLsneD6NOMhY=; b=K9EX+92jBhyOMFOAJRPvM4t/YHFn4u7HGdA/bg7WA/Kqu2RVY88jzCeBlZHXjROCRWKkW6 K/nR/VC614qS+IjlYQ4B7YdOkJAi+ajaHhsEuEX2vsogHEI46n0IJL6GKhUNqBgFf5uxkN oytVLYCbWCRAH5wyhgzIt/j80L0UrA8= X-MC-Unique: PkcghMU4Ns65SkQdNm2huA-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 1/3] virsh: Properly terminate string list in virshDomainInterfaceSourceModeCompleter() Date: Tue, 15 Mar 2022 08:08:15 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.11.54.2 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 2.85 on 10.11.54.10 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-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1647328111593100001 Content-Type: text/plain; charset="utf-8" A completer must return a NULL terminated list of strings, which means that when dealing with enums, it has to allocate one pointer more than the value of VIR_XXX_LAST. But this is not honoured in virshDomainInterfaceSourceModeCompleter() leading to out of bounds read. Signed-off-by: Michal Privoznik --- tools/virsh-completer-domain.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/virsh-completer-domain.c b/tools/virsh-completer-domain.c index 250dd8b21a..9cc27b84cb 100644 --- a/tools/virsh-completer-domain.c +++ b/tools/virsh-completer-domain.c @@ -500,7 +500,7 @@ virshDomainInterfaceSourceModeCompleter(vshControl *ctl= G_GNUC_UNUSED, =20 virCheckFlags(0, NULL); =20 - ret =3D g_new0(char *, VIRSH_DOMAIN_INTERFACE_SOURCE_MODE_LAST); + ret =3D g_new0(char *, VIRSH_DOMAIN_INTERFACE_SOURCE_MODE_LAST + 1); =20 for (i =3D 0; i < VIRSH_DOMAIN_INTERFACE_SOURCE_MODE_LAST; i++) ret[i] =3D g_strdup(virshDomainInterfaceSourceModeTypeToString(i)); --=20 2.34.1