pidl/lib: Add recursion detection logic to prevent looping.
authorNoel Power <noel.power@suse.com>
Tue, 2 Dec 2014 17:26:41 +0000 (17:26 +0000)
committerAndrew Bartlett <abartlet@samba.org>
Tue, 5 Sep 2023 21:18:32 +0000 (21:18 +0000)
commit3f3fccab05d8e8dee0127968c49482600d5cf39e
tree4f094d06114c9bb52b678a017a0bd9dd4fd9f71e
parent171171565f1909592cf728d3f6d78c611c6a30ed
pidl/lib: Add recursion detection logic to prevent looping.

Under some circumstances 'can_contain_deferred' & 'align_type functions' can
loop.

This prevents a hang when processing sample idl like

interface hang
{
typedef [public] struct {
wsp_cbasestoragevariant variant[NUM_ENTRIES];
} vt_variant_wrap;

typedef [public,nodiscriminant,switch_type(uint16)] union {
[case(VT_I1)] int8 vt_i1;
[case(VT_VARIANT)] vt_variant_wrap vt_variant_wrap;
} variant_types;

typedef [public] struct {
[switch_is(vtype)] variant_types vvalue;
} wsp_cbasestoragevariant;
};

which will hang with the following command

   pidl --header --ndr-parser -- foo.idl

Signed-off-by: Noel Power <noel.power@suse.com>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
pidl/lib/Parse/Pidl/NDR.pm