summaryrefslogtreecommitdiff
path: root/pidl/lib
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2010-09-21 05:41:37 +0200
committerAnatoliy Atanasov <anatoliy.atanasov@postpath.com>2010-09-23 13:34:08 -0700
commitbea4948acb4bbee2fbf886adeb53edbc84de96da (patch)
tree7eb59f8eba6af13485bf24086063b791ea2933e6 /pidl/lib
parent66731461a6882faf5ec6ba23944e4d4b357125b7 (diff)
downloadsamba-bea4948acb4bbee2fbf886adeb53edbc84de96da.tar.gz
samba-bea4948acb4bbee2fbf886adeb53edbc84de96da.tar.bz2
samba-bea4948acb4bbee2fbf886adeb53edbc84de96da.zip
pidl:NDR/Parser: fix range() for arrays
metze
Diffstat (limited to 'pidl/lib')
-rw-r--r--pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm33
1 files changed, 32 insertions, 1 deletions
diff --git a/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm b/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm
index b389cfbc13..02f7c9a49b 100644
--- a/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm
+++ b/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm
@@ -870,7 +870,10 @@ sub ParseDataPull($$$$$$$)
$self->pidl("NDR_CHECK(".TypeFunctionName("ndr_pull", $l->{DATA_TYPE})."($ndr, $ndr_flags, $var_name));");
- if (my $range = has_property($e, "range")) {
+ my $pl = GetPrevLevel($e, $l);
+
+ my $range = has_property($e, "range");
+ if ($range and $pl->{TYPE} ne "ARRAY") {
$var_name = get_value_of($var_name);
my $signed = Parse::Pidl::Typelist::is_signed($l->{DATA_TYPE});
my ($low, $high) = split(/,/, $range, 2);
@@ -1015,6 +1018,20 @@ sub ParseElementPullLevel
} elsif ($l->{TYPE} eq "ARRAY") {
my $length = $self->ParseArrayPullHeader($e, $l, $ndr, $var_name, $env);
+ if (my $range = has_property($e, "range")) {
+ my ($low, $high) = split(/,/, $range, 2);
+ if ($low < 0) {
+ warning(0, "$low is invalid for the range of an array size");
+ }
+ if ($low == 0) {
+ $self->pidl("if ($length > $high) {");
+ } else {
+ $self->pidl("if ($length < $low || $length > $high) {");
+ }
+ $self->pidl("\treturn ndr_pull_error($ndr, NDR_ERR_RANGE, \"value out of range\");");
+ $self->pidl("}");
+ }
+
my $nl = GetNextLevel($e, $l);
if (is_charset_array($e,$l)) {
@@ -1083,6 +1100,20 @@ sub ParseElementPullLevel
$length = "ndr_get_array_length($ndr, " . get_pointer_to($var_name) .")";
}
+ if (my $range = has_property($e, "range")) {
+ my ($low, $high) = split(/,/, $range, 2);
+ if ($low < 0) {
+ warning(0, "$low is invalid for the range of an array size");
+ }
+ if ($low == 0) {
+ $self->pidl("if ($length > $high) {");
+ } else {
+ $self->pidl("if ($length < $low || $length > $high) {");
+ }
+ $self->pidl("\treturn ndr_pull_error($ndr, NDR_ERR_RANGE, \"value out of range\");");
+ $self->pidl("}");
+ }
+
$var_name = get_array_element($var_name, $counter);
$self->ParseMemCtxPullStart($e, $l, $ndr, $array_name);