summaryrefslogtreecommitdiff
path: root/pidl/lib
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2012-03-15 13:05:39 +0100
committerKarolin Seeger <kseeger@samba.org>2012-04-10 16:48:07 +0200
commitb6e74db2936aaeba77a38b5ac85802b7d9bdaad3 (patch)
treee5e54db8e95ee7c80f547851f36eb1a73126cf35 /pidl/lib
parent2de81df668e1b880d5c29c1115250ccf0e4ed617 (diff)
downloadsamba-b6e74db2936aaeba77a38b5ac85802b7d9bdaad3.tar.gz
samba-b6e74db2936aaeba77a38b5ac85802b7d9bdaad3.tar.bz2
samba-b6e74db2936aaeba77a38b5ac85802b7d9bdaad3.zip
pidl/NDR/Parser: split off ParseArrayPullGetSize() and ParseArrayPullGetLength()
metze
Diffstat (limited to 'pidl/lib')
-rw-r--r--pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm55
1 files changed, 42 insertions, 13 deletions
diff --git a/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm b/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm
index 709ad2a0de..eaf673bbd7 100644
--- a/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm
+++ b/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm
@@ -321,39 +321,68 @@ sub check_null_pointer($$$$)
}
}
-#####################################################################
-# parse an array - pull side
-sub ParseArrayPullHeader($$$$$$)
+sub ParseArrayPullGetSize($$$$$$)
{
my ($self,$e,$l,$ndr,$var_name,$env) = @_;
- my $length;
my $size;
if ($l->{IS_CONFORMANT}) {
- $length = $size = "ndr_get_array_size($ndr, " . get_pointer_to($var_name) . ")";
+ $size = "ndr_get_array_size($ndr, " . get_pointer_to($var_name) . ")";
} elsif ($l->{IS_ZERO_TERMINATED} and $l->{SIZE_IS} == 0 and $l->{LENGTH_IS} == 0) { # Noheader arrays
- $length = $size = "ndr_get_string_size($ndr, sizeof(*$var_name))";
+ $size = "ndr_get_string_size($ndr, sizeof(*$var_name))";
} else {
- $length = $size = ParseExprExt($l->{SIZE_IS}, $env, $e->{ORIGINAL},
+ $size = ParseExprExt($l->{SIZE_IS}, $env, $e->{ORIGINAL},
check_null_pointer($e, $env, sub { $self->pidl(shift); },
"return ndr_pull_error($ndr, NDR_ERR_INVALID_POINTER, \"NULL Pointer for size_is()\");"),
check_fully_dereferenced($e, $env));
}
+ my $array_size = $size;
+
+ return $array_size;
+}
+
+#####################################################################
+# parse an array - pull side
+sub ParseArrayPullGetLength($$$$$$;$)
+{
+ my ($self,$e,$l,$ndr,$var_name,$env,$array_size) = @_;
+
+ if (not defined($array_size)) {
+ $array_size = $self->ParseArrayPullGetSize($e, $l, $ndr, $var_name, $env);
+ }
+
+ my $array_length = $array_size;
+ if ($l->{IS_VARYING}) {
+ my $length = "ndr_get_array_length($ndr, " . get_pointer_to($var_name) .")";
+ $array_length = $length;
+ }
+
+ return $array_length;
+}
+
+#####################################################################
+# parse an array - pull side
+sub ParseArrayPullHeader($$$$$$)
+{
+ my ($self,$e,$l,$ndr,$var_name,$env) = @_;
+
if ((!$l->{IS_SURROUNDING}) and $l->{IS_CONFORMANT}) {
$self->pidl("NDR_CHECK(ndr_pull_array_size($ndr, " . get_pointer_to($var_name) . "));");
}
if ($l->{IS_VARYING}) {
$self->pidl("NDR_CHECK(ndr_pull_array_length($ndr, " . get_pointer_to($var_name) . "));");
- $length = "ndr_get_array_length($ndr, " . get_pointer_to($var_name) .")";
}
- if ($length ne $size) {
- $self->pidl("if ($length > $size) {");
+ my $array_size = $self->ParseArrayPullGetSize($e, $l, $ndr, $var_name, $env);
+ my $array_length = $self->ParseArrayPullGetLength($e, $l, $ndr, $var_name, $env, $array_size);
+
+ if ($array_length ne $array_size) {
+ $self->pidl("if ($array_length > $array_size) {");
$self->indent;
- $self->pidl("return ndr_pull_error($ndr, NDR_ERR_ARRAY_SIZE, \"Bad array size %u should exceed array length %u\", $size, $length);");
+ $self->pidl("return ndr_pull_error($ndr, NDR_ERR_ARRAY_SIZE, \"Bad array size %u should exceed array length %u\", $array_size, $array_length);");
$self->deindent;
$self->pidl("}");
}
@@ -383,10 +412,10 @@ sub ParseArrayPullHeader($$$$$$)
}
if (ArrayDynamicallyAllocated($e,$l) and not is_charset_array($e,$l)) {
- $self->AllocateArrayLevel($e,$l,$ndr,$var_name,$size);
+ $self->AllocateArrayLevel($e,$l,$ndr,$var_name,$array_size);
}
- return $length;
+ return $array_length;
}
sub compression_alg($$)