mirror of
https://github.com/samba-team/samba.git
synced 2024-12-30 13:18:05 +03:00
Fix bug handling size arguments in a direction without actual data.
(This used to be commit 169d505e9e
)
This commit is contained in:
parent
5db62a16ff
commit
90c8841bef
@ -272,21 +272,28 @@ sub PythonFunctionBody($$$)
|
|||||||
|
|
||||||
my $signature = "S.$prettyname(";
|
my $signature = "S.$prettyname(";
|
||||||
|
|
||||||
my %metadata_args = ();
|
my $metadata_args = { in => {}, out => {} };
|
||||||
|
|
||||||
sub get_var($) { my $x = shift; $x =~ s/\*//g; return $x; }
|
sub get_var($) { my $x = shift; $x =~ s/\*//g; return $x; }
|
||||||
|
|
||||||
# Determine arguments that are metadata for other arguments (size_is/length_is)
|
# Determine arguments that are metadata for other arguments (size_is/length_is)
|
||||||
foreach my $e (@{$fn->{ELEMENTS}}) {
|
foreach my $e (@{$fn->{ELEMENTS}}) {
|
||||||
if (has_property($e, "length_is")) {
|
foreach my $dir (@{$e->{DIRECTION}}) {
|
||||||
$metadata_args{get_var($e->{PROPERTIES}->{length_is})} = $e->{NAME};
|
my $main = undef;
|
||||||
} elsif (has_property($e, "size_is")) {
|
if (has_property($e, "length_is")) {
|
||||||
$metadata_args{get_var($e->{PROPERTIES}->{size_is})} = $e->{NAME};
|
$main = get_var($e->{PROPERTIES}->{length_is});
|
||||||
|
} elsif (has_property($e, "size_is")) {
|
||||||
|
$main = get_var($e->{PROPERTIES}->{size_is});
|
||||||
|
}
|
||||||
|
if ($main) {
|
||||||
|
$metadata_args->{$dir}->{$main} = $e->{NAME};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach my $e (@{$fn->{ELEMENTS}}) {
|
foreach my $e (@{$fn->{ELEMENTS}}) {
|
||||||
next if ($metadata_args{$e->{NAME}});
|
next if (($metadata_args->{in}->{$e->{NAME}} and grep(/in/, @{$e->{DIRECTION}})) or
|
||||||
|
($metadata_args->{out}->{$e->{NAME}}) and grep(/out/, @{$e->{DIRECTION}}));
|
||||||
$self->pidl("PyObject *py_$e->{NAME};");
|
$self->pidl("PyObject *py_$e->{NAME};");
|
||||||
if (grep(/out/,@{$e->{DIRECTION}})) {
|
if (grep(/out/,@{$e->{DIRECTION}})) {
|
||||||
$result_size++;
|
$result_size++;
|
||||||
@ -315,23 +322,27 @@ sub PythonFunctionBody($$$)
|
|||||||
$self->pidl("return NULL;");
|
$self->pidl("return NULL;");
|
||||||
$self->deindent;
|
$self->deindent;
|
||||||
$self->pidl("}");
|
$self->pidl("}");
|
||||||
|
$self->pidl("");
|
||||||
|
|
||||||
if ($fn->{RETURN_TYPE}) {
|
if ($fn->{RETURN_TYPE}) {
|
||||||
$result_size++ unless ($fn->{RETURN_TYPE} eq "WERROR" or $fn->{RETURN_TYPE} eq "NTSTATUS");
|
$result_size++ unless ($fn->{RETURN_TYPE} eq "WERROR" or $fn->{RETURN_TYPE} eq "NTSTATUS");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
my $fail = "talloc_free(mem_ctx); return NULL;";
|
||||||
foreach my $e (@{$fn->{ELEMENTS}}) {
|
foreach my $e (@{$fn->{ELEMENTS}}) {
|
||||||
next unless (grep(/in/,@{$e->{DIRECTION}}));
|
next unless (grep(/in/,@{$e->{DIRECTION}}));
|
||||||
if ($metadata_args{$e->{NAME}}) {
|
if ($metadata_args->{in}->{$e->{NAME}}) {
|
||||||
my $val = "PyList_Size(py_".$metadata_args{$e->{NAME}}.")";
|
my $py_var = "py_".$metadata_args->{in}->{$e->{NAME}};
|
||||||
|
$self->pidl("PY_CHECK_TYPE(PyList, $py_var, $fail);");
|
||||||
|
my $val = "PyList_Size($py_var)";
|
||||||
if ($e->{LEVELS}[0]->{TYPE} eq "POINTER") {
|
if ($e->{LEVELS}[0]->{TYPE} eq "POINTER") {
|
||||||
$self->pidl("r->in.$e->{NAME} = talloc_ptrtype(mem_ctx, r->in.$e->{NAME});");
|
$self->pidl("r->in.$e->{NAME} = talloc_ptrtype(mem_ctx, r->in.$e->{NAME});");
|
||||||
$self->pidl("*r->in.$e->{NAME} = $val;");
|
$self->pidl("*r->in.$e->{NAME} = $val;");
|
||||||
} else {
|
} else {
|
||||||
$self->pidl("r->in.$e->{NAME} = PyList_Size(py_".$metadata_args{$e->{NAME}}.");");
|
$self->pidl("r->in.$e->{NAME} = $val;");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$self->ConvertObjectFromPython($env, "mem_ctx", $e, "py_$e->{NAME}", "r->in.$e->{NAME}", "talloc_free(mem_ctx); return NULL;");
|
$self->ConvertObjectFromPython($env, "mem_ctx", $e, "py_$e->{NAME}", "r->in.$e->{NAME}", $fail);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$self->pidl("status = dcerpc_$fn->{NAME}(iface->pipe, mem_ctx, r);");
|
$self->pidl("status = dcerpc_$fn->{NAME}(iface->pipe, mem_ctx, r);");
|
||||||
@ -348,7 +359,7 @@ sub PythonFunctionBody($$$)
|
|||||||
}
|
}
|
||||||
|
|
||||||
foreach my $e (@{$fn->{ELEMENTS}}) {
|
foreach my $e (@{$fn->{ELEMENTS}}) {
|
||||||
next if ($metadata_args{$e->{NAME}});
|
next if ($metadata_args->{out}->{$e->{NAME}});
|
||||||
my $py_name = "py_$e->{NAME}";
|
my $py_name = "py_$e->{NAME}";
|
||||||
if (grep(/out/,@{$e->{DIRECTION}})) {
|
if (grep(/out/,@{$e->{DIRECTION}})) {
|
||||||
$self->ConvertObjectToPython("r", $env, $e, "r->out.$e->{NAME}", $py_name);
|
$self->ConvertObjectToPython("r", $env, $e, "r->out.$e->{NAME}", $py_name);
|
||||||
|
Loading…
Reference in New Issue
Block a user