From nobody Sun Feb 8 17:14:32 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.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 63.128.21.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=1606823448; cv=none; d=zohomail.com; s=zohoarc; b=b7cCGRptj6boAkWg8MaSr3JfTCkQQzD8GirfjcCDeMMbOXwlcbh/9CjNa+Ior8sLt1XJJGAXVk5pfWGRA7VB/VTIrVYTRcNdroZjRri7TjAJeVO7BJZQN+OkfM7OrTFlY71wHlA+clIyogZNVAPFDJNlqPnJ4qk3XjuyxndE+KE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1606823448; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=aui1YywUSuyrEnk4jCUOFUJ//zkZLuoiU1lFqZCuQtc=; b=DEsnKXJmW3JF+om4mcdrsX8nxyiz2zLwm67ip6s9EP+ANuXWSz5uNX2J1Et8BvWCgm6QWfgc73kwkCJEYU+IHs1NVVSP7LNhkc5qW2K6TV2mO/4WNUHMKfijQaomS/Pw8692CcCyB1YH2IIC4NFK2XG00fV1+TtSWye08vlGlDM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mx.zohomail.com with SMTPS id 1606823448209670.5788233548171; Tue, 1 Dec 2020 03:50:48 -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-104-FUgUuueBOiGxGnNzpizc_Q-1; Tue, 01 Dec 2020 06:50:45 -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 D210E817B97; Tue, 1 Dec 2020 11:50:39 +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 ACD9E63B8C; Tue, 1 Dec 2020 11:50:39 +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 4657B1809CA4; Tue, 1 Dec 2020 11:50:39 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0B1BoN2N026331 for ; Tue, 1 Dec 2020 06:50:23 -0500 Received: by smtp.corp.redhat.com (Postfix) id 4CEE25D6AB; Tue, 1 Dec 2020 11:50:23 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.194.243]) by smtp.corp.redhat.com (Postfix) with ESMTP id C32835D71D for ; Tue, 1 Dec 2020 11:50:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1606823447; 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: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=aui1YywUSuyrEnk4jCUOFUJ//zkZLuoiU1lFqZCuQtc=; b=Sau9DK+o5E+ZwXhOgcNOolBDDYk31Sn0DeUC/Y3yq58ePTP6JjekgF3f/wZfM3/Ed7ZKTA DraTI2+7UKivgb+edoAmmTEVsu0ZpeOah9M/DOPD7ON4EWGUIT6S6P6EaC4fV5ZhQlLWge S72e8G3iFm2FgSJrYSZH0+kzRqxC+vA= X-MC-Unique: FUgUuueBOiGxGnNzpizc_Q-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 2/3] virJSONValueObjectGetStringArray: Report error if @key is not an array Date: Tue, 1 Dec 2020 12:50:15 +0100 Message-Id: <9bb03f05c4f04c575bc6560720703235eba35b74.1606823325.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 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.11 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) Content-Type: text/plain; charset="utf-8" The virJSONValueObjectGetStringArray() function is given a @key which is supposed to be an array inside given @object. Well, if it's not then an error state is returned (NULL), but no error message is set. Signed-off-by: Michal Privoznik Reviewed-by: J=C3=A1n Tomko --- src/util/virjson.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/util/virjson.c b/src/util/virjson.c index d471923732..160f6172d2 100644 --- a/src/util/virjson.c +++ b/src/util/virjson.c @@ -1472,8 +1472,12 @@ virJSONValueObjectGetStringArray(virJSONValuePtr obj= ect, const char *key) size_t i; =20 data =3D virJSONValueObjectGetArray(object, key); - if (!data) + if (!data) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("%s is missing not an array"), + key); return NULL; + } =20 n =3D virJSONValueArraySize(data); ret =3D g_new0(char *, n + 1); --=20 2.26.2