From: John Thacker Date: Sun, 12 Oct 2025 19:07:00 +0000 (-0400) Subject: wireshark-pidl: Check for undefined SwitchType first X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=56e4a4faad7a6da2fe479b02e7f296f2263733f8;p=thirdparty%2Fsamba.git wireshark-pidl: Check for undefined SwitchType first From the Wireshark development branch: commit edc98c1b537cbd7b8fb35cdb8b61b7dd000a1544 Author: John Thacker Date: Thu Oct 9 18:31:35 2025 -0400 pidl: Check for undefined SwitchType first If the switch type is not defined (e.g. in a union with no discriminant) check for that first instead of doing a bunch of comparisons with an uninitialized scalar variable. Doesn't change the dissector results, but prevents a bunch of Perl warnings: Use of uninitialized value $t in hash element at /wireshark/tools/pidl/lib/Parse/Pidl/Typelist.pm line 194. Use of uninitialized value in string eq at /wireshark/tools/pidl/lib/Parse/Pidl/Wireshark/NDR.pm l ine 480. Use of uninitialized value in string eq at /wireshark/tools/pidl/lib/Parse/Pidl/Wireshark/NDR.pm l ine 482. Use of uninitialized value in string eq at /wireshark/tools/pidl/lib/Parse/Pidl/Wireshark/NDR.pm l ine 484. Signed-off-by: John Thacker Reviewed-by: Stefan Metzmacher Reviewed-by: Andreas Schneider --- diff --git a/pidl/lib/Parse/Pidl/Wireshark/NDR.pm b/pidl/lib/Parse/Pidl/Wireshark/NDR.pm index f27d4f9850c..667199ecbd5 100644 --- a/pidl/lib/Parse/Pidl/Wireshark/NDR.pm +++ b/pidl/lib/Parse/Pidl/Wireshark/NDR.pm @@ -450,21 +450,23 @@ sub SwitchType($$;$) { my ($e, $type, $nodiscriminant) = @_; - my $switch_dt = getType($type); my $switch_type = undef; - if ($switch_dt->{DATA}->{TYPE} eq "ENUM") { - $switch_type = Parse::Pidl::Typelist::enum_type_fn($switch_dt->{DATA}); - } elsif ($switch_dt->{DATA}->{TYPE} eq "BITMAP") { - $switch_type = Parse::Pidl::Typelist::bitmap_type_fn($switch_dt->{DATA}); - } elsif ($switch_dt->{DATA}->{TYPE} eq "SCALAR") { - if (defined $e->{SWITCH_TYPE}) { - $switch_type = "$e->{SWITCH_TYPE}"; - } else { - $switch_type = "$switch_dt->{DATA}->{NAME}"; - } - } elsif (not defined $e->{SWITCH_TYPE}) { + if (not defined($type)) { $switch_type = $nodiscriminant; - } + } else { + my $switch_dt = getType($type); + if ($switch_dt->{DATA}->{TYPE} eq "ENUM") { + $switch_type = Parse::Pidl::Typelist::enum_type_fn($switch_dt->{DATA}); + } elsif ($switch_dt->{DATA}->{TYPE} eq "BITMAP") { + $switch_type = Parse::Pidl::Typelist::bitmap_type_fn($switch_dt->{DATA}); + } elsif ($switch_dt->{DATA}->{TYPE} eq "SCALAR") { + if (defined $e->{SWITCH_TYPE}) { + $switch_type = "$e->{SWITCH_TYPE}"; + } else { + $switch_type = "$switch_dt->{DATA}->{NAME}"; + } + } + } return $switch_type }