1
0
mirror of https://github.com/samba-team/samba.git synced 2025-02-26 21:57:41 +03:00

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 <metze@samba.org>

Signed-off-by: Matthieu Patou <mat@matws.net>
Signed-off-by: Stefan Metzmacher <metze@samba.org>
This commit is contained in:
Matthieu Patou 2013-10-11 13:18:37 -07:00 committed by Stefan Metzmacher
parent f0a6043fb2
commit 3f6ca430b0

View File

@ -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;