diff options
author | Jelmer Vernooij <jelmer@samba.org> | 2007-02-07 19:03:19 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 14:44:48 -0500 |
commit | ecf2c1effb778a95fd863a5e87ec7e378d228b57 (patch) | |
tree | 8b94782e07399490d6390e066c557af8c04aefc1 /source4 | |
parent | 2811e18da0d8dae2e2560c11a28450ae8b2a98d5 (diff) | |
download | samba-ecf2c1effb778a95fd863a5e87ec7e378d228b57.tar.gz samba-ecf2c1effb778a95fd863a5e87ec7e378d228b57.tar.bz2 samba-ecf2c1effb778a95fd863a5e87ec7e378d228b57.zip |
r21222: Merge a couple of pidl fixes:
* Pidl will now warn when trying to use pointers as integers in expressions.
* "subcontext()" is now marked as deprecated. The alternatives,
transmit_as() / represent_as() should be available soon.
* More tests.
* Remove some unused code in smbtorture.
(This used to be commit 37c0da541e3962164d5af3e3c9560803a733f3b7)
Diffstat (limited to 'source4')
-rw-r--r-- | source4/pidl/TODO | 4 | ||||
-rw-r--r-- | source4/pidl/expr.yp | 34 | ||||
-rw-r--r-- | source4/pidl/lib/Parse/Pidl/Expr.pm | 1211 | ||||
-rw-r--r-- | source4/pidl/lib/Parse/Pidl/NDR.pm | 7 | ||||
-rw-r--r-- | source4/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm | 96 | ||||
-rw-r--r-- | source4/pidl/lib/Parse/Pidl/Util.pm | 8 | ||||
-rwxr-xr-x | source4/pidl/pidl | 5 | ||||
-rw-r--r-- | source4/pidl/ref_notes.txt | 220 | ||||
-rwxr-xr-x | source4/pidl/tests/ndr_deprecations.pl | 28 | ||||
-rwxr-xr-x[-rw-r--r--] | source4/pidl/tests/ndr_represent.pl | 36 | ||||
-rwxr-xr-x | source4/pidl/tests/util.pl | 23 | ||||
-rw-r--r-- | source4/torture/smbtorture.c | 5 | ||||
-rw-r--r-- | source4/torture/torture.c | 1 |
13 files changed, 842 insertions, 836 deletions
diff --git a/source4/pidl/TODO b/source4/pidl/TODO index 5b3610232c..7cf6a4209a 100644 --- a/source4/pidl/TODO +++ b/source4/pidl/TODO @@ -1,8 +1,6 @@ - EJS output backend shouldn't use the NDR levels stuff but instead as the "C levels" and NDR levels don't necessarily match. -- warn about [out] attributes on pointers (midl/samba3 compatibility) - - true multiple dimension array / strings in arrays support - compatibility mode for generating MIDL-readable data: @@ -21,3 +19,5 @@ - allow data structures outside of interfaces - mem_ctx in the interface rather than as struct ndr member. + +- real typelibs diff --git a/source4/pidl/expr.yp b/source4/pidl/expr.yp index 6faef27588..a8074875ff 100644 --- a/source4/pidl/expr.yp +++ b/source4/pidl/expr.yp @@ -21,9 +21,7 @@ exp: NUM | TEXT { "\"$_[1]\"" } | func - | exp '.' VAR { "$_[1].$_[3]" } - | VAR { $_[0]->_Lookup($_[1]) } - | '*' exp %prec DEREF { $_[0]->_Dereference($_[2]); "*$_[2]" } + | var | '~' exp %prec INV { "~$_[2]" } | exp '+' exp { "$_[1] + $_[3]" } | exp '-' exp { "$_[1] - $_[3]" } @@ -41,7 +39,6 @@ exp: NUM | exp '||' exp { "$_[1] || $_[3]" } | exp '&&' exp { "$_[1] && $_[3]" } | exp '&' exp { "$_[1] & $_[3]" } - | exp '->' VAR { $_[1]."->".$_[3] } | exp '?' exp ':' exp { "$_[1]?$_[3]:$_[5]" } | '~' exp { "~$_[1]" } | '!' exp { "not $_[1]" } @@ -52,9 +49,24 @@ exp: NUM | '(' exp ')' { "($_[2])" } ; +possible_pointer: + VAR { $_[0]->_Lookup($_[1]) } + | '*' possible_pointer %prec DEREF { $_[0]->_Dereference($_[2]); "*$_[2]" } + ; + +var: possible_pointer { $_[0]->_Use($_[1]) } + | var '.' VAR { $_[0]->_Use("$_[1].$_[3]") } + | '(' var ')' { "($_[2])" } + | var '->' VAR { $_[0]->_Use("*$_[1]"); $_[1]."->".$_[3] } +; + + func: VAR '(' opt_args ')' { "$_[1]($_[3])" }; opt_args: { "" } | args; -args: exp | exp ',' args { "$_[1], $_[3]" }; +exp_or_possible_pointer: exp | possible_pointer; +args: exp_or_possible_pointer + | exp_or_possible_pointer ',' args { "$_[1], $_[3]" } +; %% @@ -93,6 +105,15 @@ sub _Lexer { } } +sub _Use($$) +{ + my ($self, $x) = @_; + if (defined($self->YYData->{USE})) { + return $self->YYData->{USE}->($x); + } + return $x; +} + sub _Lookup($$) { my ($self, $x) = @_; @@ -118,11 +139,12 @@ sub _Error($) } sub Run { - my($self, $data, $error, $lookup, $deref) = @_; + my($self, $data, $error, $lookup, $deref, $use) = @_; $self->YYData->{FULL_INPUT} = $data; $self->YYData->{INPUT} = $data; $self->YYData->{LOOKUP} = $lookup; $self->YYData->{DEREFERENCE} = $deref; $self->YYData->{ERROR} = $error; + $self->YYData->{USE} = $use; return $self->YYParse( yylex => \&_Lexer, yyerror => \&_Error); } diff --git a/source4/pidl/lib/Parse/Pidl/Expr.pm b/source4/pidl/lib/Parse/Pidl/Expr.pm index 34c30b824f..f64db508d6 100644 --- a/source4/pidl/lib/Parse/Pidl/Expr.pm +++ b/source4/pidl/lib/Parse/Pidl/Expr.pm @@ -38,7 +38,9 @@ sub new { }, GOTOS => { 'exp' => 2, - 'func' => 11 + 'var' => 11, + 'func' => 12, + 'possible_pointer' => 13 } }, {#State 1 @@ -54,33 +56,33 @@ sub new { 'VAR' => 10 }, GOTOS => { - 'exp' => 12, - 'func' => 11 + 'exp' => 14, + 'var' => 11, + 'func' => 12, + 'possible_pointer' => 13 } }, {#State 2 ACTIONS => { - '' => 14, - "-" => 13, - "<" => 15, - "+" => 16, - "%" => 17, - "==" => 18, - "^" => 19, - "*" => 20, - ">>" => 21, - "!=" => 22, - "?" => 23, - "&&" => 24, - "||" => 25, - "&" => 26, - "/" => 27, - "->" => 28, - "|" => 29, - "<<" => 31, - "=>" => 30, + '' => 16, + "-" => 15, + "<" => 17, + "+" => 18, + "%" => 19, + "==" => 20, + "^" => 21, + "*" => 22, + ">>" => 23, + "!=" => 24, + "?" => 25, + "||" => 26, + "&&" => 27, + "&" => 28, + "/" => 29, + "|" => 30, + "<<" => 32, + "=>" => 31, "<=" => 33, - "." => 32, ">" => 34 } }, @@ -98,7 +100,9 @@ sub new { }, GOTOS => { 'exp' => 35, - 'func' => 11 + 'var' => 11, + 'func' => 12, + 'possible_pointer' => 13 } }, {#State 4 @@ -115,7 +119,9 @@ sub new { }, GOTOS => { 'exp' => 36, - 'func' => 11 + 'var' => 11, + 'func' => 12, + 'possible_pointer' => 13 } }, {#State 5 @@ -137,8 +143,10 @@ sub new { 'VAR' => 10 }, GOTOS => { - 'exp' => 37, - 'func' => 11 + 'exp' => 38, + 'var' => 37, + 'func' => 12, + 'possible_pointer' => 13 } }, {#State 8 @@ -154,46 +162,49 @@ sub new { 'VAR' => 10 }, GOTOS => { - 'exp' => 38, - 'func' => 11 + 'exp' => 39, + 'var' => 11, + 'func' => 12, + 'possible_pointer' => 13 } }, {#State 9 ACTIONS => { - "-" => 1, - "~" => 3, - "&" => 4, - 'TEXT' => 6, - 'NUM' => 5, - "!" => 8, - "(" => 7, "*" => 9, - 'VAR' => 10 + 'VAR' => 41 }, GOTOS => { - 'exp' => 39, - 'func' => 11 + 'possible_pointer' => 40 } }, {#State 10 ACTIONS => { - "(" => 40 + "(" => 42 }, - DEFAULT => -5 + DEFAULT => -30 }, {#State 11 - DEFAULT => -3 + ACTIONS => { + "->" => 43, + "." => 44 + }, + DEFAULT => -4 }, {#State 12 + DEFAULT => -3 + }, + {#State 13 + DEFAULT => -32 + }, + {#State 14 ACTIONS => { - "^" => 19, - "=>" => 30, - "." => 32, + "^" => 21, + "=>" => 31, "<=" => 33 }, - DEFAULT => -29 + DEFAULT => -26 }, - {#State 13 + {#State 15 ACTIONS => { "-" => 1, "~" => 3, @@ -206,14 +217,16 @@ sub new { 'VAR' => 10 }, GOTOS => { - 'exp' => 41, - 'func' => 11 + 'exp' => 45, + 'var' => 11, + 'func' => 12, + 'possible_pointer' => 13 } }, - {#State 14 + {#State 16 DEFAULT => 0 }, - {#State 15 + {#State 17 ACTIONS => { "-" => 1, "~" => 3, @@ -226,11 +239,13 @@ sub new { 'VAR' => 10 }, GOTOS => { - 'exp' => 42, - 'func' => 11 + 'exp' => 46, + 'var' => 11, + 'func' => 12, + 'possible_pointer' => 13 } }, - {#State 16 + {#State 18 ACTIONS => { "-" => 1, "~" => 3, @@ -243,11 +258,13 @@ sub new { 'VAR' => 10 }, GOTOS => { - 'exp' => 43, - 'func' => 11 + 'exp' => 47, + 'var' => 11, + 'func' => 12, + 'possible_pointer' => 13 } }, - {#State 17 + {#State 19 ACTIONS => { "-" => 1, "~" => 3, @@ -260,11 +277,13 @@ sub new { 'VAR' => 10 }, GOTOS => { - 'exp' => 44, - 'func' => 11 + 'exp' => 48, + 'var' => 11, + 'func' => 12, + 'possible_pointer' => 13 } }, - {#State 18 + {#State 20 ACTIONS => { "-" => 1, "~" => 3, @@ -277,11 +296,13 @@ sub new { 'VAR' => 10 }, GOTOS => { - 'exp' => 45, - 'func' => 11 + 'exp' => 49, + 'var' => 11, + 'func' => 12, + 'possible_pointer' => 13 } }, - {#State 19 + {#State 21 ACTIONS => { "-" => 1, "~" => 3, @@ -294,11 +315,13 @@ sub new { 'VAR' => 10 }, GOTOS => { - 'exp' => 46, - 'func' => 11 + 'exp' => 50, + 'var' => 11, + 'func' => 12, + 'possible_pointer' => 13 } }, - {#State 20 + {#State 22 ACTIONS => { "-" => 1, "~" => 3, @@ -311,11 +334,13 @@ sub new { 'VAR' => 10 }, GOTOS => { - 'exp' => 47, - 'func' => 11 + 'exp' => 51, + 'var' => 11, + 'func' => 12, + 'possible_pointer' => 13 } }, - {#State 21 + {#State 23 ACTIONS => { "-" => 1, "~" => 3, @@ -328,11 +353,13 @@ sub new { 'VAR' => 10 }, GOTOS => { - 'exp' => 48, - 'func' => 11 + 'exp' => 52, + 'var' => 11, + 'func' => 12, + 'possible_pointer' => 13 } }, - {#State 22 + {#State 24 ACTIONS => { "-" => 1, "~" => 3, @@ -345,11 +372,13 @@ sub new { 'VAR' => 10 }, GOTOS => { - 'exp' => 49, - 'func' => 11 + 'exp' => 53, + 'var' => 11, + 'func' => 12, + 'possible_pointer' => 13 } }, - {#State 23 + {#State 25 ACTIONS => { "-" => 1, "~" => 3, @@ -362,11 +391,13 @@ sub new { 'VAR' => 10 }, GOTOS => { - 'exp' => 50, - 'func' => 11 + 'exp' => 54, + 'var' => 11, + 'func' => 12, + 'possible_pointer' => 13 } }, - {#State 24 + {#State 26 ACTIONS => { "-" => 1, "~" => 3, @@ -379,11 +410,13 @@ sub new { 'VAR' => 10 }, GOTOS => { - 'exp' => 51, - 'func' => 11 + 'exp' => 55, + 'var' => 11, + 'func' => 12, + 'possible_pointer' => 13 } }, - {#State 25 + {#State 27 ACTIONS => { "-" => 1, "~" => 3, @@ -396,11 +429,13 @@ sub new { 'VAR' => 10 }, GOTOS => { - 'exp' => 52, - 'func' => 11 + 'exp' => 56, + 'var' => 11, + 'func' => 12, + 'possible_pointer' => 13 } }, - {#State 26 + {#State 28 ACTIONS => { "-" => 1, "~" => 3, @@ -413,11 +448,13 @@ sub new { 'VAR' => 10 }, GOTOS => { - 'exp' => 53, - 'func' => 11 + 'exp' => 57, + 'var' => 11, + 'func' => 12, + 'possible_pointer' => 13 } }, - {#State 27 + {#State 29 ACTIONS => { "-" => 1, "~" => 3, @@ -430,16 +467,13 @@ sub new { 'VAR' => 10 }, GOTOS => { - 'exp' => 54, - 'func' => 11 - } - }, - {#State 28 - ACTIONS => { - 'VAR' => 55 + 'exp' => 58, + 'var' => 11, + 'func' => 12, + 'possible_pointer' => 13 } }, - {#State 29 + {#State 30 ACTIONS => { "-" => 1, "~" => 3, @@ -452,11 +486,13 @@ sub new { 'VAR' => 10 }, GOTOS => { - 'exp' => 56, - 'func' => 11 + 'exp' => 59, + 'var' => 11, + 'func' => 12, + 'possible_pointer' => 13 } }, - {#State 30 + {#State 31 ACTIONS => { "-" => 1, "~" => 3, @@ -469,11 +505,13 @@ sub new { 'VAR' => 10 }, GOTOS => { - 'exp' => 57, - 'func' => 11 + 'exp' => 60, + 'var' => 11, + 'func' => 12, + 'possible_pointer' => 13 } }, - {#State 31 + {#State 32 ACTIONS => { "-" => 1, "~" => 3, @@ -486,13 +524,10 @@ sub new { 'VAR' => 10 }, GOTOS => { - 'exp' => 58, - 'func' => 11 - } - }, - {#State 32 - ACTIONS => { - 'VAR' => 59 + 'exp' => 61, + 'var' => 11, + 'func' => 12, + 'possible_pointer' => 13 } }, {#State 33 @@ -508,8 +543,10 @@ sub new { 'VAR' => 10 }, GOTOS => { - 'exp' => 60, - 'func' => 11 + 'exp' => 62, + 'var' => 11, + 'func' => 12, + 'possible_pointer' => 13 } }, {#State 34 @@ -525,89 +562,91 @@ sub new { 'VAR' => 10 }, GOTOS => { - 'exp' => 61, - 'func' => 11 + 'exp' => 63, + 'var' => 11, + 'func' => 12, + 'possible_pointer' => 13 } }, {#State 35 ACTIONS => { - "^" => 19, - "=>" => 30, - "." => 32, + "^" => 21, + "=>" => 31, "<=" => 33 }, - DEFAULT => -7 + DEFAULT => -5 }, {#State 36 ACTIONS => { - "^" => 19, - "=>" => 30, - "." => 32, + "^" => 21, + "=>" => 31, "<=" => 33 }, - DEFAULT => -30 + DEFAULT => -27 }, {#State 37 ACTIONS => { - "-" => 13, - "<" => 15, - "+" => 16, - "%" => 17, - "==" => 18, - "^" => 19, - "*" => 20, - ")" => 62, - ">>" => 21, - "!=" => 22, - "?" => 23, - "&&" => 24, - "||" => 25, - "&" => 26, - "/" => 27, - "->" => 28, - "|" => 29, - "=>" => 30, - "<<" => 31, - "." => 32, - "<=" => 33, - ">" => 34 - } + ")" => 64, + "->" => 43, + "." => 44 + }, + DEFAULT => -4 }, {#State 38 ACTIONS => { - "-" => 13, - "<" => 15, - "+" => 16, - "%" => 17, - "==" => 18, - "^" => 19, - "*" => 20, - ">>" => 21, - "!=" => 22, - "?" => 23, - "&&" => 24, - "||" => 25, - "&" => 26, - "/" => 27, - "|" => 29, - "=>" => 30, - "<<" => 31, - "." => 32, + "-" => 15, + "<" => 17, + "+" => 18, + "%" => 19, + "==" => 20, + "^" => 21, + "*" => 22, + ")" => 65, + ">>" => 23, + "!=" => 24, + "?" => 25, + "&&" => 27, + "||" => 26, + "&" => 28, + "/" => 29, + "|" => 30, + "=>" => 31, + "<<" => 32, "<=" => 33, ">" => 34 - }, - DEFAULT => -27 + } }, {#State 39 ACTIONS => { - "^" => 19, - "=>" => 30, - "." => 32, - "<=" => 33 + "-" => 15, + "<" => 17, + "+" => 18, + "%" => 19, + "==" => 20, + "^" => 21, + "*" => 22, + ">>" => 23, + "!=" => 24, + "?" => 25, + "&&" => 27, + "||" => 26, + "&" => 28, + "/" => 29, + "|" => 30, + "=>" => 31, + "<<" => 32, + "<=" => 33, + ">" => 34 }, - DEFAULT => -6 + DEFAULT => -24 }, {#State 40 + DEFAULT => -31 + }, + {#State 41 + DEFAULT => -30 + }, + {#State 42 ACTIONS => { "-" => 1, "~" => 3, @@ -619,411 +658,410 @@ sub new { "*" => 9, 'VAR' => 10 }, - DEFAULT => -34, + DEFAULT => -37, GOTOS => { - 'exp' => 64, - 'args' => 63, - 'func' => 11, - 'opt_args' => 65 + 'exp' => 69, + 'var' => 11, + 'args' => 66, + 'func' => 12, + 'opt_args' => 70, + 'exp_or_possible_pointer' => 67, + 'possible_pointer' => 68 } }, - {#State 41 + {#State 43 + ACTIONS => { + 'VAR' => 71 + } + }, + {#State 44 ACTIONS => { - "<" => 15, - "==" => 18, - "^" => 19, - ">>" => 21, - "!=" => 22, - "?" => 23, - "&&" => 24, - "||" => 25, - "&" => 26, - "|" => 29, - "=>" => 30, - "<<" => 31, - "." => 32, + 'VAR' => 72 + } + }, + {#State 45 + ACTIONS => { + "<" => 17, + "==" => 20, + "^" => 21, + ">>" => 23, + "!=" => 24, + "?" => 25, + "&&" => 27, + "||" => 26, + "&" => 28, + "|" => 30, + "=>" => 31, + "<<" => 32, "<=" => 33, ">" => 34 }, - DEFAULT => -9 + DEFAULT => -7 }, - {#State 42 + {#State 46 ACTIONS => { - "==" => 18, - "^" => 19, - "!=" => 22, - "?" => 23, - "&&" => 24, - "||" => 25, - "&" => 26, - "|" => 29, - "=>" => 30, - "." => 32, + "==" => 20, + "^" => 21, + "!=" => 24, + "?" => 25, + "&&" => 27, + "||" => 26, + "&" => 28, + "|" => 30, + "=>" => 31, "<=" => 33 }, - DEFAULT => -12 + DEFAULT => -10 }, - {#State 43 + {#State 47 ACTIONS => { - "<" => 15, - "==" => 18, - "^" => 19, - ">>" => 21, - "!=" => 22, - "?" => 23, - "&&" => 24, - "||" => 25, - "&" => 26, - "|" => 29, - "=>" => 30, - "<<" => 31, - "." => 32, + "<" => 17, + "==" => 20, + "^" => 21, + ">>" => 23, + "!=" => 24, + "?" => 25, + "&&" => 27, + "||" => 26, + "&" => 28, + "|" => 30, + "=>" => 31, + "<<" => 32, "<=" => 33, ">" => 34 }, - DEFAULT => -8 + DEFAULT => -6 }, - {#State 44 + {#State 48 ACTIONS => { - "-" => 13, - "<" => 15, - "+" => 16, - "==" => 18, - "^" => 19, - ">>" => 21, - "!=" => 22, - "?" => 23, - "&&" => 24, - "||" => 25, - "&" => 26, - "|" => 29, - "=>" => 30, - "<<" => 31, - "." => 32, + "-" => 15, + "<" => 17, + "+" => 18, + "==" => 20, + "^" => 21, + ">>" => 23, + "!=" => 24, + "?" => 25, + "&&" => 27, + "||" => 26, + "&" => 28, + "|" => 30, + "=>" => 31, + "<<" => 32, "<=" => 33, ">" => 34 }, - DEFAULT => -11 + DEFAULT => -9 }, - {#State 45 + {#State 49 ACTIONS => { - "^" => 19, - "?" => 23, - "&&" => 24, - "||" => 25, - "&" => 26, - "|" => 29, - "=>" => 30, - "." => 32, + "^" => 21, + "?" => 25, + "&&" => 27, + "||" => 26, + "&" => 28, + "|" => 30, + "=>" => 31, "<=" => 33 }, - DEFAULT => -15 + DEFAULT => -13 }, - {#State 46 + {#State 50 ACTIONS => { - "-" => 13, - "<" => 15, - "+" => 16, - "%" => 17, - "==" => 18, - "^" => 19, - "*" => 20, - ">>" => 21, - "!=" => 22, - "?" => 23, - "&&" => 24, - "||" => 25, - "&" => 26, - "/" => 27, - "->" => 28, - "|" => 29, - "=>" => 30, - "<<" => 31, - "." => 32, + "-" => 15, + "<" => 17, + "+" => 18, + "%" => 19, + "==" => 20, + "^" => 21, + "*" => 22, + ">>" => 23, + "!=" => 24, + "?" => 25, + "&&" => 27, + "||" => 26, + "&" => 28, + "/" => 29, + "|" => 30, + "=>" => 31, + "<<" => 32, "<=" => 33, ">" => 34 }, - DEFAULT => -31 + DEFAULT => -28 }, - {#State 47 + {#State 51 ACTIONS => { - "-" => 13, - "<" => 15, - "+" => 16, - "==" => 18, - "^" => 19, - ">>" => 21, - "!=" => 22, - "?" => 23, - "&&" => 24, - "||" => 25, - "&" => 26, - "|" => 29, - "=>" => 30, - "<<" => 31, - "." => 32, + "-" => 15, + "<" => 17, + "+" => 18, + "==" => 20, + "^" => 21, + ">>" => 23, + "!=" => 24, + "?" => 25, + "&&" => 27, + "||" => 26, + "&" => 28, + "|" => 30, + "=>" => 31, + "<<" => 32, "<=" => 33, ">" => 34 }, - DEFAULT => -10 + DEFAULT => -8 }, - {#State 48 + {#State 52 ACTIONS => { - "<" => 15, - "==" => 18, - "^" => 19, - "!=" => 22, - "?" => 23, - "&&" => 24, - "||" => 25, - "&" => 26, - "|" => 29, - "=>" => 30, - "." => 32, + "<" => 17, + "==" => 20, + "^" => 21, + "!=" => 24, + "?" => 25, + "&&" => 27, + "||" => 26, + "&" => 28, + "|" => 30, + "=>" => 31, "<=" => 33, ">" => 34 }, - DEFAULT => -19 + DEFAULT => -17 }, - {#State 49 + {#State 53 ACTIONS => { - "^" => 19, - "?" => 23, - "&&" => 24, - "||" => 25, - "&" => 26, - "|" => 29, - "=>" => 30, - "." => 32, + "^" => 21, + "?" => 25, + "&&" => 27, + "||" => 26, + "&" => 28, + "|" => 30, + "=>" => 31, "<=" => 33 }, - DEFAULT => -20 + DEFAULT => -18 }, - {#State 50 + {#State 54 ACTIONS => { - ":" => 66, - "-" => 13, - "<" => 15, - "+" => 16, - "%" => 17, - "==" => 18, - "^" => 19, - "*" => 20, - ">>" => 21, - "!=" => 22, - "?" => 23, - "&&" => 24, - "||" => 25, - "&" => 26, - "/" => 27, - "->" => 28, - "|" => 29, - "=>" => 30, - "<<" => 31, - "." => 32, + ":" => 73, + "-" => 15, + "<" => 17, + "+" => 18, + "%" => 19, + "==" => 20, + "^" => 21, + "*" => 22, + ">>" => 23, + "!=" => 24, + "?" => 25, + "&&" => 27, + "||" => 26, + "&" => 28, + "/" => 29, + "|" => 30, + "=>" => 31, + "<<" => 32, "<=" => 33, ">" => 34 } }, - {#State 51 + {#State 55 ACTIONS => { - "^" => 19, - "?" => 23, - "||" => 25, - "=>" => 30, - "." => 32, + "^" => 21, + "?" => 25, + "=>" => 31, "<=" => 33 }, - DEFAULT => -22 + DEFAULT => -19 }, - {#State 52 + {#State 56 ACTIONS => { - "^" => 19, - "?" => 23, - "=>" => 30, - "." => 32, + "^" => 21, + "?" => 25, + "||" => 26, + "=>" => 31, "<=" => 33 }, - DEFAULT => -21 + DEFAULT => -20 }, - {#State 53 + {#State 57 ACTIONS => { - "^" => 19, - "?" => 23, - "&&" => 24, - "||" => 25, - "|" => 29, - "=>" => 30, - "." => 32, + "^" => 21, + "?" => 25, + "&&" => 27, + "||" => 26, + "|" => 30, + "=>" => 31, "<=" => 33 }, - DEFAULT => -23 + DEFAULT => -21 }, - {#State 54 + {#State 58 ACTIONS => { - "-" => 13, - "<" => 15, - "+" => 16, - "==" => 18, - "^" => 19, - ">>" => 21, - "!=" => 22, - "?" => 23, - "&&" => 24, - "||" => 25, - "&" => 26, - "|" => 29, - "=>" => 30, - "<<" => 31, - "." => 32, + "-" => 15, + "<" => 17, + "+" => 18, + "==" => 20, + "^" => 21, + ">>" => 23, + "!=" => 24, + "?" => 25, + "&&" => 27, + "||" => 26, + "&" => 28, + "|" => 30, + "=>" => 31, + "<<" => 32, "<=" => 33, ">" => 34 }, - DEFAULT => -28 - }, - {#State 55 - DEFAULT => -24 + DEFAULT => -25 }, - {#State 56 + {#State 59 ACTIONS => { - "^" => 19, - "?" => 23, - "&&" => 24, - "||" => 25, - "=>" => 30, - "." => 32, + "^" => 21, + "?" => 25, + "&&" => 27, + "||" => 26, + "=>" => 31, "<=" => 33 }, - DEFAULT => -14 + DEFAULT => -12 }, - {#State 57 + {#State 60 ACTIONS => { - "-" => 13, - "<" => 15, - "+" => 16, - "%" => 17, - "==" => 18, - "^" => 19, - "*" => 20, - ">>" => 21, - "!=" => 22, - "?" => 23, - "&&" => 24, - "||" => 25, - "&" => 26, - "/" => 27, - "->" => 28, - "|" => 29, - "=>" => 30, - "<<" => 31, - "." => 32, + "-" => 15, + "<" => 17, + "+" => 18, + "%" => 19, + "==" => 20, + "^" => 21, + "*" => 22, + ">>" => 23, + "!=" => 24, + "?" => 25, + "&&" => 27, + "||" => 26, + "&" => 28, + "/" => 29, + "|" => 30, + "=>" => 31, + "<<" => 32, "<=" => 33, ">" => 34 }, - DEFAULT => -17 + DEFAULT => -15 }, - {#State 58 + {#State 61 ACTIONS => { - "<" => 15, - "==" => 18, - "^" => 19, - "!=" => 22, - "?" => 23, - "&&" => 24, - "||" => 25, - "&" => 26, - "|" => 29, - "=>" => 30, - "." => 32, + "<" => 17, + "==" => 20, + "^" => 21, + "!=" => 24, + "?" => 25, + "&&" => 27, + "||" => 26, + "&" => 28, + "|" => 30, + "=>" => 31, "<=" => 33, ">" => 34 }, - DEFAULT => -18 - }, - {#State 59 - DEFAULT => -4 + DEFAULT => -16 }, - {#State 60 + {#State 62 ACTIONS => { - "-" => 13, - "<" => 15, - "+" => 16, - "%" => 17, - "==" => 18, - "^" => 19, - "*" => 20, - ">>" => 21, - "!=" => 22, - "?" => 23, - "&&" => 24, - "||" => 25, - "&" => 26, - "/" => 27, - "->" => 28, - "|" => 29, - "=>" => 30, - "<<" => 31, - "." => 32, + "-" => 15, + "<" => 17, + "+" => 18, + "%" => 19, + "==" => 20, + "^" => 21, + "*" => 22, + ">>" => 23, + "!=" => 24, + "?" => 25, + "&&" => 27, + "||" => 26, + "&" => 28, + "/" => 29, + "|" => 30, + "=>" => 31, + "<<" => 32, "<=" => 33, ">" => 34 }, - DEFAULT => -16 + DEFAULT => -14 }, - {#State 61 + {#State 63 ACTIONS => { - "==" => 18, - "^" => 19, - "!=" => 22, - "?" => 23, - "&&" => 24, - "||" => 25, - "&" => 26, - "|" => 29, - "=>" => 30, - "." => 32, + "==" => 20, + "^" => 21, + "!=" => 24, + "?" => 25, + "&&" => 27, + "||" => 26, + "&" => 28, + "|" => 30, + "=>" => 31, "<=" => 33 }, - DEFAULT => -13 + DEFAULT => -11 }, - {#State 62 - DEFAULT => -32 + {#State 64 + DEFAULT => -34 }, - {#State 63 - DEFAULT => -35 + {#State 65 + DEFAULT => -29 }, - {#State 64 + {#State 66 + DEFAULT => -38 + }, + {#State 67 + ACTIONS => { + "," => 74 + }, + DEFAULT => -41 + }, + {#State 68 + DEFAULT => -32 + }, + {#State 69 ACTIONS => { - "-" => 13, - "<" => 15, - "+" => 16, - "%" => 17, - "," => 67, - "==" => 18, - "^" => 19, - "*" => 20, - ">>" => 21, - "!=" => 22, - "?" => 23, - "&&" => 24, - "||" => 25, - "&" => 26, - "->" => 28, - "/" => 27, - "|" => 29, - "=>" => 30, - "<<" => 31, - "." => 32, + "-" => 15, + "<" => 17, + "+" => 18, + "%" => 19, + "==" => 20, + "^" => 21, + "*" => 22, + ">>" => 23, + "!=" => 24, + "?" => 25, + "&&" => 27, + "||" => 26, + "&" => 28, + "/" => 29, + "|" => 30, + "=>" => 31, + "<<" => 32, "<=" => 33, ">" => 34 }, - DEFAULT => -36 + DEFAULT => -39 }, - {#State 65 + {#State 70 ACTIONS => { - ")" => 68 + ")" => 75 } }, - {#State 66 + {#State 71 + DEFAULT => -35 + }, + {#State 72 + DEFAULT => -33 + }, + {#State 73 ACTIONS => { "-" => 1, "~" => 3, @@ -1036,11 +1074,13 @@ sub new { 'VAR' => 10 }, GOTOS => { - 'exp' => 69, - 'func' => 11 + 'exp' => 76, + 'var' => 11, + 'func' => 12, + 'possible_pointer' => 13 } }, - {#State 67 + {#State 74 ACTIONS => { "-" => 1, "~" => 3, @@ -1053,25 +1093,27 @@ sub new { 'VAR' => 10 }, GOTOS => { - 'exp' => 64, - 'args' => 70, - 'func' => 11 + 'exp' => 69, + 'var' => 11, + 'args' => 77, + 'func' => 12, + 'exp_or_possible_pointer' => 67, + 'possible_pointer' => 68 } }, - {#State 68 - DEFAULT => -33 + {#State 75 + DEFAULT => -36 }, - {#State 69 + {#State 76 ACTIONS => { - "^" => 19, - "=>" => 30, - "." => 32, + "^" => 21, + "=>" => 31, "<=" => 33 }, - DEFAULT => -25 + DEFAULT => -22 }, - {#State 70 - DEFAULT => -37 + {#State 77 + DEFAULT => -42 } ], yyrules => @@ -1085,208 +1127,229 @@ sub new { [#Rule 2 'exp', 1, sub -#line 22 "pidl/expr.yp" +#line 22 "expr.yp" { "\"$_[1]\"" } ], [#Rule 3 'exp', 1, undef ], [#Rule 4 - 'exp', 3, -sub -#line 24 "pidl/expr.yp" -{ "$_[1].$_[3]" } + 'exp', 1, undef ], [#Rule 5 - 'exp', 1, -sub -#line 25 "pidl/expr.yp" -{ $_[0]->_Lookup($_[1]) } - ], - [#Rule 6 - 'exp', 2, -sub -#line 26 "pidl/expr.yp" -{ $_[0]->_Dereference($_[2]); "*$_[2]" } - ], - [#Rule 7 'exp', 2, sub -#line 27 "pidl/expr.yp" +#line 25 "expr.yp" { "~$_[2]" } ], - [#Rule 8 + [#Rule 6 'exp', 3, sub -#line 28 "pidl/expr.yp" +#line 26 "expr.yp" { "$_[1] + $_[3]" } ], - [#Rule 9 + [#Rule 7 'exp', 3, sub -#line 29 "pidl/expr.yp" +#line 27 "expr.yp" { "$_[1] - $_[3]" } ], - [#Rule 10 + [#Rule 8 'exp', 3, sub -#line 30 "pidl/expr.yp" +#line 28 "expr.yp" { "$_[1] * $_[3]" } ], - [#Rule 11 + [#Rule 9 'exp', 3, sub -#line 31 "pidl/expr.yp" +#line 29 "expr.yp" { "$_[1] % $_[3]" } ], - [#Rule 12 + [#Rule 10 'exp', 3, sub -#line 32 "pidl/expr.yp" +#line 30 "expr.yp" { "$_[1] < $_[3]" } ], - [#Rule 13 + [#Rule 11 'exp', 3, sub -#line 33 "pidl/expr.yp" +#line 31 "expr.yp" { "$_[1] > $_[3]" } ], - [#Rule 14 + [#Rule 12 'exp', 3, sub -#line 34 "pidl/expr.yp" +#line 32 "expr.yp" { "$_[1] | $_[3]" } ], - [#Rule 15 + [#Rule 13 'exp', 3, sub -#line 35 "pidl/expr.yp" +#line 33 "expr.yp" { "$_[1] == $_[3]" } ], - [#Rule 16 + [#Rule 14 'exp', 3, sub -#line 36 "pidl/expr.yp" +#line 34 "expr.yp" { "$_[1] <= $_[3]" } ], - [#Rule 17 + [#Rule 15 'exp', 3, sub -#line 37 "pidl/expr.yp" +#line 35 "expr.yp" { "$_[1] => $_[3]" } ], - [#Rule 18 + [#Rule 16 'exp', 3, sub -#line 38 "pidl/expr.yp" +#line 36 "expr.yp" { "$_[1] << $_[3]" } ], - [#Rule 19 + [#Rule 17 'exp', 3, sub -#line 39 "pidl/expr.yp" +#line 37 "expr.yp" { "$_[1] >> $_[3]" } ], - [#Rule 20 + [#Rule 18 'exp', 3, sub -#line 40 "pidl/expr.yp" +#line 38 "expr.yp" { "$_[1] != $_[3]" } ], - [#Rule 21 + [#Rule 19 'exp', 3, sub -#line 41 "pidl/expr.yp" +#line 39 "expr.yp" { "$_[1] || $_[3]" } ], - [#Rule 22 + [#Rule 20 'exp', 3, sub -#line 42 "pidl/expr.yp" +#line 40 "expr.yp" { "$_[1] && $_[3]" } ], - [#Rule 23 + [#Rule 21 'exp', 3, sub -#line 43 "pidl/expr.yp" +#line 41 "expr.yp" { "$_[1] & $_[3]" } ], - [#Rule 24 - 'exp', 3, -sub -#line 44 "pidl/expr.yp" -{ $_[1]."->".$_[3] } - ], - [#Rule 25 + [#Rule 22 'exp', 5, sub -#line 45 "pidl/expr.yp" +#line 42 "expr.yp" { "$_[1]?$_[3]:$_[5]" } ], - [#Rule 26 + [#Rule 23 'exp', 2, sub -#line 46 "pidl/expr.yp" +#line 43 "expr.yp" { "~$_[1]" } ], - [#Rule 27 + [#Rule 24 'exp', 2, sub -#line 47 "pidl/expr.yp" +#line 44 "expr.yp" { "not $_[1]" } ], - [#Rule 28 + [#Rule 25 'exp', 3, sub -#line 48 "pidl/expr.yp" +#line 45 "expr.yp" { "$_[1] / $_[3]" } ], - [#Rule 29 + [#Rule 26 'exp', 2, sub -#line 49 "pidl/expr.yp" +#line 46 "expr.yp" { "-$_[2]" } ], - [#Rule 30 + [#Rule 27 'exp', 2, sub -#line 50 "pidl/expr.yp" +#line 47 "expr.yp" { "&$_[2]" } ], - [#Rule 31 + [#Rule 28 'exp', 3, sub -#line 51 "pidl/expr.yp" +#line 48 "expr.yp" { "$_[1]^$_[3]" } ], - [#Rule 32 + [#Rule 29 'exp', 3, sub -#line 52 "pidl/expr.yp" +#line 49 "expr.yp" { "($_[2])" } ], + [#Rule 30 + 'possible_pointer', 1, +sub +#line 53 "expr.yp" +{ $_[0]->_Lookup($_[1]) } + ], + [#Rule 31 + 'possible_pointer', 2, +sub +#line 54 "expr.yp" +{ $_[0]->_Dereference($_[2]); "*$_[2]" } + ], + [#Rule 32 + 'var', 1, +sub +#line 57 "expr.yp" +{ $_[0]->_Use($_[1]) } + ], [#Rule 33 + 'var', 3, +sub +#line 58 "expr.yp" +{ $_[0]->_Use("$_[1].$_[3]") } + ], + [#Rule 34 + 'var', 3, +sub +#line 59 "expr.yp" +{ "($_[2])" } + ], + [#Rule 35 + 'var', 3, +sub +#line 60 "expr.yp" +{ $_[0]->_Use("*$_[1]"); $_[1]."->".$_[3] } + ], + [#Rule 36 'func', 4, sub -#line 55 "pidl/expr.yp" +#line 64 "expr.yp" { "$_[1]($_[3])" } ], - [#Rule 34 + [#Rule 37 'opt_args', 0, sub -#line 56 "pidl/expr.yp" +#line 65 "expr.yp" { "" } ], - [#Rule 35 + [#Rule 38 'opt_args', 1, undef ], - [#Rule 36 + [#Rule 39 + 'exp_or_possible_pointer', 1, undef + ], + [#Rule 40 + 'exp_or_possible_pointer', 1, undef + ], + [#Rule 41 'args', 1, undef ], - [#Rule 37 + [#Rule 42 'args', 3, sub -#line 57 "pidl/expr.yp" +#line 68 "expr.yp" { "$_[1], $_[3]" } ] ], @@ -1294,7 +1357,7 @@ sub bless($self,$class); } -#line 59 "pidl/expr.yp" +#line 71 "expr.yp" package Parse::Pidl::Expr; @@ -1332,6 +1395,15 @@ sub _Lexer { } } +sub _Use($$) +{ + my ($self, $x) = @_; + if (defined($self->YYData->{USE})) { + return $self->YYData->{USE}->($x); + } + return $x; +} + sub _Lookup($$) { my ($self, $x) = @_; @@ -1357,12 +1429,13 @@ sub _Error($) } sub Run { - my($self, $data, $error, $lookup, $deref) = @_; + my($self, $data, $error, $lookup, $deref, $use) = @_; $self->YYData->{FULL_INPUT} = $data; $self->YYData->{INPUT} = $data; $self->YYData->{LOOKUP} = $lookup; $self->YYData->{DEREFERENCE} = $deref; $self->YYData->{ERROR} = $error; + $self->YYData->{USE} = $use; return $self->YYParse( yylex => \&_Lexer, yyerror => \&_Error); } diff --git a/source4/pidl/lib/Parse/Pidl/NDR.pm b/source4/pidl/lib/Parse/Pidl/NDR.pm index 462e577cdd..2ba8461e4a 100644 --- a/source4/pidl/lib/Parse/Pidl/NDR.pm +++ b/source4/pidl/lib/Parse/Pidl/NDR.pm @@ -35,7 +35,7 @@ use vars qw($VERSION); $VERSION = '0.01'; @ISA = qw(Exporter); @EXPORT = qw(GetPrevLevel GetNextLevel ContainsDeferred ContainsString); -@EXPORT_OK = qw(GetElementLevelTable ParseElement); +@EXPORT_OK = qw(GetElementLevelTable ParseElement ValidElement); use strict; use Parse::Pidl qw(warning fatal); @@ -902,7 +902,6 @@ sub ValidElement($) } } - if (has_property($e, "subcontext") and has_property($e, "represent_as")) { fatal($e, el_name($e) . " : subcontext() and represent_as() can not be used on the same element"); } @@ -919,6 +918,10 @@ sub ValidElement($) fatal($e, el_name($e) . " : represent_as() and value() can not be used on the same element"); } + if (has_property($e, "subcontext")) { + warning($e, "subcontext() is deprecated. Use represent_as() or transmit_as() instead"); + } + if (defined (has_property($e, "subcontext_size")) and not defined(has_property($e, "subcontext"))) { fatal($e, el_name($e) . " : subcontext_size() on non-subcontext element"); } diff --git a/source4/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm b/source4/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm index a1bd3e1f96..1e199ba62b 100644 --- a/source4/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm +++ b/source4/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm @@ -304,6 +304,51 @@ sub ParseArrayPushHeader($$$$$) return $length; } +sub check_fully_dereferenced($$) +{ + my ($element, $env) = @_; + + return sub ($) { + my $origvar = shift; + my $check = 0; + + # Figure out the number of pointers in $ptr + my $expandedvar = $origvar; + $expandedvar =~ s/^(\**)//; + my $ptr = $1; + + my $var = undef; + foreach (keys %$env) { + if ($env->{$_} eq $expandedvar) { + $var = $_; + last; + } + } + + return($origvar) unless (defined($var)); + my $e; + foreach (@{$element->{PARENT}->{ELEMENTS}}) { + if ($_->{NAME} eq $var) { + $e = $_; + last; + } + } + + $e or die("Environment doesn't match siblings"); + + # See if pointer at pointer level $level + # needs to be checked. + my $nump = 0; + foreach (@{$e->{LEVELS}}) { + if ($_->{TYPE} eq "POINTER") { + $nump = $_->{POINTER_INDEX}+1; + } + } + warning($element->{ORIGINAL}, "Got pointer for `$e->{NAME}', expected fully derefenced variable") if ($nump > length($ptr)); + return ($origvar); + } +} + sub check_null_pointer($$$$) { my ($element, $env, $print_fn, $return) = @_; @@ -373,8 +418,8 @@ sub ParseArrayPullHeader($$$$$) } elsif ($l->{IS_ZERO_TERMINATED}) { # Noheader arrays $length = $size = "ndr_get_string_size($ndr, sizeof(*$var_name))"; } else { - $length = $size = ParseExprExt($l->{SIZE_IS}, $env, $e, - check_null_pointer($e, $env, \&pidl, "return NT_STATUS_INVALID_PARAMETER_MIX;")); + $length = $size = ParseExprExt($l->{SIZE_IS}, $env, $e->{ORIGINAL}, + check_null_pointer($e, $env, \&pidl, "return NT_STATUS_INVALID_PARAMETER_MIX;"), check_fully_dereferenced($e, $env)); } if ((!$l->{IS_SURROUNDING}) and $l->{IS_CONFORMANT}) { @@ -397,7 +442,7 @@ sub ParseArrayPullHeader($$$$$) if ($l->{IS_CONFORMANT} and not $l->{IS_ZERO_TERMINATED}) { defer "if ($var_name) {"; defer_indent; - my $size = ParseExprExt($l->{SIZE_IS}, $env, $e, check_null_pointer($e, $env, \&defer, "return NT_STATUS_INVALID_PARAMETER_MIX;")); + my $size = ParseExprExt($l->{SIZE_IS}, $env, $e->{ORIGINAL}, check_null_pointer($e, $env, \&defer, "return NT_STATUS_INVALID_PARAMETER_MIX;"), check_fully_dereferenced($e, $env)); defer "NDR_CHECK(ndr_check_array_size(ndr, (void*)" . get_pointer_to($var_name) . ", $size));"; defer_deindent; defer "}"; @@ -406,7 +451,7 @@ sub ParseArrayPullHeader($$$$$) if ($l->{IS_VARYING} and not $l->{IS_ZERO_TERMINATED}) { defer "if ($var_name) {"; defer_indent; - my $length = ParseExprExt($l->{LENGTH_IS}, $env, $e, check_null_pointer($e, $env, \&defer, "return NT_STATUS_INVALID_PARAMETER_MIX;")); + my $length = ParseExprExt($l->{LENGTH_IS}, $env, $e->{ORIGINAL}, check_null_pointer($e, $env, \&defer, "return NT_STATUS_INVALID_PARAMETER_MIX;"), check_fully_dereferenced($e, $env)); defer "NDR_CHECK(ndr_check_array_length(ndr, (void*)" . get_pointer_to($var_name) . ", $length));"; defer_deindent; defer "}" @@ -432,7 +477,7 @@ sub compression_clen($$$) my ($e, $l, $env) = @_; my ($alg, $clen, $dlen) = split(/ /, $l->{COMPRESSION}); - return ParseExpr($clen, $env, $e); + return ParseExpr($clen, $env, $e->{ORIGINAL}); } sub compression_dlen($$$) @@ -440,7 +485,7 @@ sub compression_dlen($$$) my ($e,$l,$env) = @_; my ($alg, $clen, $dlen) = split(/ /, $l->{COMPRESSION}); - return ParseExpr($dlen, $env, $e); + return ParseExpr($dlen, $env, $e->{ORIGINAL}); } sub ParseCompressionPushStart($$$$) @@ -501,7 +546,7 @@ sub ParseSubcontextPushStart($$$$) { my ($e,$l,$ndr,$env) = @_; my $subndr = "_ndr_$e->{NAME}"; - my $subcontext_size = ParseExpr($l->{SUBCONTEXT_SIZE}, $env, $e); + my $subcontext_size = ParseExpr($l->{SUBCONTEXT_SIZE}, $env, $e->{ORIGINAL}); pidl "{"; indent; @@ -519,7 +564,7 @@ sub ParseSubcontextPushEnd($$$$) { my ($e,$l,$ndr,$env) = @_; my $subndr = "_ndr_$e->{NAME}"; - my $subcontext_size = ParseExpr($l->{SUBCONTEXT_SIZE}, $env, $e); + my $subcontext_size = ParseExpr($l->{SUBCONTEXT_SIZE}, $env, $e->{ORIGINAL}); if (defined $l->{COMPRESSION}) { ParseCompressionPushEnd($e, $l, $subndr, $env); @@ -534,7 +579,7 @@ sub ParseSubcontextPullStart($$$$) { my ($e,$l,$ndr,$env) = @_; my $subndr = "_ndr_$e->{NAME}"; - my $subcontext_size = ParseExpr($l->{SUBCONTEXT_SIZE}, $env, $e); + my $subcontext_size = ParseExpr($l->{SUBCONTEXT_SIZE}, $env, $e->{ORIGINAL}); pidl "{"; indent; @@ -552,7 +597,7 @@ sub ParseSubcontextPullEnd($$$$) { my ($e,$l,$ndr,$env) = @_; my $subndr = "_ndr_$e->{NAME}"; - my $subcontext_size = ParseExpr($l->{SUBCONTEXT_SIZE}, $env, $e); + my $subcontext_size = ParseExpr($l->{SUBCONTEXT_SIZE}, $env, $e->{ORIGINAL}); if (defined $l->{COMPRESSION}) { ParseCompressionPullEnd($e, $l, $subndr, $env); @@ -617,7 +662,7 @@ sub ParseElementPushLevel } } elsif ($l->{TYPE} eq "ARRAY" and not has_fast_array($e,$l) and not is_charset_array($e, $l)) { - my $length = ParseExpr($l->{LENGTH_IS}, $env, $e); + my $length = ParseExpr($l->{LENGTH_IS}, $env, $e->{ORIGINAL}); my $counter = "cntr_$e->{NAME}_$l->{LEVEL_INDEX}"; $var_name = $var_name . "[$counter]"; @@ -668,7 +713,7 @@ sub ParseElementPush($$$$$$) start_flags($e); if (my $value = has_property($e, "value")) { - $var_name = ParseExpr($value, $env, $e); + $var_name = ParseExpr($value, $env, $e->{ORIGINAL}); } ParseElementPushLevel($e, $e->{LEVELS}[0], $ndr, $var_name, $env, $primitives, $deferred); @@ -719,7 +764,7 @@ sub ParseElementPrint($$$) $var_name = append_prefix($e, $var_name); if (my $value = has_property($e, "value")) { - $var_name = "(ndr->flags & LIBNDR_PRINT_SET_VALUES)?" . ParseExpr($value,$env, $e) . ":$var_name"; + $var_name = "(ndr->flags & LIBNDR_PRINT_SET_VALUES)?" . ParseExpr($value,$env, $e->{ORIGINAL}) . ":$var_name"; } foreach my $l (@{$e->{LEVELS}}) { @@ -741,8 +786,8 @@ sub ParseElementPrint($$$) if ($l->{IS_ZERO_TERMINATED}) { $length = "ndr_string_length($var_name, sizeof(*$var_name))"; } else { - $length = ParseExprExt($l->{LENGTH_IS}, $env, $e, - check_null_pointer($e, $env, \&pidl, "return;")); + $length = ParseExprExt($l->{LENGTH_IS}, $env, $e->{ORIGINAL}, + check_null_pointer($e, $env, \&pidl, "return;"), check_fully_dereferenced($e, $env)); } if (is_charset_array($e,$l)) { @@ -772,8 +817,8 @@ sub ParseElementPrint($$$) } pidl "ndr_print_$l->{DATA_TYPE}(ndr, \"$e->{NAME}\", $var_name);"; } elsif ($l->{TYPE} eq "SWITCH") { - my $switch_var = ParseExprExt($l->{SWITCH_IS}, $env, $e, - check_null_pointer($e, $env, \&pidl, "return;")); + my $switch_var = ParseExprExt($l->{SWITCH_IS}, $env, $e->{ORIGINAL}, + check_null_pointer($e, $env, \&pidl, "return;"), check_fully_dereferenced($e, $env)); pidl "ndr_print_set_switch_value(ndr, " . get_pointer_to($var_name) . ", $switch_var);"; } } @@ -803,8 +848,8 @@ sub ParseElementPrint($$$) sub ParseSwitchPull($$$$$$) { my($e,$l,$ndr,$var_name,$ndr_flags,$env) = @_; - my $switch_var = ParseExprExt($l->{SWITCH_IS}, $env, $e, - check_null_pointer($e, $env, \&pidl, "return NT_STATUS_INVALID_PARAMETER_MIX;")); + my $switch_var = ParseExprExt($l->{SWITCH_IS}, $env, $e->{ORIGINAL}, + check_null_pointer($e, $env, \&pidl, "return NT_STATUS_INVALID_PARAMETER_MIX;"), check_fully_dereferenced($e, $env)); $var_name = get_pointer_to($var_name); pidl "NDR_CHECK(ndr_pull_set_switch_value($ndr, $var_name, $switch_var));"; @@ -815,8 +860,8 @@ sub ParseSwitchPull($$$$$$) sub ParseSwitchPush($$$$$$) { my($e,$l,$ndr,$var_name,$ndr_flags,$env) = @_; - my $switch_var = ParseExprExt($l->{SWITCH_IS}, $env, $e, - check_null_pointer($e, $env, \&pidl, "return NT_STATUS_INVALID_PARAMETER_MIX;")); + my $switch_var = ParseExprExt($l->{SWITCH_IS}, $env, $e->{ORIGINAL}, + check_null_pointer($e, $env, \&pidl, "return NT_STATUS_INVALID_PARAMETER_MIX;"), check_fully_dereferenced($e, $env)); $var_name = get_pointer_to($var_name); pidl "NDR_CHECK(ndr_push_set_switch_value($ndr, $var_name, $switch_var));"; @@ -1012,7 +1057,7 @@ sub ParseElementPullLevel } } elsif ($l->{TYPE} eq "ARRAY" and not has_fast_array($e,$l) and not is_charset_array($e, $l)) { - my $length = ParseExpr($l->{LENGTH_IS}, $env, $e); + my $length = ParseExpr($l->{LENGTH_IS}, $env, $e->{ORIGINAL}); my $counter = "cntr_$e->{NAME}_$l->{LEVEL_INDEX}"; my $array_name = $var_name; @@ -1181,7 +1226,7 @@ sub ParseStructPush($$) $size = "ndr_string_length(r->$e->{NAME}, sizeof(*r->$e->{NAME}))"; } } else { - $size = ParseExpr($e->{LEVELS}[0]->{SIZE_IS}, $env, $e); + $size = ParseExpr($e->{LEVELS}[0]->{SIZE_IS}, $env, $e->{ORIGINAL}); } pidl "NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, $size));"; @@ -2038,7 +2083,7 @@ sub AllocateArrayLevel($$$$$) { my ($e,$l,$ndr,$env,$size) = @_; - my $var = ParseExpr($e->{NAME}, $env, $e); + my $var = ParseExpr($e->{NAME}, $env, $e->{ORIGINAL}); my $pl = GetPrevLevel($e, $l); if (defined($pl) and @@ -2118,7 +2163,8 @@ sub ParseFunctionPull($) and $e->{LEVELS}[1]->{IS_ZERO_TERMINATED}); if ($e->{LEVELS}[1]->{TYPE} eq "ARRAY") { - my $size = ParseExprExt($e->{LEVELS}[1]->{SIZE_IS}, $env, $e, check_null_pointer($e, $env, \&pidl, "return NT_STATUS_INVALID_PARAMETER_MIX;")); + my $size = ParseExprExt($e->{LEVELS}[1]->{SIZE_IS}, $env, $e->{ORIGINAL}, check_null_pointer($e, $env, \&pidl, "return NT_STATUS_INVALID_PARAMETER_MIX;"), + check_fully_dereferenced($e, $env)); pidl "NDR_PULL_ALLOC_N(ndr, r->out.$e->{NAME}, $size);"; diff --git a/source4/pidl/lib/Parse/Pidl/Util.pm b/source4/pidl/lib/Parse/Pidl/Util.pm index 3ca79b6c1c..00185fbef7 100644 --- a/source4/pidl/lib/Parse/Pidl/Util.pm +++ b/source4/pidl/lib/Parse/Pidl/Util.pm @@ -101,12 +101,12 @@ sub ParseExpr($$$) return($varlist->{$x}) if (defined($varlist->{$x})); return $x; }, - undef); + undef, undef); } -sub ParseExprExt($$$$) +sub ParseExprExt($$$$$) { - my($expr, $varlist, $e, $deref) = @_; + my($expr, $varlist, $e, $deref, $use) = @_; die("Undefined value in ParseExpr") if not defined($expr); @@ -118,7 +118,7 @@ sub ParseExprExt($$$$) return($varlist->{$x}) if (defined($varlist->{$x})); return $x; }, - $deref); + $deref, $use); } 1; diff --git a/source4/pidl/pidl b/source4/pidl/pidl index 2cc7143386..0bd841a5ff 100755 --- a/source4/pidl/pidl +++ b/source4/pidl/pidl @@ -4,7 +4,7 @@ # package to parse IDL files and generate code for # rpc functions in Samba # Copyright tridge@samba.org 2000-2003 -# Copyright jelmer@samba.org 2005 +# Copyright jelmer@samba.org 2005-2007 # released under the GNU GPL =pod @@ -319,6 +319,9 @@ Specifies that a size of I<length> bytes should be read, followed by a blob of that size, which will be parsed as NDR. +subcontext() is deprecated now, and should not be used in new code. +Instead, use represent_as() or transmit_as(). + =item flag Specify boolean options, mostly used for diff --git a/source4/pidl/ref_notes.txt b/source4/pidl/ref_notes.txt deleted file mode 100644 index 00f44fddb7..0000000000 --- a/source4/pidl/ref_notes.txt +++ /dev/null @@ -1,220 +0,0 @@ -some experiments with ref ptrs - - - - typedef struct { - short x; - } xstruct; - - uint16 echo_TestRef([in] xstruct foo); - - short v = 13; - xstruct r; - r.x = v; - echo_TestRef(r); - - [0D 00] - ----------------------------------------------------- - typedef struct { - short *x; - } xstruct; - - uint16 echo_TestRef([in] xstruct foo); - - short v = 13; - xstruct r; - r.x = &v; - echo_TestRef(r); - - [PP PP PP PP 0D 00] - - - xstruct r; - r.x = NULL; - echo_TestRef(r); - - [00 00 00 00] - ----------------------------------------------------- - typedef struct { - [ref] short *x; - } xstruct; - - uint16 echo_TestRef([in] xstruct foo); - - short v = 13; - xstruct r; - r.x = &v; - echo_TestRef(r); - - [XX XX XX XX 0D 00] - - - xstruct r; - r.x = NULL; - echo_TestRef(r); - - [client runtime error 0x6f4] - - ----------------------------------------------------- - typedef struct { - short x; - } xstruct; - - uint16 echo_TestRef([in] xstruct *foo); - - short v = 13; - xstruct r; - r.x = v; - echo_TestRef(&r); - - [0D 00] - - - echo_TestRef(NULL); - - [client runtime error 0x6f4] - ----------------------------------------------------- - typedef struct { - short x; - } xstruct; - - uint16 echo_TestRef([in,ref] xstruct *foo); - - short v = 13; - xstruct r; - r.x = v; - echo_TestRef(&r); - - [0D 00] - - - echo_TestRef(NULL); - - [client runtime error 0x6f4] - - ----------------------------------------------------- - typedef struct { - short x; - } xstruct; - - uint16 echo_TestRef([in,unique] xstruct *foo); - - short v = 13; - xstruct r; - r.x = v; - echo_TestRef(&r); - - [PP PP PP PP 0D 00] - - - echo_TestRef(NULL); - - [00 00 00 00] - - ----------------------------------------------------- - typedef struct { - short x; - } xstruct; - - uint16 echo_TestRef([out] xstruct foo); - - [idl compiler error] - ----------------------------------------------------- - typedef struct { - short x; - } xstruct; - - void echo_TestRef([out] xstruct *foo); - - xstruct r; - echo_TestRef(&r); - r.x -> 13; - - [0D 00] - - - echo_TestRef(NULL); - - [client runtime error 0x6f4] - ----------------------------------------------------- - typedef struct { - short x; - } xstruct; - - void echo_TestRef([out,ref] xstruct *foo); - - xstruct r; - echo_TestRef(&r); - r.x -> 13; - - [0D 00] - - - echo_TestRef(NULL); - - [client runtime error 0x6f4] - ----------------------------------------------------- - typedef struct { - short x; - } xstruct; - - void echo_TestRef([out,unique] xstruct *foo); - - [idl compiler error] - - ----------------------------------------------------- - void echo_TestRef([in] short **foo); - - short v = 13; - short *pv = &v; - - echo_TestRef(&pv); - - [PP PP PP PP 0D 00] - - - short *pv = NULL; - - echo_TestRef(&pv); - - [00 00 00 00] - - - echo_TestRef(NULL); - - [client runtime error 0x6f4] - - ----------------------------------------------------- - void echo_TestRef([in,ref] short **foo); - - short v = 13; - short *pv = &v; - - echo_TestRef(&pv); - - [PP PP PP PP 0D 00] - - - short *pv = NULL; - - echo_TestRef(&pv); - - [00 00 00 00] - - - echo_TestRef(NULL); - - [client runtime error 0x6f4] - - diff --git a/source4/pidl/tests/ndr_deprecations.pl b/source4/pidl/tests/ndr_deprecations.pl new file mode 100755 index 0000000000..89738e42f6 --- /dev/null +++ b/source4/pidl/tests/ndr_deprecations.pl @@ -0,0 +1,28 @@ +#!/usr/bin/perl +# (C) 2007 Jelmer Vernooij <jelmer@samba.org> +# Published under the GNU General Public License +use strict; +use warnings; + +use Test::More tests => 1; +use FindBin qw($RealBin); +use lib "$RealBin"; +use Util; +use Parse::Pidl::Util qw(MyDumper); +use Parse::Pidl::NDR qw(ValidElement); + +# Case 1 + +my $e = { + 'FILE' => 'foo.idl', + 'NAME' => 'v', + 'PROPERTIES' => {"subcontext" => 1}, + 'POINTERS' => 0, + 'TYPE' => 'uint8', + 'PARENT' => { TYPE => 'STRUCT' }, + 'LINE' => 42 }; + +test_warnings("foo.idl:42: subcontext() is deprecated. Use represent_as() or transmit_as() instead\n", + sub { ValidElement($e); }); + + diff --git a/source4/pidl/tests/ndr_represent.pl b/source4/pidl/tests/ndr_represent.pl index 880ecba827..52cd06f817 100644..100755 --- a/source4/pidl/tests/ndr_represent.pl +++ b/source4/pidl/tests/ndr_represent.pl @@ -3,7 +3,7 @@ # (C) 2006 Jelmer Vernooij. Published under the GNU GPL use strict; -use Test::More tests => 1 * 8; +use Test::More tests => 2 * 8; use FindBin qw($RealBin); use lib "$RealBin"; use Util qw(test_samba4_ndr); @@ -40,3 +40,37 @@ NTSTATUS ndr_uint32_to_uint8(uint32_t from, uint8_t *to) } ' ); + +test_samba4_ndr('transmit_as-simple', +' + void bla([in,transmit_as(uint32)] uint8 x); +', +' + uint8_t expected[] = { 0x0D }; + DATA_BLOB in_blob = { expected, 1 }; + struct ndr_pull *ndr = ndr_pull_init_blob(&in_blob, NULL); + struct bla r; + + if (NT_STATUS_IS_ERR(ndr_pull_bla(ndr, NDR_SCALARS|NDR_BUFFERS, &r))) + return 1; + + if (r.in.x != 13) + return 2; +', +' +#include <libcli/util/nterr.h> + +NTSTATUS ndr_uint8_to_uint32(uint8_t from, uint32_t *to) +{ + *to = from; + return NT_STATUS_OK; +} + +NTSTATUS ndr_uint32_to_uint8(uint32_t from, uint8_t *to) +{ + *to = from; + return NT_STATUS_OK; +} +' +); + diff --git a/source4/pidl/tests/util.pl b/source4/pidl/tests/util.pl index 19cb90c080..ba2f7b7b49 100755 --- a/source4/pidl/tests/util.pl +++ b/source4/pidl/tests/util.pl @@ -4,10 +4,11 @@ use strict; use warnings; -use Test::More tests => 56; +use Test::More tests => 70; use FindBin qw($RealBin); use lib "$RealBin"; use Util; +use Parse::Pidl qw(error); use Parse::Pidl::Util; # has_property() @@ -89,3 +90,23 @@ is("b.a.a", ParseExpr("a.a.a", {"a" => "b"}, undef)); test_errors("nofile:0: Parse error in `~' near `~'\n", sub { is(undef, ParseExpr("~", {}, {FILE => "nofile", LINE => 0})); }); + +test_errors("nofile:0: Got pointer, expected integer\n", sub { + is(undef, ParseExprExt("foo", {}, {FILE => "nofile", LINE => 0}, + undef, sub { my $x = shift; + error({FILE => "nofile", LINE => 0}, + "Got pointer, expected integer"); + return undef; }))}); + +is("b.a.a", ParseExpr("b.a.a", {"a" => "b"}, undef)); +is("((rr_type) == NBT_QTYPE_NETBIOS)", ParseExpr("((rr_type)==NBT_QTYPE_NETBIOS)", {}, undef)); +is("talloc_check_name", ParseExpr("talloc_check_name", {}, undef)); +is("talloc_check_name()", ParseExpr("talloc_check_name()", {}, undef)); +is("talloc_check_name(ndr)", ParseExpr("talloc_check_name(ndr)", {}, undef)); +is("talloc_check_name(ndr, 1)", ParseExpr("talloc_check_name(ndr,1)", {}, undef)); +is("talloc_check_name(ndr, \"struct ndr_push\")", ParseExpr("talloc_check_name(ndr,\"struct ndr_push\")", {}, undef)); +is("((rr_type) == NBT_QTYPE_NETBIOS) && talloc_check_name(ndr, \"struct ndr_push\")", ParseExpr("((rr_type)==NBT_QTYPE_NETBIOS)&&talloc_check_name(ndr,\"struct ndr_push\")", {}, undef)); +is("(rdata).data.length", ParseExpr("(rdata).data.length", {}, undef)); +is("((rdata).data.length == 2)", ParseExpr("((rdata).data.length==2)", {}, undef)); +is("((rdata).data.length == 2)?0:rr_type", ParseExpr("((rdata).data.length==2)?0:rr_type", {}, undef)); +is("((((rr_type) == NBT_QTYPE_NETBIOS) && talloc_check_name(ndr, \"struct ndr_push\") && ((rdata).data.length == 2))?0:rr_type)", ParseExpr("((((rr_type)==NBT_QTYPE_NETBIOS)&&talloc_check_name(ndr,\"struct ndr_push\")&&((rdata).data.length==2))?0:rr_type)", {}, undef)); diff --git a/source4/torture/smbtorture.c b/source4/torture/smbtorture.c index 79b00494ca..cc4c3e6b5b 100644 --- a/source4/torture/smbtorture.c +++ b/source4/torture/smbtorture.c @@ -583,10 +583,8 @@ int main(int argc,char *argv[]) if (strcmp(target, "samba3") == 0) { lp_set_cmdline("torture:samba3", "true"); - lp_set_cmdline("torture:knownfail", "samba3-knownfail"); } else if (strcmp(target, "samba4") == 0) { lp_set_cmdline("torture:samba4", "true"); - lp_set_cmdline("torture:knownfail", "samba4-knownfail"); } if (max_runtime) { @@ -662,8 +660,7 @@ int main(int argc,char *argv[]) exit(1); } - torture = torture_context_init(talloc_autofree_context(), - lp_parm_string(-1, "torture", "knownfail"), ui_ops); + torture = torture_context_init(talloc_autofree_context(), ui_ops); if (argc_new == 0) { printf("You must specify a test to run, or 'ALL'\n"); diff --git a/source4/torture/torture.c b/source4/torture/torture.c index df25fdce74..e54efd72d0 100644 --- a/source4/torture/torture.c +++ b/source4/torture/torture.c @@ -42,7 +42,6 @@ bool torture_register_suite(struct torture_suite *suite) } struct torture_context *torture_context_init(TALLOC_CTX *mem_ctx, - const char *known_failures_file, const struct torture_ui_ops *ui_ops) { struct torture_context *torture = talloc_zero(mem_ctx, |