From nobody Mon Feb 9 00:07:50 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 205.139.110.61 as permitted sender) client-ip=205.139.110.61; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of redhat.com designates 205.139.110.61 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=1574079517; cv=none; d=zoho.com; s=zohoarc; b=ET6XW5hb6QcZ34hjE/aRE9q1vXPDiPXcE4yN/ezF561O5DMA3QIAwP8Ki80cgWzEm++D6K3U6C5n5RkRfBZJfnw2Zdtk+mGMDF+leD0b4vkXl+m5tK4xCbSq/85EEG3vchwrAfGlThSmE0jf2P0QOntqpD+xFYT9rAjwPnd87HQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1574079517; h=Content-Type:Content-Transfer-Encoding:Cc: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=xU29Q3yL5SRtch1+8V0V0y4agEGDA4dZT/utpm8ZJrk=; b=GrdPl3VAjiF/GeBxAkbo/vgwXCZ1YTu5wg3YveZ++6gJqp8hhnBLCCoFWhrsL32x9bqoyYj3L+meN1jUSp87JX5GM0NdlyrR6Irrf4vjOanWgXakMPbcZoFk+3MVqG0nOtD+wsnmkAaTwoaVxHtG7+OI2btGmRN8Pn7LtUs1SDs= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.com: domain of redhat.com designates 205.139.110.61 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-1.mimecast.com (us-smtp-2.mimecast.com [205.139.110.61]) by mx.zohomail.com with SMTPS id 1574079517100327.88352497589415; Mon, 18 Nov 2019 04:18:37 -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-100-CHa5W-_3OxeigqUTnXBPmw-1; Mon, 18 Nov 2019 07:18:33 -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 92094800580; Mon, 18 Nov 2019 12:18:28 +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 0DEBA60905; Mon, 18 Nov 2019 12:18:27 +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 804A14BB78; Mon, 18 Nov 2019 12:18:25 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id xAICIOL6015671 for ; Mon, 18 Nov 2019 07:18:24 -0500 Received: by smtp.corp.redhat.com (Postfix) id E8C9F60618; Mon, 18 Nov 2019 12:18:24 +0000 (UTC) Received: from ridgehead.redhat.com (unknown [10.43.2.116]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4DBF8608B5; Mon, 18 Nov 2019 12:18:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1574079515; 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: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=xU29Q3yL5SRtch1+8V0V0y4agEGDA4dZT/utpm8ZJrk=; b=bR75mKQyjP3D/PnibBgiyR4DPr1p6xfMoYwswFx+k1OlQhCAg/INU2BkMDih8Z6LXWNtaT mgo0HSUmWdXvav3VaacS79hYJklr6D3a1u21YpGfq/ap/ruZ4Q0h87XcZNDJhajcmBYbBI BqTx/jwW+bEe+iv+y/dqoWjZe6BVKN8= From: Erik Skultety To: libvir-list@redhat.com Date: Mon, 18 Nov 2019 13:18:18 +0100 Message-Id: <5ed8eee069541127a0a72fb512b90b2243a6d92d.1574079462.git.eskultet@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Cc: Erik Skultety Subject: [libvirt] [PATCH 2/3] rpc: gendispatch: Add a check for zero size client-side buffers 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-MC-Unique: CHa5W-_3OxeigqUTnXBPmw-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" After libvirt switched to GLib, we also started to use glib allocation primitives as of commit e85e34f3. Unlike malloc which is ambiguous with regards to size =3D=3D 0 (which in our case returned a unique pointer safe to be passed to free), g_malloc0 strictly returns NULL on size =3D=3D 0. This change broke our legacy APIs which rely on the caller to pre-allocate the target buffer to hold the results and pass the buffer size as an argument. Since it makes very little sense to call an API with nowhere to store the results, fix this by returning 0 directly in such case in the RPC dispatch code - there are modern API equivalents allocating the target buffer automatically anyway. https://bugzilla.redhat.com/show_bug.cgi?id=3D1772842 Signed-off-by: Erik Skultety --- src/rpc/gendispatch.pl | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/rpc/gendispatch.pl b/src/rpc/gendispatch.pl index 8656c8f205..524d31f741 100755 --- a/src/rpc/gendispatch.pl +++ b/src/rpc/gendispatch.pl @@ -1073,6 +1073,14 @@ elsif ($mode eq "server") { print " goto cleanup;\n"; print " }\n"; print "\n"; + + + print " if (args->$single_ret_list_max_var =3D=3D 0) {\n"; + print " ret->$single_ret_list_name.${single_ret_list_na= me}_len =3D 0;\n"; + print " rv =3D 0;\n"; + print " goto cleanup;\n"; + print " }\n"; + print "\n"; } =20 print join("\n", @getters_list); --=20 2.23.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list