summaryrefslogtreecommitdiff
path: root/pidl
diff options
context:
space:
mode:
authorAurelien Aptel <aaptel@suse.com>2016-02-09 17:36:19 +0100
committerStefan Metzmacher <metze@samba.org>2016-06-20 12:08:21 +0200
commit0d209ea24b4c7a0e403e8903fdc445493894e114 (patch)
treeb501fca06962ca26def6c3a522569cf6cafff222 /pidl
parent57bc1ced67b9c1a65f9997d54bf560cdeb3802a2 (diff)
downloadsamba-0d209ea24b4c7a0e403e8903fdc445493894e114.tar.gz
pidl/ws: dereference pointers when passing name param.
Port parts of Wireshark commit a58c986f to the samba repo. Signed-off-by: Aurelien Aptel <aaptel@suse.com> Reviewed-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: David Disseldorp <ddiss@samba.org>
Diffstat (limited to 'pidl')
-rw-r--r--pidl/lib/Parse/Pidl/Wireshark/NDR.pm38
1 files changed, 30 insertions, 8 deletions
diff --git a/pidl/lib/Parse/Pidl/Wireshark/NDR.pm b/pidl/lib/Parse/Pidl/Wireshark/NDR.pm
index 6cc600adbfc..f17efe78454 100644
--- a/pidl/lib/Parse/Pidl/Wireshark/NDR.pm
+++ b/pidl/lib/Parse/Pidl/Wireshark/NDR.pm
@@ -437,9 +437,9 @@ sub SwitchType($$;$)
return $switch_type
}
-sub Element($$$$$)
+sub Element($$$$$$)
{
- my ($self,$e,$pn,$ifname,$isoruseswitch) = @_;
+ my ($self,$e,$pn,$ifname,$isoruseswitch,%switchvars) = @_;
my $dissectorname = "$ifname\_dissect\_element\_".StripPrefixes($pn, $self->{conformance}->{strip_prefixes})."\_".StripPrefixes($e->{NAME}, $self->{conformance}->{strip_prefixes});
@@ -449,6 +449,7 @@ sub Element($$$$$)
my $type = $isoruseswitch->[0];
my $name = $isoruseswitch->[1];
+ my $switch_dt = getType($type);
my $switch_raw_type = SwitchType($e, $type, "uint32");
if (not defined($switch_raw_type)) {
die("Unknown type[$type]\n");
@@ -456,7 +457,22 @@ sub Element($$$$$)
my $switch_type = "g${switch_raw_type}";
$moreparam = ", $switch_type *".$name;
- $param = $name;
+
+ if (($e->{PROPERTIES}->{switch_is} eq "") && ($switchvars{$name}) &&
+ #not a "native" type
+ (!($type =~ /^uint(8|16|1632|32|3264|64)/))) {
+ $param = $name;
+ } elsif ( $switch_dt->{DATA}->{TYPE} eq "ENUM") {
+ $param = $name;
+ } else {
+ $param = "*".$name;
+ }
+
+ if ($name ne "") {
+ $call_code = "offset = $dissectorname(tvb, offset, pinfo, tree, di, drep, &$name);";
+ } else {
+ $call_code = "offset = $dissectorname(tvb, offset, pinfo, tree, di, drep);";
+ }
} else {
$moreparam = "";
$call_code = "offset = $dissectorname(tvb, offset, pinfo, tree, di, drep);";
@@ -504,7 +520,9 @@ sub Element($$$$$)
foreach (@{$e->{LEVELS}}) {
if (defined $_->{SWITCH_IS}) {
$oldparam = $param;
- $param = "*$param";
+ if (($param ne "0") && (!($param =~ /\*/))) {
+ $param = "*$param";
+ }
}
next if ($_->{TYPE} eq "SWITCH");
next if (defined($self->{conformance}->{noemit}->{"$dissectorname$add"}));
@@ -539,7 +557,7 @@ sub Function($$$)
my %dissectornames;
foreach (@{$fn->{ELEMENTS}}) {
- $dissectornames{$_->{NAME}} = $self->Element($_, $fn->{NAME}, $ifname, undef) if not defined($dissectornames{$_->{NAME}});
+ $dissectornames{$_->{NAME}} = $self->Element($_, $fn->{NAME}, $ifname, undef, undef) if not defined($dissectornames{$_->{NAME}});
}
my $fn_name = $_->{NAME};
@@ -643,9 +661,11 @@ sub Struct($$$$)
my $varswitchs = {};
# will contain the switch var declaration;
my $vars = [];
+ my %switch_hash;
foreach (@{$e->{ELEMENTS}}) {
if (has_property($_, "switch_is")) {
$varswitchs->{$_->{PROPERTIES}->{switch_is}} = [];
+ $switch_hash{ $_->{PROPERTIES}->{switch_is}} = $_->{PROPERTIES}->{switch_is};
}
}
foreach (@{$e->{ELEMENTS}}) {
@@ -660,7 +680,9 @@ sub Struct($$$$)
}
my $switch_type = "g${switch_raw_type}";
- push @$vars, "$switch_type $v = 0;";
+ if ($switch_type ne "") {
+ push @$vars, "$switch_type $v = 0;";
+ }
$switch_info = [ $_->{TYPE}, $v ];
$varswitchs->{$v} = $switch_info;
}
@@ -670,7 +692,7 @@ sub Struct($$$$)
$switch_info = $varswitchs->{$varswitch};
}
- $res.="\t".$self->Element($_, $name, $ifname, $switch_info)."\n\n";
+ $res.="\t".$self->Element($_, $name, $ifname, $switch_info, %switch_hash)."\n\n";
}
my $doalign = undef;
@@ -763,7 +785,7 @@ sub Union($$$$)
foreach (@{$e->{ELEMENTS}}) {
$res.="\n\t\t$_->{CASE}:\n";
if ($_->{TYPE} ne "EMPTY") {
- $res.="\t\t\t".$self->Element($_, $name, $ifname, undef)."\n";
+ $res.="\t\t\t".$self->Element($_, $name, $ifname, undef, undef)."\n";
}
$res.="\t\tbreak;\n";
}