From 3f6ca430b067705d556031d52736d5a5d5ae8f55 Mon Sep 17 00:00:00 2001 From: Matthieu Patou Date: Fri, 11 Oct 2013 13:18:37 -0700 Subject: [PATCH] pidl-wireshark: if the structure has the flag no_align then set also no_align in the dceprc_info structure Some dissection function will try to do alignment if the no_align flag is not set. Pair-Programmed-With: Stefan Metzmacher Signed-off-by: Matthieu Patou Signed-off-by: Stefan Metzmacher --- pidl/lib/Parse/Pidl/Wireshark/NDR.pm | 29 +++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/pidl/lib/Parse/Pidl/Wireshark/NDR.pm b/pidl/lib/Parse/Pidl/Wireshark/NDR.pm index 321104fdc3d..6bc03ccd9b9 100644 --- a/pidl/lib/Parse/Pidl/Wireshark/NDR.pm +++ b/pidl/lib/Parse/Pidl/Wireshark/NDR.pm @@ -647,6 +647,13 @@ sub Struct($$$$) $res.="\t".$self->Element($_, $name, $ifname, $switch_info)."\n\n"; } + my $doalign = undef; + if ($e->{ALIGN} > 1 and not property_matches($e, "flag", ".*LIBNDR_FLAG_NOALIGN.*")) { + $doalign = 1; + } elsif (property_matches($e, "flag", ".*LIBNDR_FLAG_NOALIGN.*")) { + $doalign = 0; + } + $self->pidl_hdr("int $dissectorname(tvbuff_t *tvb _U_, int offset _U_, packet_info *pinfo _U_, proto_tree *parent_tree _U_, guint8 *drep _U_, int hf_index _U_, guint32 param _U_);"); $self->pidl_fn_start($dissectorname); @@ -657,16 +664,24 @@ sub Struct($$$$) $self->pidl_code($_) foreach (@$vars); $self->pidl_code("proto_item *item = NULL;"); $self->pidl_code("proto_tree *tree = NULL;"); - if ($e->{ALIGN} > 1) { + if (defined($doalign)) { $self->pidl_code("dcerpc_info *di = (dcerpc_info *)pinfo->private_data;"); + if ($doalign == 0) { + $self->pidl_code("gboolean oldalign = di->no_align;"); + } } $self->pidl_code("int old_offset;"); $self->pidl_code(""); - if ($e->{ALIGN} > 1 and not property_matches($e, "flag", ".*LIBNDR_FLAG_NOALIGN.*")) { - $self->pidl_code("ALIGN_TO_$e->{ALIGN}_BYTES;"); + if (defined($doalign)) { + if ($doalign == 1) { + $self->pidl_code("ALIGN_TO_$e->{ALIGN}_BYTES;"); + } + if ($doalign == 0) { + $self->pidl_code("di->no_align = TRUE;"); + } + $self->pidl_code(""); } - $self->pidl_code(""); $self->pidl_code("old_offset = offset;"); $self->pidl_code(""); @@ -680,7 +695,7 @@ sub Struct($$$$) $self->pidl_code("\n$res"); $self->pidl_code("proto_item_set_len(item, offset-old_offset);\n"); - if ($e->{ALIGN} > 1) { + if (defined($doalign) and $doalign == 1) { $self->pidl_code(""); $self->pidl_code("if (di->call_data->flags & DCERPC_IS_NDR64) {"); $self->indent; @@ -688,6 +703,10 @@ sub Struct($$$$) $self->deindent; $self->pidl_code("}"); } + if (defined($doalign) and $doalign == 0) { + $self->pidl_code(""); + $self->pidl_code("di->no_align = oldalign;"); + } $self->pidl_code(""); $self->pidl_code("return offset;"); $self->deindent;