From nobody Thu Mar 28 20:54:00 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) client-ip=207.211.31.81; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) by mx.zohomail.com with SMTPS id 1581516782409419.21783383748823; Wed, 12 Feb 2020 06:13:02 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-23-PKiLfc0aO3efqlH5RMVTbg-1; Wed, 12 Feb 2020 09:12:58 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 4712A1851FC2; Wed, 12 Feb 2020 14:12:53 +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 EF3EC8AC26; Wed, 12 Feb 2020 14:12:52 +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 A261618089C8; Wed, 12 Feb 2020 14:12:52 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 01CEBTpZ024776 for ; Wed, 12 Feb 2020 09:11:30 -0500 Received: by smtp.corp.redhat.com (Postfix) id 9F285107CD09; Wed, 12 Feb 2020 14:11:29 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast05.extmail.prod.ext.rdu2.redhat.com [10.11.55.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9A8DA107CD04 for ; Wed, 12 Feb 2020 14:11:27 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id CBBB7801E66 for ; Wed, 12 Feb 2020 14:11:27 +0000 (UTC) Received: from mxct.zte.com.cn (out1.zte.com.cn [202.103.147.172]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-11-nCaScSFMMDmzN882ulC0cQ-1; Wed, 12 Feb 2020 09:11:23 -0500 Received: from mse-fl1.zte.com.cn (unknown [10.30.14.238]) by Forcepoint Email with ESMTPS id 20D001CA3AA47D643629 for ; Wed, 12 Feb 2020 22:11:17 +0800 (CST) Received: from notes_smtp.zte.com.cn (notes_smtp.zte.com.cn [10.30.1.239]) by mse-fl1.zte.com.cn with ESMTP id 01CEAoJG084965 for ; Wed, 12 Feb 2020 22:10:50 +0800 (GMT-8) (envelope-from wang.yi59@zte.com.cn) Received: from fox-host8.localdomain ([10.74.120.8]) by szsmtp06.zte.com.cn (Lotus Domino Release 8.5.3FP6) with ESMTP id 2020021222111274-2105150 ; Wed, 12 Feb 2020 22:11:12 +0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1581516781; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:content-type:content-type: content-transfer-encoding:content-transfer-encoding:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=2+OPrk5RhAwuzx7ucobbTEUDqE+yLjbwx/uauG81KQo=; b=VCd2IUrlXp+Bx0ws0klH3tb+e4t9IBc8Gads2kwAL/R4nji1tPke2XQvOLhzoKNu+44HCz sRW/UnNvKWzrpWFoXSJdLygn55hg81CMxXCBxBmCMQui9a3QtXdpRVg7Xgk9lonVi8ixvc 6iDmdp4pSLzDWi/pEhI4e7yvSVw6uuA= From: Yi Wang To: libvir-list@redhat.com Subject: [PATCH] util: Prevent a NULl pointer from being accessed Date: Wed, 12 Feb 2020 22:10:42 +0800 Message-Id: <1581516642-25440-1-git-send-email-wang.yi59@zte.com.cn> X-MIMETrack: Itemize by SMTP Server on SZSMTP06/server/zte_ltd(Release 8.5.3FP6|November 21, 2013) at 2020-02-12 22:11:12, Serialize by Router on notes_smtp/zte_ltd(Release 9.0.1FP7|August 17, 2016) at 2020-02-12 22:10:53, Serialize complete at 2020-02-12 22:10:53 X-MAIL: mse-fl1.zte.com.cn 01CEAoJG084965 X-MC-Unique: nCaScSFMMDmzN882ulC0cQ-1 X-MC-Unique: PKiLfc0aO3efqlH5RMVTbg-1 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-MIME-Autoconverted: from quoted-printable to 8bit by lists01.pubmisc.prod.ext.phx2.redhat.com id 01CEBTpZ024776 X-loop: libvir-list@redhat.com Cc: wang.yi59@zte.com.cn, Huang Zijiang , wang.liang82@zte.com.cn, xue.zhihong@zte.com.cn 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.11 X-Mimecast-Spam-Score: 2 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Huang Zijiang virJSONValueObjectGetObject maybe return NULL if the key is missing or if value is not the correct TYPE, so we have to prevent a NULl pointer from being accessed. Signed-off-by: Huang Zijiang Signed-off-by: Yi Wang --- src/util/virqemu.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/util/virqemu.c b/src/util/virqemu.c index f3a233a..29fbe4e 100644 --- a/src/util/virqemu.c +++ b/src/util/virqemu.c @@ -257,6 +257,11 @@ virQEMUBuildObjectCommandlineFromJSON(virBufferPtr buf, const char *type =3D virJSONValueObjectGetString(objprops, "qom-type"); const char *alias =3D virJSONValueObjectGetString(objprops, "id"); virJSONValuePtr props =3D virJSONValueObjectGetObject(objprops, "props= "); + if (!props) { + virReportError(VIR_ERR_INVALID_ARG, "%s", + _("reply was missing return props data")); + return -1; + } =20 return virQEMUBuildObjectCommandlineFromJSONInternal(buf, type, alias,= props); } --=20 1.9.1