From nobody Fri Apr 26 17:23:43 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1494498312556160.72241623918217; Thu, 11 May 2017 03:25:12 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4257E80F90; Thu, 11 May 2017 10:25:10 +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 E9AC88B311; Thu, 11 May 2017 10:25:09 +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 6A58C1800C95; Thu, 11 May 2017 10:25:08 +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 v4BAP67P031114 for ; Thu, 11 May 2017 06:25:06 -0400 Received: by smtp.corp.redhat.com (Postfix) id 5941E8D540; Thu, 11 May 2017 10:25:06 +0000 (UTC) Received: from dhcp-17-113.lcy.redhat.com (unknown [10.42.17.113]) by smtp.corp.redhat.com (Postfix) with ESMTP id C811B6046E; Thu, 11 May 2017 10:25:04 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 4257E80F90 Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 4257E80F90 From: "Daniel P. Berrange" To: libvir-list@redhat.com Date: Thu, 11 May 2017 11:25:02 +0100 Message-Id: <20170511102502.6356-1-berrange@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH] rpc: improve error message for bounds check 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: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Thu, 11 May 2017 10:25:11 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" If we exceed a fixed limit in RPC code we get a horrible message like this, if the parameter type is a 'string', because we forgot to initialize the error message type field: $ virsh snapshot-list ostack1 error: too many remote undefineds: 1329 > 1024 It would also be useful to know which RPC call and field was exceeded. So this patch makes us report: $ virsh snapshot-list ostack1 error: too many remote undefineds: 1329 > 1024, in parameter 'names' for 'virDomainSnapshotListNames' Signed-off-by: Daniel P. Berrange Reviewed-by: Kashyap Chamarthy --- src/rpc/gendispatch.pl | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/rpc/gendispatch.pl b/src/rpc/gendispatch.pl index 173189c..0c5e4ba 100755 --- a/src/rpc/gendispatch.pl +++ b/src/rpc/gendispatch.pl @@ -1501,6 +1501,7 @@ elsif ($mode eq "client") { $single_ret_list_name =3D $1; $single_ret_list_max_var =3D "max$1"; $single_ret_list_max_define =3D $2; + $single_ret_list_error_msg_type =3D "string"; } elsif ($ret_member =3D~ m/^(admin|remote)_nonnull_string= (\S+)<\S+>;/) { # error out on unannotated arrays die "$1_nonnull_string array without insert@ a= nnotation: $ret_member"; @@ -1773,7 +1774,8 @@ elsif ($mode eq "client") { print "\n"; print " if ($single_ret_list_max_var > $single_ret_list_max= _define) {\n"; print " virReportError(VIR_ERR_RPC,\n"; - print " _(\"too many remote ${single_ret= _list_error_msg_type}s: %d > %d\"),\n"; + print " _(\"too many remote ${single_ret= _list_error_msg_type}s: %d > %d,\"\n"; + print " \"in parameter '$single_ret_li= st_name' for 'vir$call->{ProcName}'\"),\n"; print " $single_ret_list_max_var, $singl= e_ret_list_max_define);\n"; print " goto done;\n"; print " }\n"; @@ -1839,7 +1841,8 @@ elsif ($mode eq "client") { $modern_ret_as_list) { print " if (ret.$single_ret_list_name.${single_ret_list_nam= e}_len > $single_ret_list_max_var) {\n"; print " virReportError(VIR_ERR_RPC,\n"; - print " _(\"too many remote ${single_ret= _list_error_msg_type}s: %d > %d\"),\n"; + print " _(\"too many remote ${single_ret= _list_error_msg_type}s: %d > %d,\"\n"; + print " \"in parameter '$single_ret_li= st_name' for 'vir$call->{ProcName}'\"),\n"; print " ret.$single_ret_list_name.${sing= le_ret_list_name}_len, $single_ret_list_max_var);\n"; print " goto cleanup;\n"; print " }\n"; --=20 2.9.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list