aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2017-09-25 00:16:26 -0700
committerGuy Harris <guy@alum.mit.edu>2017-09-25 07:18:22 +0000
commitc1a5531b71208c8270f7d969f4aebdfbfb5ad12e (patch)
tree14233dd0873c63b2e6db22829138896a52f35891 /tools
parenta98d1089166cc90ebf7c82b938ae0add478b921d (diff)
pidl: Fix array range checks in python output
Pick up change from Samba: commit 67040cf61232dd1cdcc820237919ac1e073c31c2 Author: Volker Lendecke <vl@samba.org> Date: Tue Jun 20 15:31:18 2017 +0200 pidl: Fix array range checks in python output Without this, we generated code like if (ndr_table_dnsserver.num_calls < 0) { PyErr_SetString(PyExc_TypeError, "Internal Error, ndr_interface_call missing for py_DnssrvOperation_ndr_pack"); return NULL; } call = &ndr_table_dnsserver.calls[0]; This does not really make sense, and Coverity found comparing the unsigned num_calls against <0 a bit pointless. Should fix 138 Coverity findings and make the code a bit more correct. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org> Change-Id: I401e3771e6f3c1125ff847749073693af23884fc Reviewed-on: https://code.wireshark.org/review/23723 Reviewed-by: Guy Harris <guy@alum.mit.edu>
Diffstat (limited to 'tools')
-rw-r--r--tools/pidl/lib/Parse/Pidl/Samba4/Python.pm9
1 files changed, 6 insertions, 3 deletions
diff --git a/tools/pidl/lib/Parse/Pidl/Samba4/Python.pm b/tools/pidl/lib/Parse/Pidl/Samba4/Python.pm
index 79beb2e75e..f418ac489a 100644
--- a/tools/pidl/lib/Parse/Pidl/Samba4/Python.pm
+++ b/tools/pidl/lib/Parse/Pidl/Samba4/Python.pm
@@ -521,7 +521,8 @@ sub PythonFunctionStruct($$$$)
$self->pidl("DATA_BLOB blob;");
$self->pidl("enum ndr_err_code err;");
$self->pidl("");
- $self->pidl("if (ndr_table_$iface\.num_calls < $fn->{OPNUM}) {");
+ $self->pidl("if (ndr_table_$iface\.num_calls < " . ($fn->{OPNUM}+1) .
+ ") {");
$self->indent;
$self->pidl("PyErr_SetString(PyExc_TypeError, \"Internal Error, ndr_interface_call missing for py_$name\_ndr_pack\");");
$self->pidl("return NULL;");
@@ -633,7 +634,8 @@ sub PythonFunctionStruct($$$$)
$self->pidl("struct ndr_pull *pull = NULL;");
$self->pidl("enum ndr_err_code err;");
$self->pidl("");
- $self->pidl("if (ndr_table_$iface\.num_calls < $fn->{OPNUM}) {");
+ $self->pidl("if (ndr_table_$iface\.num_calls < " . ($fn->{OPNUM}+1) .
+ ") {");
$self->indent;
$self->pidl("PyErr_SetString(PyExc_TypeError, \"Internal Error, ndr_interface_call missing for py_$name\_ndr_unpack\");");
$self->pidl("return NULL;");
@@ -797,7 +799,8 @@ sub PythonFunctionStruct($$$$)
$self->pidl("PyObject *ret;");
$self->pidl("char *retstr;");
$self->pidl("");
- $self->pidl("if (ndr_table_$iface\.num_calls < $fn->{OPNUM}) {");
+ $self->pidl("if (ndr_table_$iface\.num_calls < " . ($fn->{OPNUM}+1) .
+ ") {");
$self->indent;
$self->pidl("PyErr_SetString(PyExc_TypeError, \"Internal Error, ndr_interface_call missing for py_$name\_ndr_print\");");
$self->pidl("return NULL;");