From nobody Tue Nov 26 13:17:26 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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 (zoho.com: domain of redhat.com designates 207.211.31.81 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=1574326731; cv=none; d=zoho.com; s=zohoarc; b=F2MGHyGnIIBVa0ENYHBwZeBnhRSTyf/v/8qdg2GM3aH3tFI+S1QvsR4hU2lUu+l+h48eFv9sxQGe6+h/End/GSObv2B7Lh7v4z6NcdEVACKLAonz63RRb7hCxBo3iVIqA3BZHCTOXyrjipdxKq6ROuuI2ecO+pXmKFGCkEXkUTI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1574326731; 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=D4b/LhJ+e0vSCgrCmNSBcZ1SBBeg/zC8KjiP20bNO+M5L6Szi+R8pH0MEC8GjQDrMQ6kxsru9i9iSvc1bJTVNrygntKbDaLq+d+PJGATOEaOZXlTDmDb9Gw8+RX73z6MLyvXouyqCRwppoT3OSYE/rhgAAPuBTD3WTdjlZZl4lc= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.com: domain of redhat.com designates 207.211.31.81 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 [207.211.31.81]) by mx.zohomail.com with SMTPS id 157432673103570.5348195383076; Thu, 21 Nov 2019 00:58:51 -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-407-2etbBiMXPfyPpgBUrjYbWA-1; Thu, 21 Nov 2019 03:58:47 -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 8DE361034AE4; Thu, 21 Nov 2019 08:58:41 +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 145F060BC3; Thu, 21 Nov 2019 08:58:41 +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 A26121809567; Thu, 21 Nov 2019 08:58:39 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id xAL8wbMM000702 for ; Thu, 21 Nov 2019 03:58:37 -0500 Received: by smtp.corp.redhat.com (Postfix) id CD68853E19; Thu, 21 Nov 2019 08:58:37 +0000 (UTC) Received: from ridgehead.redhat.com (unknown [10.43.2.116]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2D69A60BC3; Thu, 21 Nov 2019 08:58:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1574326729; 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=VzSz5NN6Y/qqy5S978nutjES71+3WeOxYsecC4KnZ5GMAOh2miY5C45chG3dspMcnPvONl xffGVlK/CEZoDattBo7+8KjNHICF3mnFxwuHzCcjxJfrMQAtHQRF4EC0nl4qEi+5eXPJVS hTFE+8cclyY+LuzhySsvRrbabgMEWdE= From: Erik Skultety To: libvir-list@redhat.com Date: Thu, 21 Nov 2019 09:58:30 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Cc: Erik Skultety Subject: [libvirt] [PATCH v2 2/4] 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.11 X-MC-Unique: 2etbBiMXPfyPpgBUrjYbWA-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