From nobody Mon Feb 9 02:09:09 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.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.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=quarantine dis=quarantine) header.from=virtuozzo.com ARC-Seal: i=1; a=rsa-sha256; t=1687512149; cv=none; d=zohomail.com; s=zohoarc; b=NtbP+RLUCA9j6FEcOL0rdLYJO4dXIJZhCbYFt/1Zy4AO31A+Xsl812ge5NCjRWJIPsbEht9MwUXrnAxIKIN9UM0/v2SRa0emWPMntkidmEo2pgEX+yPtkOqGkEUfwv9YQraraIWnehhWt7zmbMZS99IXNr06vwpJFJWWtLZ5/bc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1687512149; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=qkm3dWmYc5Nqoy4bl6zvavl0nXPeZYTTldXULZuMjKI=; b=S5dW9pc4LdjaQkrtK5uRDj5u9dZ1tIT3dBOOmEmrUhHlE/syJ6NG+2zY4u1D7L3dqAM4mI3sgoctZPXTRDHpOl6v1nW8aNtdvf9eqv8sjt7o548LpMfjqowcElvBpcXlsn9Go8ex4VrLz3vGj3uXKF1sVLpAOTBw7RcHU2s4E/k= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail header.from= (p=quarantine dis=quarantine) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1687512149065923.4923058714205; Fri, 23 Jun 2023 02:22:29 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-146-jeO3SRemMv-rzlGynzTSSw-1; Fri, 23 Jun 2023 05:22:25 -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 85E3F2807D8C; Fri, 23 Jun 2023 09:22:22 +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 99664425356; Fri, 23 Jun 2023 09:22:21 +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 70BC51946588; Fri, 23 Jun 2023 09:22:21 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id F2DA01946587 for ; Fri, 23 Jun 2023 09:22:20 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 9E6AA200C0CD; Fri, 23 Jun 2023 09:22:20 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast03.extmail.prod.ext.rdu2.redhat.com [10.11.55.19]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9815D200B402 for ; Fri, 23 Jun 2023 09:22:20 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 81BB68E44E1 for ; Fri, 23 Jun 2023 09:22:20 +0000 (UTC) Received: from relay.virtuozzo.com (relay.virtuozzo.com [130.117.225.111]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-36-CEXV3R9MO9G2IGlnfvo-zg-1; Fri, 23 Jun 2023 05:22:16 -0400 Received: from [192.168.16.76] (helo=dv..) by relay.virtuozzo.com with esmtp (Exim 4.96) (envelope-from ) id 1qCcyn-002IJB-0p; Fri, 23 Jun 2023 11:22:12 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1687512148; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=qkm3dWmYc5Nqoy4bl6zvavl0nXPeZYTTldXULZuMjKI=; b=BklorA0ut28IZYntAdUsXpfKM3sctpcfcrdCWXp/peCDu6ivfLZUCFBw33dnFVuFCY84ux yQaJIzJVGBqw0x1anfVZiKs/2lx4tIfkcOxY7SyOR4bto1gyMFTvBuMxPt2fwERX5ZX+lw mY1/OwqQfFoJTjtIW7u7HhsMkcya9Q0= X-MC-Unique: jeO3SRemMv-rzlGynzTSSw-1 X-Original-To: libvir-list@listman.corp.redhat.com X-MC-Unique: CEXV3R9MO9G2IGlnfvo-zg-1 From: Oleg Vasilev To: libvir-list@redhat.com Subject: [PATCH] util: don't validate empty params Date: Fri, 23 Jun 2023 15:20:50 +0600 Message-ID: <20230623092202.1994230-1-oleg.vasilev@virtuozzo.com> MIME-Version: 1.0 X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 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: , Cc: Oleg Vasilev , Den Lunev Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: virtuozzo.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1687512150926100001 Content-Type: text/plain; charset="utf-8"; x-default="true" If there are no parameters, there is nothing to validate. If params =3D=3D NULL, memcpy below results in memcpy(sorted, NULL, 0), which is UB. Found by UBSAN. Example of this codepath: virDomainBlockCopy() (where nparams =3D=3D 0 is valid) -> qemuDomainBlockCopy() Signed-off-by: Oleg Vasilev Reviewed-by: Kristina Hanicova --- src/util/virtypedparam.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/util/virtypedparam.c b/src/util/virtypedparam.c index 3bb8b125e9..ef3b8052f6 100644 --- a/src/util/virtypedparam.c +++ b/src/util/virtypedparam.c @@ -68,6 +68,10 @@ virTypedParamsValidate(virTypedParameterPtr params, int = nparams, ...) g_autofree virTypedParameterPtr sorted =3D NULL; g_autofree virTypedParameterPtr keys =3D NULL; =20 + if (!nparams) { + return 0; + } + va_start(ap, nparams); =20 sorted =3D g_new0(virTypedParameter, nparams); --=20 2.41.0