Repository navigation
udp_multicast: drop malformed datagrams instead of raising in _recv_internal - #2174
Conversation
AI Review: udp_multicast: drop malformed datagrams instead of raisingThe fix is correct and worthwhile. On Lint failure
Tests
News fragment
Verdict: request changes |
A datagram that does not decode to a can.Message is bad input from a sender, not a bus or socket fault. Log it and keep receiving so a thread-based Notifier is not stopped. Socket, select and timestamp errors from recv() are still raised as CanOperationError.
Keep the broad except with a BLE001 noqa, test the drop through a real socket on BasicTestUdpMulticastBusIPv4, remove the mock-based unit file, and rename the news fragment to 2173.fixed.rst.
f2987f5 to
8da1ed7
Compare
|
Thanks for the review — I've applied the requested changes. The broad — Ugur Celik (ucsurf) · https://uc.surf |
Summary of Changes
UdpMulticastBus._recv_internal()now logs and drops a datagram that cannot be decoded into acan.Message, instead of raisingCanOperationError. A raised error there ends a thread-basedNotifier, so one bad datagram stopped message delivery.recv()are still raised asCanOperationError. This matches the existing handling of FD frames on a non-FD bus, which are already dropped.Related Issues / Pull Requests
Type of Change
Checklist
tox).Additional Notes
Tests: Added test/test_udp_multicast.py; those 3 tests pass locally with a mocked socket; full suite/tox not run. The contribution-guide box is left unticked because tox and the full suite were not run. No documentation change was needed beyond the news fragment.
Credit: Ugur Celik (ucsurf), @ucsurf
— Ugur Celik (ucsurf) · https://uc.surf
We find and report security issues in open source before attackers do. If our work helped you, a small contribution keeps it going and makes the internet a little safer for everyone:
https://buymeacoffee.com/ucsurf