summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--pidl/lib/Parse/Pidl/Compat.pm1
-rw-r--r--pidl/lib/Parse/Pidl/NDR.pm1
-rw-r--r--pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm16
-rw-r--r--pidl/lib/Parse/Pidl/Typelist.pm15
4 files changed, 23 insertions, 10 deletions
diff --git a/pidl/lib/Parse/Pidl/Compat.pm b/pidl/lib/Parse/Pidl/Compat.pm
index 58ba136591..1b49c439c4 100644
--- a/pidl/lib/Parse/Pidl/Compat.pm
+++ b/pidl/lib/Parse/Pidl/Compat.pm
@@ -67,7 +67,6 @@ my %supported_properties = (
# array
"range" => ["ELEMENT"],
- "max" => ["ELEMENT"],
"size_is" => ["ELEMENT"],
"string" => ["ELEMENT"],
"noheader" => ["ELEMENT"],
diff --git a/pidl/lib/Parse/Pidl/NDR.pm b/pidl/lib/Parse/Pidl/NDR.pm
index 89632437c1..5ee26d16b6 100644
--- a/pidl/lib/Parse/Pidl/NDR.pm
+++ b/pidl/lib/Parse/Pidl/NDR.pm
@@ -921,7 +921,6 @@ my %property_list = (
# array
"range" => ["ELEMENT"],
- "max" => ["ELEMENT"],
"size_is" => ["ELEMENT"],
"string" => ["ELEMENT"],
"noheader" => ["ELEMENT"],
diff --git a/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm b/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm
index e2b14c10b1..44d21f0b4a 100644
--- a/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm
+++ b/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm
@@ -857,14 +857,16 @@ sub ParseDataPull($$$$$$$)
if (my $range = has_property($e, "range")) {
$var_name = get_value_of($var_name);
+ my $signed = Parse::Pidl::Typelist::is_signed($l->{DATA_TYPE});
my ($low, $high) = split(/,/, $range, 2);
- $self->pidl("if ($var_name < $low || $var_name > $high) {");
- $self->pidl("\treturn ndr_pull_error($ndr, NDR_ERR_RANGE, \"value out of range\");");
- $self->pidl("}");
- }
- if (my $max = has_property($e, "max")) {
- $var_name = get_value_of($var_name);
- $self->pidl("if ($var_name > $max) {");
+ if ($low < 0 and not $signed) {
+ warning(0, "$low is invalid for the range of an unsigned type");
+ }
+ if ($low == 0 and not $signed) {
+ $self->pidl("if ($var_name > $high) {");
+ } else {
+ $self->pidl("if ($var_name < $low || $var_name > $high) {");
+ }
$self->pidl("\treturn ndr_pull_error($ndr, NDR_ERR_RANGE, \"value out of range\");");
$self->pidl("}");
}
diff --git a/pidl/lib/Parse/Pidl/Typelist.pm b/pidl/lib/Parse/Pidl/Typelist.pm
index 0e3fd8de44..4f9d982c21 100644
--- a/pidl/lib/Parse/Pidl/Typelist.pm
+++ b/pidl/lib/Parse/Pidl/Typelist.pm
@@ -8,7 +8,7 @@ package Parse::Pidl::Typelist;
require Exporter;
@ISA = qw(Exporter);
@EXPORT_OK = qw(hasType getType resolveType mapTypeName scalar_is_reference expandAlias
- mapScalarType addType typeIs is_scalar enum_type_fn
+ mapScalarType addType typeIs is_signed is_scalar enum_type_fn
bitmap_type_fn mapType typeHasBody
);
use vars qw($VERSION);
@@ -145,6 +145,19 @@ sub hasType($)
return 0;
}
+sub is_signed($)
+{
+ my $t = shift;
+
+ return ($t eq "int8"
+ or $t eq "int16"
+ or $t eq "int32"
+ or $t eq "dlong"
+ or $t eq "int"
+ or $t eq "long"
+ or $t eq "short");
+}
+
sub is_scalar($)
{
sub is_scalar($);