[SCM] Samba Shared Repository - branch master updated

Andrew Bartlett abartlet at samba.org
Tue Dec 10 04:17:03 UTC 2019


The branch, master has been updated
       via  ef5d79e24ba pidl/tests/samba-ndr.pl: remove duplicate import
       via  fbe402edf55 pidl s4::Python: silence warnings
       via  51a11afecf5 pidl Parse::Pidl::NDR: silence two warnings about undefined strings
       via  3c90c9de6f4 pidl Parse::Pidl::NDR: add HRESULT alignment
       via  33255102acd pidl Parse::Pidl::NDR: warn of unknown scalar alignments
       via  4de002a0f77 pidl s4::NDR::Parser: silence a warning
       via  aefce8e7c0d pidl s4::NDR::Parser: correct has_fast_array logic
       via  2765b5c1a27 pidl s4::NDR::Parser: read hex numbers as numbers for ranges
       via  efef4366f18 pidl: use perl warnings
       via  b6913830bf6 librpc/ndr: Do not follow a client-supplied NULL pointer in _print_drsuapi_DsAttributeValue_attid()
       via  f786cdf5e84 selftest: Add ndrdump tests for malformed drsuapi traffic
      from  83ffe6752d5 pidl: Remove Parse/Yapp/Driver.pm

https://git.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit ef5d79e24ba8aec226419e594de0cf91c24d7fc4
Author: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
Date:   Sun Dec 1 00:44:52 2019 +1300

    pidl/tests/samba-ndr.pl: remove duplicate import
    
    Signed-off-by: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>
    
    Autobuild-User(master): Andrew Bartlett <abartlet at samba.org>
    Autobuild-Date(master): Tue Dec 10 04:16:31 UTC 2019 on sn-devel-184

commit fbe402edf55cc4dda8820645c7c4e20862969803
Author: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
Date:   Sun Dec 1 00:43:52 2019 +1300

    pidl s4::Python: silence warnings
    
    - do not redeclare variables in the same scope.
    - use $1 instead of \1, which perl just prefers.
    
    Signed-off-by: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

commit 51a11afecf590a26b784c1d2e484829330efa44f
Author: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
Date:   Sun Dec 1 00:43:02 2019 +1300

    pidl Parse::Pidl::NDR: silence two warnings about undefined strings
    
    Signed-off-by: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

commit 3c90c9de6f45af60d9db5f40ec0dad6318e53e3d
Author: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
Date:   Sun Dec 1 00:42:22 2019 +1300

    pidl Parse::Pidl::NDR: add HRESULT alignment
    
    this is a guess
    
    Signed-off-by: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

commit 33255102acd755cacceafd2a082722ed0fbc695f
Author: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
Date:   Sun Dec 1 00:41:42 2019 +1300

    pidl Parse::Pidl::NDR: warn of unknown scalar alignments
    
    Signed-off-by: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

commit 4de002a0f77dba8345ca6c395a855a5c053a8dd4
Author: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
Date:   Sat Nov 30 23:05:56 2019 +1300

    pidl s4::NDR::Parser: silence a warning
    
    At level 0 there is no previous level so $pl is undefined thus so is ->{TYPE}
    
    Signed-off-by: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

commit aefce8e7c0d82241ab6ecfab7d714338b331bc52
Author: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
Date:   Sat Nov 30 22:52:23 2019 +1300

    pidl s4::NDR::Parser: correct has_fast_array logic
    
    Here we fix two bugs that cancelled each other out completely, so this
    patch leaves us with exactly the same functionally as before.
    
    Bug 1: In perl, return is *syntactically* a function.
    
    That means 'return X or Y' is read as 'return(X) or Y', as in the
    'open(X) or die "..."' construct -- Y is only evaluated if return
    returns false. But return never returns, so Y is dead code. If in
    doubt, try these:
    
    perl -e "sub x {return 0 or die;} x"
    perl -e "sub x {return (0 or die);} x"
    
    What we *meant* here is 'return (X or Y)', BUT it turns out we were
    confused -- the Y case was bogus.
    
    Bug 2: string arrays never had "fast array logic" in the first place.
    
    The fast array logic is for arrays of bytes, and can be fast (i.e.
    memcpy) because there is no endianness to worry about. A string array
    is an array of pointers not bytes.
    
    Signed-off-by: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

commit 2765b5c1a27232b990537415718e98449617641b
Author: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
Date:   Sat Nov 30 23:37:08 2019 +1300

    pidl s4::NDR::Parser: read hex numbers as numbers for ranges
    
    Hex numbers in IDL are not parsed as numbers, resulting in warnings
    like
    
    Argument 0x2000 isn't numeric in numeric lt (<) at /home/douglas/src/samba/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm line 981
    
    not to mention problematic code. We add a utility function to convert
    these numbers to numbers.
    
    A typical difference this makes is:
    
     --- old/default/librpc/gen_ndr/ndr_dcerpc.c     2019-11-30 23:40:32.915816967 +1300
     +++ new/default/librpc/gen_ndr/ndr_dcerpc.c     2019-11-30 17:00:09.055733660 +1300
     @@ -1893,7 +1893,7 @@
             if (ndr_flags & NDR_SCALARS) {
                     NDR_CHECK(ndr_pull_align(ndr, 4));
                     NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->ReceiveWindowSize));
     -               if (r->ReceiveWindowSize > 0x40000) {
     +               if (r->ReceiveWindowSize < 8192 || r->ReceiveWindowSize > 262144) {
                             return ndr_pull_error(ndr, NDR_ERR_RANGE, "value out of range");
                     }
                     NDR_CHECK(ndr_pull_trailer_align(ndr, 4));
    
    Where the minimum ("0x2000" == 8192) was read as a string, thus
    treated as zero.
    
    The treatment as zero was introduced in 142b2a61f8a77b3065ce4c78b459ab714d6d190a
    accidentially, which shows why warnings are important.
    
    Signed-off-by: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

commit efef4366f18515ec78cb025928c20fb7986cd98f
Author: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
Date:   Sat Nov 30 22:34:54 2019 +1300

    pidl: use perl warnings
    
    Warnings are good. If we turn on warnings with 'use warnings', we will
    see bugs that have lain latent for years.
    
    Signed-off-by: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

commit b6913830bf626c8d7059f4cda3a4fc1bb3081973
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Thu Dec 5 09:56:44 2019 +1300

    librpc/ndr: Do not follow a client-supplied NULL pointer in _print_drsuapi_DsAttributeValue_attid()
    
    This is not a security issue as it only happens when printing the structure
    during debugging, not normal production.
    
    Found by Michael Hanselmann using an NDR fuzzer and Hongfuzz.
    
    Signed-off-by: Andrew Bartlett <abartlet at samba.org>
    Reviewed-by: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>

commit f786cdf5e84f70c9a0ca206c761d453d42e72251
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Thu Dec 5 11:10:14 2019 +1300

    selftest: Add ndrdump tests for malformed drsuapi traffic
    
    Thanks to Douglas Bagnall for the samples, produced from seeds
    generated by Samba's make test traffic, fuzzed by ndr_fuzz_X
    and Hongfuzz.
    
    Signed-off-by: Andrew Bartlett <abartlet at samba.org>
    Reviewed-by: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>

-----------------------------------------------------------------------

Summary of changes:
 librpc/ndr/ndr_drsuapi.c                           |  10 +-
 pidl/lib/Parse/Pidl.pm                             |   2 +-
 pidl/lib/Parse/Pidl/CUtil.pm                       |   1 +
 pidl/lib/Parse/Pidl/Compat.pm                      |   1 +
 pidl/lib/Parse/Pidl/Dump.pm                        |   1 +
 pidl/lib/Parse/Pidl/Expr.pm                        |   1 +
 pidl/lib/Parse/Pidl/IDL.pm                         |   1 +
 pidl/lib/Parse/Pidl/NDR.pm                         |  15 +-
 pidl/lib/Parse/Pidl/ODL.pm                         |   1 +
 pidl/lib/Parse/Pidl/Samba3/ClientNDR.pm            |   1 +
 pidl/lib/Parse/Pidl/Samba3/ServerNDR.pm            |   1 +
 pidl/lib/Parse/Pidl/Samba3/Template.pm             |   1 +
 pidl/lib/Parse/Pidl/Samba4.pm                      |   1 +
 pidl/lib/Parse/Pidl/Samba4/COM/Header.pm           |   1 +
 pidl/lib/Parse/Pidl/Samba4/COM/Proxy.pm            |   1 +
 pidl/lib/Parse/Pidl/Samba4/COM/Stub.pm             |   1 +
 pidl/lib/Parse/Pidl/Samba4/Header.pm               |   1 +
 pidl/lib/Parse/Pidl/Samba4/NDR/Client.pm           |   1 +
 pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm           |  21 +-
 pidl/lib/Parse/Pidl/Samba4/NDR/Server.pm           |   1 +
 pidl/lib/Parse/Pidl/Samba4/Python.pm               |   8 +-
 pidl/lib/Parse/Pidl/Samba4/TDR.pm                  |   1 +
 pidl/lib/Parse/Pidl/Samba4/Template.pm             |   1 +
 pidl/lib/Parse/Pidl/Typelist.pm                    |   1 +
 pidl/lib/Parse/Pidl/Util.pm                        |  38 +-
 pidl/lib/Parse/Pidl/Wireshark/Conformance.pm       |   1 +
 pidl/lib/Parse/Pidl/Wireshark/NDR.pm               |   1 +
 pidl/pidl                                          |   1 +
 pidl/tests/Util.pm                                 |   1 +
 pidl/tests/ndr_align.pl                            |   1 +
 pidl/tests/ndr_alloc.pl                            |   1 +
 pidl/tests/ndr_array.pl                            |   1 +
 pidl/tests/ndr_compat.pl                           |   1 +
 pidl/tests/ndr_fullptr.pl                          |   1 +
 pidl/tests/ndr_refptr.pl                           |   1 +
 pidl/tests/ndr_represent.pl                        |   1 +
 pidl/tests/ndr_simple.pl                           |   1 +
 pidl/tests/ndr_string.pl                           |   1 +
 pidl/tests/ndr_tagtype.pl                          |   2 +-
 pidl/tests/parse_idl.pl                            |   2 +-
 pidl/tests/samba-ndr.pl                            |   1 -
 pidl/tests/test_util.pl                            |   1 +
 python/samba/tests/blackbox/ndrdump.py             |  24 +
 .../tests/fuzzed_drsuapi_DsAddEntry_1.b64.txt      |   1 +
 .../librpc/tests/fuzzed_drsuapi_DsAddEntry_1.txt   | 508 +++++++++++++++++++++
 .../fuzzed_drsuapi_DsReplicaAttribute.b64.txt      |   1 +
 .../tests/fuzzed_drsuapi_DsReplicaAttribute.txt    |  31 ++
 47 files changed, 675 insertions(+), 22 deletions(-)
 create mode 100644 source4/librpc/tests/fuzzed_drsuapi_DsAddEntry_1.b64.txt
 create mode 100644 source4/librpc/tests/fuzzed_drsuapi_DsAddEntry_1.txt
 create mode 100644 source4/librpc/tests/fuzzed_drsuapi_DsReplicaAttribute.b64.txt
 create mode 100644 source4/librpc/tests/fuzzed_drsuapi_DsReplicaAttribute.txt


Changeset truncated at 500 lines:

diff --git a/librpc/ndr/ndr_drsuapi.c b/librpc/ndr/ndr_drsuapi.c
index 45d3ac095c3..cd550f1f0ee 100644
--- a/librpc/ndr/ndr_drsuapi.c
+++ b/librpc/ndr/ndr_drsuapi.c
@@ -94,8 +94,14 @@ static void _print_drsuapi_DsAttributeValue_attid(struct ndr_print *ndr, const c
 
 	ndr_print_struct(ndr, name, "drsuapi_DsAttributeValue");
 	ndr->depth++;
-	v = IVAL(r->blob->data, 0);
-	ndr_print_uint32(ndr, "attid", v);
+	if (r->blob == NULL || r->blob->data == NULL) {
+		ndr_print_string(ndr, "attid", "NULL");
+	} else if (r->blob->length < 4) {
+		ndr_print_DATA_BLOB(ndr, "attid", *r->blob);
+	} else {
+		v = IVAL(r->blob->data, 0);
+		ndr_print_uint32(ndr, "attid", v);
+	}
 	ndr->depth--;
 }
 
diff --git a/pidl/lib/Parse/Pidl.pm b/pidl/lib/Parse/Pidl.pm
index 40e3673908e..e4c39b3d063 100644
--- a/pidl/lib/Parse/Pidl.pm
+++ b/pidl/lib/Parse/Pidl.pm
@@ -12,7 +12,7 @@ require Exporter;
 @EXPORT_OK = qw(warning error fatal $VERSION);
 
 use strict;
-
+use warnings;
 use vars qw ( $VERSION );
 
 $VERSION = '0.02';
diff --git a/pidl/lib/Parse/Pidl/CUtil.pm b/pidl/lib/Parse/Pidl/CUtil.pm
index 9deb6ee1779..ccd8fcc3d82 100644
--- a/pidl/lib/Parse/Pidl/CUtil.pm
+++ b/pidl/lib/Parse/Pidl/CUtil.pm
@@ -11,6 +11,7 @@ use vars qw($VERSION);
 $VERSION = '0.01';
 
 use strict;
+use warnings;
 
 sub get_pointer_to($)
 {
diff --git a/pidl/lib/Parse/Pidl/Compat.pm b/pidl/lib/Parse/Pidl/Compat.pm
index b8abcb88195..062a53b8bea 100644
--- a/pidl/lib/Parse/Pidl/Compat.pm
+++ b/pidl/lib/Parse/Pidl/Compat.pm
@@ -8,6 +8,7 @@ package Parse::Pidl::Compat;
 use Parse::Pidl qw(warning);
 use Parse::Pidl::Util qw(has_property);
 use strict;
+use warnings;
 
 use vars qw($VERSION);
 $VERSION = '0.01';
diff --git a/pidl/lib/Parse/Pidl/Dump.pm b/pidl/lib/Parse/Pidl/Dump.pm
index 4e623db673a..5d241b812c5 100644
--- a/pidl/lib/Parse/Pidl/Dump.pm
+++ b/pidl/lib/Parse/Pidl/Dump.pm
@@ -27,6 +27,7 @@ $VERSION = '0.01';
 @EXPORT_OK = qw(DumpType DumpTypedef DumpStruct DumpEnum DumpBitmap DumpUnion DumpFunction);
 
 use strict;
+use warnings;
 use Parse::Pidl::Util qw(has_property);
 
 my($res);
diff --git a/pidl/lib/Parse/Pidl/Expr.pm b/pidl/lib/Parse/Pidl/Expr.pm
index 24581d29f49..967d687670e 100644
--- a/pidl/lib/Parse/Pidl/Expr.pm
+++ b/pidl/lib/Parse/Pidl/Expr.pm
@@ -10,6 +10,7 @@
 package Parse::Pidl::Expr;
 use vars qw ( @ISA );
 use strict;
+use warnings;
 
 @ISA= qw ( Parse::Yapp::Driver );
 use Parse::Yapp::Driver;
diff --git a/pidl/lib/Parse/Pidl/IDL.pm b/pidl/lib/Parse/Pidl/IDL.pm
index 6927c892556..28bdf2f9d84 100644
--- a/pidl/lib/Parse/Pidl/IDL.pm
+++ b/pidl/lib/Parse/Pidl/IDL.pm
@@ -10,6 +10,7 @@
 package Parse::Pidl::IDL;
 use vars qw ( @ISA );
 use strict;
+use warnings;
 
 @ISA= qw ( Parse::Yapp::Driver );
 use Parse::Yapp::Driver;
diff --git a/pidl/lib/Parse/Pidl/NDR.pm b/pidl/lib/Parse/Pidl/NDR.pm
index 003156e3a11..44338a1298d 100644
--- a/pidl/lib/Parse/Pidl/NDR.pm
+++ b/pidl/lib/Parse/Pidl/NDR.pm
@@ -38,6 +38,7 @@ $VERSION = '0.01';
 @EXPORT_OK = qw(GetElementLevelTable ParseElement ReturnTypeElement ValidElement align_type mapToScalar ParseType can_contain_deferred is_charset_array);
 
 use strict;
+use warnings;
 use Parse::Pidl qw(warning fatal);
 use Parse::Pidl::Typelist qw(hasType getType typeIs expandAlias mapScalarType is_fixed_size_scalar);
 use Parse::Pidl::Util qw(has_property property_matches);
@@ -80,7 +81,8 @@ my $scalar_alignment = {
 	'ipv4address' => 4,
 	'ipv6address' => 4, #16?
 	'dnsp_name' => 1,
-	'dnsp_string' => 1
+	'dnsp_string' => 1,
+	'HRESULT' => 4,
 };
 
 sub GetElementLevelTable($$$)
@@ -115,7 +117,7 @@ sub GetElementLevelTable($$$)
 		warning($e, "[out] argument `$e->{NAME}' not a pointer") if ($needptrs > $e->{POINTERS});
 	}
 
-	my $allow_pipe = ($e->{PARENT}->{TYPE} eq "FUNCTION");
+	my $allow_pipe = (($e->{PARENT}->{TYPE} // '') eq "FUNCTION");
 	my $is_pipe = typeIs($e->{TYPE}, "PIPE");
 
 	if ($is_pipe) {
@@ -468,7 +470,12 @@ sub align_type($)
 	my ($e) = @_;
 
 	if (ref($e) eq "HASH" and $e->{TYPE} eq "SCALAR") {
-		return $scalar_alignment->{$e->{NAME}};
+		my $ret = $scalar_alignment->{$e->{NAME}};
+		if (not defined $ret) {
+			warning($e, "no scalar alignment for $e->{NAME}!");
+			return 0;
+		}
+		return $ret;
 	}
 
 	return 0 if ($e eq "EMPTY");
@@ -903,7 +910,7 @@ sub ParseInterface($)
 
 	return { 
 		NAME => $idl->{NAME},
-		UUID => lc(has_property($idl, "uuid")),
+		UUID => lc(has_property($idl, "uuid") // ''),
 		VERSION => $version,
 		TYPE => "INTERFACE",
 		PROPERTIES => $idl->{PROPERTIES},
diff --git a/pidl/lib/Parse/Pidl/ODL.pm b/pidl/lib/Parse/Pidl/ODL.pm
index 14e77fa93f2..12f869c662e 100644
--- a/pidl/lib/Parse/Pidl/ODL.pm
+++ b/pidl/lib/Parse/Pidl/ODL.pm
@@ -10,6 +10,7 @@ use Parse::Pidl::Util qw(has_property unmake_str);
 use Parse::Pidl::Typelist qw(hasType getType);
 use File::Basename;
 use strict;
+use warnings;
 
 use vars qw($VERSION);
 $VERSION = '0.01';
diff --git a/pidl/lib/Parse/Pidl/Samba3/ClientNDR.pm b/pidl/lib/Parse/Pidl/Samba3/ClientNDR.pm
index c132b552f9a..816440ef033 100644
--- a/pidl/lib/Parse/Pidl/Samba3/ClientNDR.pm
+++ b/pidl/lib/Parse/Pidl/Samba3/ClientNDR.pm
@@ -9,6 +9,7 @@ package Parse::Pidl::Samba3::ClientNDR;
 use base Parse::Pidl::Base;
 
 use strict;
+use warnings;
 use Parse::Pidl qw(fatal warning error);
 use Parse::Pidl::Util qw(has_property ParseExpr genpad);
 use Parse::Pidl::NDR qw(ContainsPipe);
diff --git a/pidl/lib/Parse/Pidl/Samba3/ServerNDR.pm b/pidl/lib/Parse/Pidl/Samba3/ServerNDR.pm
index fa7303b8543..d93d5197260 100644
--- a/pidl/lib/Parse/Pidl/Samba3/ServerNDR.pm
+++ b/pidl/lib/Parse/Pidl/Samba3/ServerNDR.pm
@@ -11,6 +11,7 @@ use Exporter;
 @EXPORT_OK = qw(DeclLevel);
 
 use strict;
+use warnings;
 use Parse::Pidl qw(warning error fatal);
 use Parse::Pidl::Typelist qw(mapTypeName scalar_is_reference);
 use Parse::Pidl::Util qw(ParseExpr has_property is_constant);
diff --git a/pidl/lib/Parse/Pidl/Samba3/Template.pm b/pidl/lib/Parse/Pidl/Samba3/Template.pm
index d50f7062395..ee64aebf365 100644
--- a/pidl/lib/Parse/Pidl/Samba3/Template.pm
+++ b/pidl/lib/Parse/Pidl/Samba3/Template.pm
@@ -11,6 +11,7 @@ $VERSION = '0.01';
 use Parse::Pidl::Util qw(genpad);
 
 use strict;
+use warnings;
 
 my($res);
 
diff --git a/pidl/lib/Parse/Pidl/Samba4.pm b/pidl/lib/Parse/Pidl/Samba4.pm
index b720ab90159..6b3f221887f 100644
--- a/pidl/lib/Parse/Pidl/Samba4.pm
+++ b/pidl/lib/Parse/Pidl/Samba4.pm
@@ -14,6 +14,7 @@ use Parse::Pidl::NDR qw(GetNextLevel);
 use Parse::Pidl::Typelist qw(mapTypeName scalar_is_reference);
 use Parse::Pidl qw(fatal error);
 use strict;
+use warnings;
 
 use vars qw($VERSION);
 $VERSION = '0.01';
diff --git a/pidl/lib/Parse/Pidl/Samba4/COM/Header.pm b/pidl/lib/Parse/Pidl/Samba4/COM/Header.pm
index de7d4547a5b..159f417236f 100644
--- a/pidl/lib/Parse/Pidl/Samba4/COM/Header.pm
+++ b/pidl/lib/Parse/Pidl/Samba4/COM/Header.pm
@@ -10,6 +10,7 @@ use vars qw($VERSION);
 $VERSION = '0.01';
 
 use strict;
+use warnings;
 
 sub GetArgumentProtoList($)
 {
diff --git a/pidl/lib/Parse/Pidl/Samba4/COM/Proxy.pm b/pidl/lib/Parse/Pidl/Samba4/COM/Proxy.pm
index de050e8f8c6..1630cf235dc 100644
--- a/pidl/lib/Parse/Pidl/Samba4/COM/Proxy.pm
+++ b/pidl/lib/Parse/Pidl/Samba4/COM/Proxy.pm
@@ -14,6 +14,7 @@ use vars qw($VERSION);
 $VERSION = '0.01';
 
 use strict;
+use warnings;
 
 my($res);
 
diff --git a/pidl/lib/Parse/Pidl/Samba4/COM/Stub.pm b/pidl/lib/Parse/Pidl/Samba4/COM/Stub.pm
index 746b384a462..71980383572 100644
--- a/pidl/lib/Parse/Pidl/Samba4/COM/Stub.pm
+++ b/pidl/lib/Parse/Pidl/Samba4/COM/Stub.pm
@@ -9,6 +9,7 @@ package Parse::Pidl::Samba4::COM::Stub;
 
 use Parse::Pidl::Util qw(has_property);
 use strict;
+use warnings;
 
 use vars qw($VERSION);
 $VERSION = '0.01';
diff --git a/pidl/lib/Parse/Pidl/Samba4/Header.pm b/pidl/lib/Parse/Pidl/Samba4/Header.pm
index e9b7bee040c..b818dce30ca 100644
--- a/pidl/lib/Parse/Pidl/Samba4/Header.pm
+++ b/pidl/lib/Parse/Pidl/Samba4/Header.pm
@@ -11,6 +11,7 @@ require Exporter;
 @EXPORT_OK = qw(GenerateFunctionInEnv GenerateFunctionOutEnv EnvSubstituteValue GenerateStructEnv);
 
 use strict;
+use warnings;
 use Parse::Pidl qw(fatal);
 use Parse::Pidl::Typelist qw(mapTypeName scalar_is_reference);
 use Parse::Pidl::Util qw(has_property is_constant unmake_str ParseExpr);
diff --git a/pidl/lib/Parse/Pidl/Samba4/NDR/Client.pm b/pidl/lib/Parse/Pidl/Samba4/NDR/Client.pm
index ddd757c749b..58ec389a9f3 100644
--- a/pidl/lib/Parse/Pidl/Samba4/NDR/Client.pm
+++ b/pidl/lib/Parse/Pidl/Samba4/NDR/Client.pm
@@ -19,6 +19,7 @@ use vars qw($VERSION);
 $VERSION = '0.01';
 
 use strict;
+use warnings;
 
 sub fn_declare($$) { my ($self,$n) = @_; $self->pidl($n); $self->pidl_hdr("$n;"); }
 sub new($)
diff --git a/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm b/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm
index 3ae0db22f7a..94428ec2037 100644
--- a/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm
+++ b/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm
@@ -13,8 +13,15 @@ push @ISA, qw(Exporter);
 @EXPORT_OK = qw(check_null_pointer NeededFunction NeededElement NeededType $res NeededInterface TypeFunctionName ParseElementPrint);
 
 use strict;
+use warnings;
 use Parse::Pidl::Typelist qw(hasType getType mapTypeName typeHasBody);
-use Parse::Pidl::Util qw(has_property ParseExpr ParseExprExt print_uuid unmake_str);
+use Parse::Pidl::Util qw(has_property
+			 ParseExpr
+			 ParseExprExt
+			 print_uuid
+			 unmake_str
+			 parse_int
+			 parse_range);
 use Parse::Pidl::CUtil qw(get_pointer_to get_value_of get_array_element);
 use Parse::Pidl::NDR qw(GetPrevLevel GetNextLevel ContainsDeferred ContainsPipe is_charset_array);
 use Parse::Pidl::Samba4 qw(is_intree choose_header ArrayDynamicallyAllocated);
@@ -77,8 +84,8 @@ sub has_fast_array($$)
 
 	my $t = getType($nl->{DATA_TYPE});
 
-	# Only uint8 and string have fast array functions at the moment
-	return ($t->{NAME} eq "uint8") or ($t->{NAME} eq "string");
+	# Only uint8 has a fast array function at the moment
+	return ($t->{NAME} eq "uint8");
 }
 
 
@@ -336,7 +343,7 @@ sub ParseArrayPullGetSize($$$$$$)
 	my $array_size = "size_$e->{NAME}_$l->{LEVEL_INDEX}";
 
 	if (my $range = has_property($e, "range")) {
-		my ($low, $high) = split(/,/, $range, 2);
+		my ($low, $high) = parse_range($range);
 		if ($low < 0) {
 			warning(0, "$low is invalid for the range of an array size");
 		}
@@ -371,7 +378,7 @@ sub ParseArrayPullGetLength($$$$$$;$)
 	my $array_length = "length_$e->{NAME}_$l->{LEVEL_INDEX}";
 
 	if (my $range = has_property($e, "range")) {
-		my ($low, $high) = split(/,/, $range, 2);
+		my ($low, $high) = parse_range($range);
 		if ($low < 0) {
 			warning(0, "$low is invalid for the range of an array size");
 		}
@@ -973,10 +980,10 @@ sub ParseDataPull($$$$$$$)
 		my $pl = GetPrevLevel($e, $l);
 
 		my $range = has_property($e, "range");
-		if ($range and $pl->{TYPE} ne "ARRAY") {
+		if ($range and (not $pl or $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);
+			my ($low, $high) = parse_range($range);
 			if ($low < 0 and not $signed) {
 				warning(0, "$low is invalid for the range of an unsigned type");
 			}
diff --git a/pidl/lib/Parse/Pidl/Samba4/NDR/Server.pm b/pidl/lib/Parse/Pidl/Samba4/NDR/Server.pm
index f87975cf939..01974ed244b 100644
--- a/pidl/lib/Parse/Pidl/Samba4/NDR/Server.pm
+++ b/pidl/lib/Parse/Pidl/Samba4/NDR/Server.pm
@@ -7,6 +7,7 @@
 package Parse::Pidl::Samba4::NDR::Server;
 
 use strict;
+use warnings;
 use Parse::Pidl::Util;
 
 use vars qw($VERSION);
diff --git a/pidl/lib/Parse/Pidl/Samba4/Python.pm b/pidl/lib/Parse/Pidl/Samba4/Python.pm
index a50f0b54df6..84d4dade512 100644
--- a/pidl/lib/Parse/Pidl/Samba4/Python.pm
+++ b/pidl/lib/Parse/Pidl/Samba4/Python.pm
@@ -7,6 +7,7 @@ package Parse::Pidl::Samba4::Python;
 use parent Parse::Pidl::Base;
 
 use strict;
+use warnings;
 use Parse::Pidl qw(warning fatal error);
 use Parse::Pidl::Typelist qw(hasType resolveType getType mapTypeName expandAlias bitmap_type_fn enum_type_fn);
 use Parse::Pidl::Util qw(has_property ParseExpr unmake_str);
@@ -37,7 +38,7 @@ sub PrettifyTypeName($$)
 {
 	my ($name, $basename) = @_;
 
-	$basename =~ s/^.*\.([^.]+)$/\1/;
+	$basename =~ s/^.*\.([^.]+)$/$1/;
 
 	$name =~ s/^$basename\_//;
 
@@ -189,7 +190,6 @@ sub PythonElementGetSet($$$$$$) {
 	$self->indent;
 	$self->pidl("$cname *object = ($cname *)pytalloc_get_ptr(py_obj);");
 	my $mem_ctx = "pytalloc_get_mem_ctx(py_obj)";
-	my $l = $e->{LEVELS}[0];
 	my $nl = GetNextLevel($e, $l);
 	if ($l->{TYPE} eq "POINTER" and
 		not ($nl->{TYPE} eq "ARRAY" and ($nl->{IS_FIXED} or is_charset_array($e, $nl))) and
@@ -1478,9 +1478,9 @@ sub Interface($$$)
 
 		$self->pidl("");
 
-		my $signature = "\"$interface->{NAME}_abstract_syntax()\\n\"";
+		$signature = "\"$interface->{NAME}_abstract_syntax()\\n\"";
 
-		my $docstring = $self->DocString($interface, $interface->{NAME}."_syntax");
+		$docstring = $self->DocString($interface, $interface->{NAME}."_syntax");
 
 		if ($docstring) {
 			$docstring = "$signature$docstring";
diff --git a/pidl/lib/Parse/Pidl/Samba4/TDR.pm b/pidl/lib/Parse/Pidl/Samba4/TDR.pm
index 9cb483c0ae0..c3282879988 100644
--- a/pidl/lib/Parse/Pidl/Samba4/TDR.pm
+++ b/pidl/lib/Parse/Pidl/Samba4/TDR.pm
@@ -15,6 +15,7 @@ use vars qw($VERSION);
 $VERSION = '0.01';
 
 use strict;
+use warnings;
 
 sub new($) {
 	my ($class) = shift;
diff --git a/pidl/lib/Parse/Pidl/Samba4/Template.pm b/pidl/lib/Parse/Pidl/Samba4/Template.pm
index d9fb3041163..6a6755b8f57 100644
--- a/pidl/lib/Parse/Pidl/Samba4/Template.pm
+++ b/pidl/lib/Parse/Pidl/Samba4/Template.pm
@@ -11,6 +11,7 @@ $VERSION = '0.01';
 use Parse::Pidl::Util qw(genpad);
 
 use strict;
+use warnings;
 
 my($res);
 
diff --git a/pidl/lib/Parse/Pidl/Typelist.pm b/pidl/lib/Parse/Pidl/Typelist.pm
index 774554f093b..2b850ffee4b 100644
--- a/pidl/lib/Parse/Pidl/Typelist.pm
+++ b/pidl/lib/Parse/Pidl/Typelist.pm
@@ -16,6 +16,7 @@ $VERSION = '0.01';
 
 use Parse::Pidl::Util qw(has_property);
 use strict;
+use warnings;
 
 my %types = ();
 
diff --git a/pidl/lib/Parse/Pidl/Util.pm b/pidl/lib/Parse/Pidl/Util.pm
index 83e23937a87..7a6039ba12b 100644
--- a/pidl/lib/Parse/Pidl/Util.pm
+++ b/pidl/lib/Parse/Pidl/Util.pm
@@ -6,11 +6,12 @@ package Parse::Pidl::Util;
 
 require Exporter;
 @ISA = qw(Exporter);
- at EXPORT = qw(has_property property_matches ParseExpr ParseExprExt is_constant make_str unmake_str print_uuid MyDumper genpad);
+ at EXPORT = qw(has_property property_matches ParseExpr ParseExprExt is_constant make_str unmake_str print_uuid MyDumper genpad parse_int parse_range);
 use vars qw($VERSION);
 $VERSION = '0.01';
 
 use strict;
+use warnings;
 
 use Parse::Pidl::Expr;
 use Parse::Pidl qw(error);
@@ -190,6 +191,41 @@ sub genpad($)
 	return "\t"x($nt)." "x($ns);
 }
 
+=item B<parse_int>
+
+Try to convert hex and octal strings to numbers. If a string doesn't
+look hexish or octish it will be left as is. If the unconverted string
+is actually a decimal number, Perl is likely to handle it correctly.
+
+=cut
+
+sub parse_int {
+	my $s = shift;
+	if ($s =~ /^0[xX][0-9A-Fa-f]+$/) {
+		return hex $s;
+	}
+	if ($s =~ /^0[0-7]+$/) {
+		return oct $s;
+	}
+	return $s;
+}
+
+=item B<parse_range>
+
+Read a range specification that might contain hex or octal numbers,
+and work out what those numbers are.
+
+=cut
+
+sub parse_range {
+	my $range = shift;
+	my ($low, $high) = split(/,/, $range, 2);
+	$low = parse_int($low);
+	$high = parse_int($high);
+	return ($low, $high);
+}
+
+
 =back
 
 =cut
diff --git a/pidl/lib/Parse/Pidl/Wireshark/Conformance.pm b/pidl/lib/Parse/Pidl/Wireshark/Conformance.pm
index 01a8c473c56..7f7ef184c18 100644
--- a/pidl/lib/Parse/Pidl/Wireshark/Conformance.pm
+++ b/pidl/lib/Parse/Pidl/Wireshark/Conformance.pm
@@ -115,6 +115,7 @@ $VERSION = '0.01';
 @EXPORT_OK = qw(ReadConformance ReadConformanceFH valid_ft_type valid_base_type);
 
 use strict;
+use warnings;
 
 use Parse::Pidl qw(fatal warning error);
 use Parse::Pidl::Util qw(has_property);
diff --git a/pidl/lib/Parse/Pidl/Wireshark/NDR.pm b/pidl/lib/Parse/Pidl/Wireshark/NDR.pm
index 49b0c2c33ba..59cbba8251a 100644
--- a/pidl/lib/Parse/Pidl/Wireshark/NDR.pm
+++ b/pidl/lib/Parse/Pidl/Wireshark/NDR.pm
@@ -21,6 +21,7 @@ use Exporter;
 @EXPORT_OK = qw(field2name %res PrintIdl StripPrefixes RegisterInterfaceHandoff register_hf_field CheckUsed ProcessImport ProcessInclude find_type DumpEttList DumpEttDeclaration DumpHfList DumpHfDeclaration DumpFunctionTable register_type register_ett);
 
 use strict;


-- 
Samba Shared Repository



More information about the samba-cvs mailing list