Stephen Seo
2495396d76
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. |
||
---|---|---|
.github/workflows | ||
src | ||
.gitignore | ||
.gitmodules | ||
CMakeLists.txt | ||
Doxyfile | ||
LICENSE | ||
README.md |
UDPConnection
Provides a network connection over UDP, with verification of packet support via libsodium (optional). Implemented in C++ (up to C++11 standard), but is available via a C api, which should facilitate creating bindings for other programming languages if needed.
This library is still a work in progress, so api breaking changes may happen in the future.
Documentation
See the gh-pages generated Doxygen documentation here.
Compiling
Release builds
mkdir buildRelease
cd buildRelease
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr -DBUILD_SHARED_LIBS=True ..
make
make DESTDIR=install_destination install
Debug builds
mkdir buildDebug
cd buildDebug
cmake -DCMAKE_BUILD_TYPE=Debug ..
make
Usage
The program in src/test/UDPC_NetworkTest.c
is used for testing UDPConnection
and is also an example of using the library in a C program.
Debug Builds
NetworkTest only builds when CMAKE_BUILD_TYPE is Debug (default).
UnitTest only builds in Debug mode and if GTest (a unit testing framework) is available.
Links
https://github.com/Stephen-Seo/UDPConnection
https://git.seodisparate.com/stephenseo/UDPConnection