Limit the label count when parsing a mDns packet
If some bytes in the mDNS packet are incorrect, such as the
service name, the MdnsPacketReader will enter an infinite loop
and crash with an out-of-memory error when parsing the data. This
issue can be resolved by limiting the label count when parsing
the mDNS packet. If the label count exceeds the limit, the packet
should be discarded as it is likely corrupted.
Bug: 307475137
Test: Manually test with problematic mnds packet raw data
atest FrameworksNetTests android.net.cts.NsdManagerTest
Ignore-AOSP-First: Security fix.
Change-Id: I48b1dc26f41549ec4afc71f87e98a02ac773430f
12 files changed