mirror of
https://github.com/signalwire/freeswitch.git
synced 2026-08-19 09:40:21 +00:00
Bounds and termination fixes across the STUN attribute receive path in `handle_ice` and `switch_stun_lookup`: - `switch_stun_packet_next_attribute` and its `_hbo` variant now confirm the 4-byte attribute header is fully within `end` before dereferencing `type`/`length`, and include the header when checking that the value fits, so a truncated or overrunning attribute is not read past the buffer. - Compute `end_buf` as the 20-byte STUN header plus the attribute section (`SWITCH_STUN_PACKET_MIN_LEN + header.length`) so the walk covers every attribute, including trailing ones. - Make `switch_stun_packet_next_attribute` the sole loop terminator and drop the redundant `xlen` guard; its seed differed between the two functions and could skip a trailing attribute in `switch_stun_lookup`. - `switch_stun_packet_attribute_get_username` reserves a byte for the terminator and always NUL-terminates, since callers use the result as a C string.
FreeSWITCH unit tests should be kept as shallow unit tests and micro benchmarks testing functionality exposed through libfreeswitch. Requirements for a new unit tests: 1. Tests must use switch_test.h framework