From nobody Thu Apr 25 12:39:06 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-1.mimecast.com [207.211.31.81]) by mx.zohomail.com with SMTPS id 1581516777028624.468169731901; Wed, 12 Feb 2020 06:12:57 -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-103-DcLYMDsIONuqlqw5087P6w-1; Wed, 12 Feb 2020 09:12:53 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 28B3B1851FD9; Wed, 12 Feb 2020 14:12:47 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8F3366E3EE; Wed, 12 Feb 2020 14:12:46 +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 B805F8B2A2; Wed, 12 Feb 2020 14:12:45 +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 01CEApcA024747 for ; Wed, 12 Feb 2020 09:10:52 -0500 Received: by smtp.corp.redhat.com (Postfix) id 9165210A58D7; Wed, 12 Feb 2020 14:10:51 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast04.extmail.prod.ext.rdu2.redhat.com [10.11.55.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8C68210A7E4A for ; Wed, 12 Feb 2020 14:10:49 +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-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id A4BA610192BA for ; Wed, 12 Feb 2020 14:10:49 +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-268-3r3ZG3iwN7OpoSxakdJqEg-1; Wed, 12 Feb 2020 09:10:45 -0500 Received: from mse-fl2.zte.com.cn (unknown [10.30.14.239]) by Forcepoint Email with ESMTPS id EA1647F1EE1C26316C58 for ; Wed, 12 Feb 2020 22:10:40 +0800 (CST) Received: from notes_smtp.zte.com.cn (notessmtp.zte.com.cn [10.30.1.239]) by mse-fl2.zte.com.cn with ESMTP id 01CEARXF056282 for ; Wed, 12 Feb 2020 22:10:27 +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 2020021222104908-2105149 ; Wed, 12 Feb 2020 22:10:49 +0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1581516775; 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=H+lbtBqbsA0q7udgfqjt5Ykc4dV5fHY+v6NQBEcFfVU=; b=Vp/PpqaQ2gV3WXIIO7txGUjJtXHzcJ+6JqUBUbnjoWdVg9CHqnwQ4Iq9a8OhG+R4IKNqiU /uK/SiLdmIXo4Oa2I3CJrDoOrw7Xy5AbcQCm/YaunwDg8t8Qo0nJ4Se7ziiT+iRE2k060S SoIpqq5Il1gS0/wIN4B9WfhycR4G6MU= 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:20 +0800 Message-Id: <1581516620-25311-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:10:49, Serialize by Router on notes_smtp/zte_ltd(Release 9.0.1FP7|August 17, 2016) at 2020-02-12 22:10:29, Serialize complete at 2020-02-12 22:10:29 X-MAIL: mse-fl2.zte.com.cn 01CEARXF056282 X-MC-Unique: 3r3ZG3iwN7OpoSxakdJqEg-1 X-MC-Unique: DcLYMDsIONuqlqw5087P6w-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 01CEApcA024747 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.13 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/virstoragefile.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c index e46ac99..53224b5 100644 --- a/src/util/virstoragefile.c +++ b/src/util/virstoragefile.c @@ -3378,6 +3378,11 @@ virStorageSourceParseBackingJSONSheepdog(virStorageS= ourcePtr src, const char *filename; const char *vdi =3D virJSONValueObjectGetString(json, "vdi"); virJSONValuePtr server =3D virJSONValueObjectGetObject(json, "server"); + if (!server) { + virReportError(VIR_ERR_INVALID_ARG, "%s", + _("missing server in JSON backing volume definitio= n")); + return -1; =20 + } =20 /* legacy URI based syntax passed via 'filename' option */ if ((filename =3D virJSONValueObjectGetString(json, "filename"))) { --=20 1.9.1