UDPConnection/src
Stephen Seo 2495396d76 Fix potential memory corruption bug
UDPC_atostr(...) uses a uint32_t as an offset into a buffer inside the
UDPC Context such that there can be at most 32 different addr-strings.
The call is thread-safe, up to a point (at most 32 concurrent calls will
return correct strings). The problem was that the offset was not being
reset to 0 and was always being incremented by 40. Should the offset
overflow, the offset into the buffer will be "mis-aligned" such that the
32nd offset into the buffer can possibly overwrite memory past the
buffer's end if the addr string is long enough.

The fix is to use a mutex instead of an atomic uint32_t to lock a
code-block that will always prevent overflow (using modulus operator).

I think the speed-loss is negligable (using a lock instead of an atomic
uint32_t) since it isn't expected for programs using UDPC to use
UDPC_atostr(...) very frequently.
2023-06-21 13:23:26 +09:00
..
test Fix potential nullptr deref in free_PacketInfo_ptr 2023-04-19 19:11:03 +09:00
TSLQueue.hpp Fix use of C++14/C++17, only C++11 is supported 2020-03-06 12:05:33 +09:00
UDPC.h Add UDPC_free_PacketInfo_ptr(...) 2023-04-19 18:50:26 +09:00
UDPC_Defines.hpp Fix potential memory corruption bug 2023-06-21 13:23:26 +09:00
UDPConnection.cpp Fix potential memory corruption bug 2023-06-21 13:23:26 +09:00