From nobody Sat Nov 23 15:06:59 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 1722927740532774.0164626549184; Tue, 6 Aug 2024 00:02:20 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 40EF6D59; Tue, 6 Aug 2024 03:02:19 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 5915BC97; Tue, 6 Aug 2024 03:02:00 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 0EB6DC5A; Tue, 6 Aug 2024 03:01:57 -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 BD1F6CF8 for ; Tue, 6 Aug 2024 03:01:49 -0400 (EDT) Received: from mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-167-HWU9a2M9PVahqR7xbnwUSA-1; Tue, 06 Aug 2024 03:01:47 -0400 Received: from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.15]) (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 mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 262C71955D47 for ; Tue, 6 Aug 2024 07:01:46 +0000 (UTC) Received: from ajulis-thinkpadt14gen4.remote.csb (unknown [10.43.2.246]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 7439C1955D42 for ; Tue, 6 Aug 2024 07:01:45 +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.8 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE 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=1722927709; 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; bh=jpkrB+fDNrQUPsJ+lkWczrspGLKL60qhxEY+GQrYk/M=; b=dq9pgw1uz6C3yfLuUCPDzQmcpZjJnI5CqFWQCy3iuZw7+TEzo88E17dBVMe8XZ7611wa5L 3aP+qr0pJyixO9aKjWCr8Ge2re9bLl5L53AEwahz06AtijEidvC8KQQcA3axmVFX09+kEj K+G8CHcs9GKpEtwJmT4Vc5lnv7mK7M0= X-MC-Unique: HWU9a2M9PVahqR7xbnwUSA-1 From: Adam Julis To: devel@lists.libvirt.org Subject: [PATCH] network: fix crashing "modify" option for hostname Date: Tue, 6 Aug 2024 09:01:42 +0200 Message-ID: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.15 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: QFTXPKGFVBU3X4EI2PE4TRZQUCZA3KHY X-Message-ID-Hash: QFTXPKGFVBU3X4EI2PE4TRZQUCZA3KHY X-MailFrom: ajulis@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: 1722927742571116600 Content-Type: text/plain; charset="utf-8"; x-default="true" The original condition caused (after adding modify option) possibly access to not allocated memory. For consistency added new check for multiple same records. Resolves: https://gitlab.com/libvirt/libvirt/-/issues/654 Signed-off-by: Adam Julis Reviewed-by: Michal Privoznik --- src/conf/network_conf.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/conf/network_conf.c b/src/conf/network_conf.c index c23b0e4400..5cf419acf1 100644 --- a/src/conf/network_conf.c +++ b/src/conf/network_conf.c @@ -3167,7 +3167,7 @@ virNetworkDefUpdateDNSHost(virNetworkDef *def, =20 /* when adding we want to only check duplicates of address since h= aving * multiple addresses with the same hostname is a legitimate confi= guration */ - if (!isAdd) { + if (command =3D=3D VIR_NETWORK_UPDATE_COMMAND_DELETE) { for (j =3D 0; j < host.nnames && !foundThisTime; j++) { for (k =3D 0; k < dns->hosts[i].nnames && !foundThisTime; = k++) { if (STREQ(host.names[j], dns->hosts[i].names[k])) @@ -3224,6 +3224,13 @@ virNetworkDefUpdateDNSHost(virNetworkDef *def, goto cleanup; } =20 + if (foundCt > 1) { + virReportError(VIR_ERR_OPERATION_INVALID, + _("multiple matching DNS HOST records were foun= d in network %1$s"), + def->name); + goto cleanup; + } + virNetworkDNSHostDefClear(&dns->hosts[foundIdxModify]); =20 memcpy(&dns->hosts[foundIdxModify], &host, sizeof(virNetworkDNSHos= tDef)); --=20 2.45.2