From nobody Tue May 14 18:25:08 2024 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=1644584650; cv=none; d=zohomail.com; s=zohoarc; b=nGlHvY8M97N6i4ujLFYNnbIGGgEF5AMpfiFlvO8UQngFyYii4vabhsE1io2+esdR227rOiTuiDoa1F49pz94P+Qu0cGBzy0z4Rk7cB7uO656/Xuf6nIFLKmjFOLAUC3mrVv6PK23GFOChtEuDURv+cEi1uTAZfZiLnW93rjzKVg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1644584650; h=Content-Type:Content-Transfer-Encoding:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=RKTXos+zFgOER4LNJzTwgjXxwKZa/jbVktjDFcv11EM=; b=Uc7k8Y+cxlPH5/QhaKmyj2OCNYqfpxF5lxUjWvb7KR5hUpUm+mt3glk+dYE6c2wB90Ipnf1U5Ev19OHPhwUySD95Clssf7khkoJQu7futDwHq85cOfI1lyXS/MuFiTBC6cdYXjORwl4NEz05dqgzmtWFf9eDmrSFs0UvDX41rrc= 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 1644584650843225.55843640554372; Fri, 11 Feb 2022 05:04:10 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-247-5IiFN1HWPeW67_sE71eFPg-1; Fri, 11 Feb 2022 08:04:06 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 7BFE751082; Fri, 11 Feb 2022 13:04:00 +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 207867B025; Fri, 11 Feb 2022 13:03:59 +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 1AD721806D1D; Fri, 11 Feb 2022 13:03:57 +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 21BCxq7Z011290 for ; Fri, 11 Feb 2022 07:59:52 -0500 Received: by smtp.corp.redhat.com (Postfix) id B42157D3DB; Fri, 11 Feb 2022 12:59:52 +0000 (UTC) Received: from rein.int.mamuti.net (unknown [10.40.192.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 878B27D3DA for ; Fri, 11 Feb 2022 12:59:49 +0000 (UTC) Received: by rein.int.mamuti.net (Postfix, from userid 500) id C62EE180154; Fri, 11 Feb 2022 13:59:47 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1644584649; 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:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=RKTXos+zFgOER4LNJzTwgjXxwKZa/jbVktjDFcv11EM=; b=CeMK4YsoRol3MQmdA2LQSWenDxE5XlY5OV0SclBNaR0XK2kCHBppuOEOvktstNpMOGD9rU Es3iErQ2i+taLvHEuyyvz6U6JX+gx5hejUV45KTIrj62WgTTu7G5GbflJkCj2IOt5VBvfX VxEVfwidZqwEB/4tCcTIf8J2wNefXm0= X-MC-Unique: 5IiFN1HWPeW67_sE71eFPg-1 From: Jiri Denemark To: libvir-list@redhat.com Subject: [libvirt PATCH] conf: Avoid NULL-dereference in virDomainObjGetMessages Date: Fri, 11 Feb 2022 13:59:38 +0100 Message-Id: <59ba4ef9544058844da50eba46019fcc11824304.1644584377.git.jdenemar@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 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: 1644584652286100001 Content-Type: text/plain; charset="utf-8" All callers currently guarantee flags passed to virDomainObjGetMessages are either zero or contain at least one of the supported flags. But it doesn't mean we should not check for the possibility an unknown flag was the only one passed to virDomainObjGetMessages. Signed-off-by: Jiri Denemark Reviewed-by: Michal Privoznik --- src/conf/domain_conf.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index ab8f2a52cc..093b719b2c 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -31472,7 +31472,8 @@ virDomainObjGetMessages(virDomainObj *vm, } } =20 - (*msgs)[nmsgs] =3D NULL; + if (*msgs) + (*msgs)[nmsgs] =3D NULL; =20 rv =3D nmsgs; =20 --=20 2.35.0