Commit graph

295 commits

Author SHA1 Message Date
390f3972f8 Add documentation for UDPC_atostr... 2023-06-22 12:07:26 +09:00
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
211715fc56 Fix potential nullptr deref in free_PacketInfo_ptr 2023-04-19 19:11:03 +09:00
3fac706d86 Add UDPC_free_PacketInfo_ptr(...)
Also add unit test for this function.
2023-04-19 18:50:26 +09:00
00b249bdc8 Update LICENSE year 2023-04-18 14:05:52 +09:00
f18e87903a Refactor UDPC::get_empty_pinfo() 2023-04-18 14:03:31 +09:00
087d3cfc6f Impl handling Ctrl-C for Windows in NetworkTest 2023-01-10 12:14:57 +09:00
577ab0bc52 Better handling of receiving packets in recv loop
On error processing a received packet, continue to receive packets in
the loop. If no packet was received, the loop ends.
2023-01-10 11:51:54 +09:00
a8ef89d9b1 Update documentation about UDPC_update(ctx) 2022-12-08 16:54:02 +09:00
77ac7f88a5 Receive packets in loop til none left in interval
Also some formatting fixes (max 80 chars in edited code).
2022-12-04 19:58:13 +09:00
b7cd3a00c7 Update LICENSE 2022-11-23 14:14:05 +09:00
e774a54349 Handle SIGINT (Ctrl-C) in NetworkTest 2022-11-23 14:13:44 +09:00
6784ba96dd Update README.md 2021-09-09 18:13:38 +09:00
6e39e6dc16 Add gh-pages workflow for Doxygen documentation 2021-09-09 18:10:07 +09:00
0e082c670f Update .gitignore 2021-08-30 12:07:27 +09:00
cf748827bc Fix README.md 2021-08-25 19:45:01 +09:00
cdee65d91a
Update README.md 2021-02-14 13:56:26 +09:00
d2cb2d79b8 Update year in LICENSE 2021-01-10 14:40:38 +09:00
e08e620b26 Add |id| to PacketInfo 2021-01-10 14:40:17 +09:00
ba3d6df406 Use dll_export (for builds for Windows) 2020-06-23 13:01:27 +09:00
b0e996cda3 Attempt to make NetworkTest work on Windows 2020-04-28 20:55:16 +09:00
2a39267b38 Add/fix more documentation 2020-04-28 19:38:07 +09:00
d3fb621406 Minor fixes 2020-04-27 19:34:04 +09:00
445a221a5b Fix check addr endianness in a4toa6 function 2020-04-27 11:47:50 +09:00
31ca4ddc44 Impl create id with hostname
Previously, ids could only be created with an ip address. Now they can
be made with a hostname, which will be looked up by UDPC.

Also fix client still requesting connections even if
accept-new-connections flag is false.
2020-04-26 18:52:06 +09:00
5dcab1d590 Minor fix to documentation 2020-04-18 16:19:59 +09:00
76c5bb750d Use memcpy instead of pointer casted assignment
std::memcpy is used over int pointer casted assignment due to possible
alignment issues that may cause the casted pointer to be invalid.
2020-04-18 16:09:00 +09:00
cf6ff5a040 Change how UDPC_PacketInfo handles it's data
The "data" member variable in UDPC_PacketInfo is now handled as a
pointer to dynamic data, instead of an array with a fixed size. Every
time a UDPC_PacketInfo is received from the context,
UDPC_free_PacketInfo() must be called on it to avoid a memory leak.
2020-04-15 19:56:15 +09:00
e01a1ccd94 Fix compilation fail on no libsodium 2020-03-06 13:03:47 +09:00
75f54119bf Fix use of C++14/C++17, only C++11 is supported 2020-03-06 12:05:33 +09:00
c37909bde3 Add helpers converting network-order (big-endian) 2020-01-16 20:28:42 +09:00
0170423a35 Fix UDPC::isBigEndian returning always true 2020-01-16 20:28:01 +09:00
80e67e845c Distinguish manual variables and pkgconf variables
Variables checked to manually set libsodium paths have been changed to
prevent conflict with variables set by searching for libsodium via
pkgconfig.
2020-01-16 11:31:22 +09:00
ed20c28ed0 Allow manually setting dependency libsodium paths 2020-01-16 11:27:19 +09:00
136c8b21a5 Fix verification message when using libsodium
Previous implementation had the client send only epoch-time-in-seconds
to be signed by the server. Now the client sends random data and
epoch-time to be signed by the server.
2020-01-15 16:31:38 +09:00
a3da8334e4 Update README.md 2020-01-13 19:26:05 +09:00
83392fc916 Fix doxygen documentation 2020-01-13 19:22:08 +09:00
f0638d2d77 Update README.md 2020-01-13 19:14:34 +09:00
3575ee9d26 Update README.md 2020-01-13 18:50:00 +09:00
76a7872e4a Update README.md 2020-01-13 18:47:22 +09:00
43a60e5826 Add LICENSE and README.md 2020-01-13 18:41:38 +09:00
b41639c568 Set pointers to const where possible in API 2020-01-10 20:28:08 +09:00
f588d409c9 Truncate "UDPConnection" to "UDPC" 2020-01-09 16:57:01 +09:00
40c4c9b2ba Fix potential non-null-terminated string bug 2020-01-09 16:45:57 +09:00
4d68715efb Add more documentation, some fixes 2020-01-08 20:50:56 +09:00
4c48dbb0cf Replace TSLQueue with std::deque where possible
Also added std::mutex for each new std::deque. cSendPkts is left as a
TSLQueue because it needs to support fast removal from the middle of the
data structure (mainly because the queued packets per ConnectionData has
an imposed limit of packets to hold).
2020-01-08 19:55:12 +09:00
e66e6c7b74 Minor fix to keysSet atomic_bool 2020-01-05 16:05:22 +09:00
e644cd86b1 Minor fixes 2020-01-05 15:39:25 +09:00
88ba670ce9 Fix usage of atomic_bool "keysSet" 2020-01-05 15:31:37 +09:00
1ecf9bff4f Minor refactoring/fix of use of atomic_bool 2020-01-05 15:12:13 +09:00