Commit Graph

5116 Commits

Author SHA1 Message Date
iphydf
7a4cc107c0
fix: Fix a stack overflow triggered by small DHT packets.
This isn't in production yet. It's in the new announce store code. The
problem was that a negative plain_len was converted to unsigned, which
made it a very large number.
2022-04-04 09:35:19 +00:00
iphydf
2c06ef6ad4
cleanup: Replace a series of if statements with a switch. 2022-04-04 09:02:48 +00:00
iphydf
941026266e
refactor: Allow overriding mono_time in tox_new.
This makes it so if mono_time is overridden, no monotonic time-related
system call is invoked in tox_new.
2022-04-03 22:48:16 +00:00
Robin Linden
6baabee695
chore: Add a shared library on Windows appveyor job
This also changes the Appveyor build to only build once, with tests,
instead of once without tests and once with tests.
2022-04-03 23:04:19 +02:00
Robin Linden
657d185de5
chore: Support producing shared libraries on Windows
The FLAT_OUTPUT_STRUCTURE CMake option was added to allow the tests to
find the .dlls.

The global data symbols were converted to functions to allow
WINDOWS_EXPORT_ALL_SYMBOLS handle them.

See:
https://cmake.org/cmake/help/v3.23/prop_tgt/WINDOWS_EXPORT_ALL_SYMBOLS.html
2022-04-03 23:04:11 +02:00
iphydf
ddda605509
fix: Don't crash if RNG init failed.
`system_random()` can fail and return NULL, which should be handled by
toxencryptsave functions.

Also synced function comments between .h and .c file for toxencryptsave.
2022-04-03 20:46:44 +00:00
zugz (tox)
4430515052
cleanup: remove populate_path_nodes_tcp
It was a no-op.
2022-04-03 00:00:00 +00:00
iphydf
7a3ead591f
cleanup: Use a struct for the ip_ntoa buffer.
Every use of this function needs to allocate the same buffer. None of
the callers uses a differently sized buffer, so we might as well put it
in a struct and have the type checker prove the buffer size is correct.

Also rename `ip_ntoa` to `net_ip_ntoa` to avoid clashes with ESP-IDF
system libraries which define this function as well.
2022-04-03 18:57:04 +00:00
iphydf
e4d1958ffa
refactor: Allow NULL logger; make it no-op in NDEBUG. 2022-04-03 18:29:22 +00:00
iphydf
4d5887cc58
test: Improve stability of forwarding_test.
By trying to create a tox tcp relay on 100 ports starting at 36570.
2022-04-03 18:14:01 +00:00
iphydf
378febffff
cleanup: Use static_assert instead of assert where possible.
This avoids some "always true condition" warnings and lifts the errors
(if any) into compile time.
2022-04-03 17:58:14 +00:00
zugz (tox)
e49a477a84
feat: add forwarding and announce request handling
This is the "server-side" part of the new friend finding system,
allowing DHT nodes to store small amounts of data and permit searching
for it. A forwarding (proxying) mechanism allows this to be used by TCP
clients, and deals with non-transitivity in the network.
2022-04-03 00:00:08 +00:00
zugz (tox)
97acb39c1f
cleanup: add timed_auth module for ping_ids 2022-04-03 00:00:08 +00:00
zugz (tox)
7cee48d9c4
cleanup: clarify and isolate use of custom IP_Port values to denote TCP connections 2022-04-03 11:41:42 +00:00
iphydf
dec1399776
test: Add fuzzer support functions for internal toxcore objects.
These help creating fuzzer fixtures with non-trivially constructed
objects and takes care of cleaning them up afterwards so the fuzzer code
can focus on the system under test.
2022-04-03 11:21:06 +00:00
iphydf
c71b1218f8
chore(deps): Use upstream cmp directly instead of our fork.
The upstream maintainer is active and has merged our changes.
2022-04-03 09:02:31 +00:00
iphydf
b66f4959e2
chore: Add dependabot config.
To keep the third_party/cmp submodule up-to-date.
2022-04-03 08:45:09 +00:00
iphydf
e3ace8ca24
cleanup: Make *_free functions nullable.
These should be no-ops when passed a null pointer.
2022-04-02 21:28:26 +00:00
iphydf
eb07575334
cleanup: Remove layers in the cmake build.
Nothing checks whether these layers are actually observed. The bazel
build does check this, so there's no need to have this documentation in
the cmake build. It'll just go out of date.
2022-04-01 17:17:15 +00:00
iphydf
1f4aaf01cb
chore: Fix path to fuzzer binaries in clusterfuzz build. 2022-04-01 16:58:17 +00:00
iphydf
cc31ff07fa
feat: Add support for custom random number generator.
This can be used by fuzzers to make RNG-driven code deterministic (i.e.
based on the fuzzer input).
2022-04-01 14:06:05 +00:00
iphydf
660e346fce
cleanup: Disallow stack frames of over 9000 bytes.
This only happens in tests, which are easy to fix. Inside toxcore we
should actually be more stringent, but for now this helps already.
2022-04-01 13:57:16 +00:00
iphydf
8b407802dd
refactor: Rename bin_pack/unpack functions the same as cmp funcs.
No real reason to have different names. Also "bin" is shorter than
"bytes" to write.
2022-04-01 11:15:16 +00:00
iphydf
d0ebc21a0e
cleanup: Add Network object parameter for addr_resolve.
This function doesn't use Network yet, but it will in the future, and
for now it's better to pass Network to all network I/O functions.
2022-04-01 10:42:43 +00:00
iphydf
e04484efae
cleanup: Remove unused random_testing program.
Fuzzers do a better job of this.
2022-04-01 09:20:04 +00:00
iphydf
b09a1ff02d
cleanup: Remove all uses of TOX_*_MAX_SIZE macros.
We should use the functions for these instead.
2022-04-01 09:10:37 +00:00
zugz (tox)
3cc72f5f57
fix: fix typo in git command in INSTALL.md 2022-03-31 00:00:00 +00:00
iphydf
c8e5fd37ae
cleanup: Add include for assert.h for the fuzzing build.
See https://github.com/TokTok/c-toxcore/runs/5776684729?check_suite_focus=true#step:4:945.
2022-03-31 19:11:09 +00:00
iphydf
cc0c4a5fe1
cleanup: Move definitions of tox_private.h functions to tox_private.c.
Also moved lock/unlock to tox_private so they can be used across these 2
tox/tox_private translation units.
2022-03-31 18:49:26 +00:00
iphydf
9b2e887826
cleanup: Expand CONST_FUNCTION and remove the macro.
Generating functions is ugly. Ideally astyle wouldn't ask us to write 4
lines of code where 1 would be more readable, but such is life (until we
move to clang-format).
2022-03-31 18:35:45 +00:00
iphydf
ee42a5ca05
chore: Add uint8_t version of bin_pack for numbers.
This was the only one missing. Also added a test for integer
conversions: lossy ones are rejected, lossless ones are ok.
2022-03-31 17:09:15 +00:00
jfreegman
015305a088
Merge moderation portion of new groupchats codebase 2022-03-30 20:09:50 -04:00
iphydf
09575dc05b
chore: Clone submodules in clusterfuzzlite Dockerfile.
Needed for the build afterwards.

Also added the cflite Dockerfile to automatic CI builds so changes to it
are checked in pull requests.

Also fixed the tokstyle docker image. It needs clang instead of gcc now.
2022-03-30 18:29:46 +00:00
iphydf
7db0c80c93
test: Add DHT and tox_events fuzz tests to the cmake build. 2022-03-29 22:57:23 +00:00
iphydf
f39aac09e6
feat: Allow custom network functions.
The idea here is to have a `Network` object that contains functions for
network operations and an optional userdata object that can manage those
network operations. This allows e.g. a fuzzer to replace the network
functions with no-ops or fuzzer inputs, reducing the need for `#ifdef`s.
2022-03-29 22:03:26 +00:00
iphydf
2e3819c956
chore: Remove valgrind build.
This is very slow, around 20 minutes, which seriously slows down
velocity for little gain. MSAN runs on unit tests and 1 auto test, so
we'll catch increasingly many valgrind-ish bugs that way in one of the
1-5-minute builds.
2022-03-29 12:53:02 +00:00
iphydf
ad90f5bbb8
cleanup: Mark Mono_Time const where possible. 2022-03-28 21:26:34 +00:00
iphydf
d56cb13279
cleanup: Avoid name clash between struct field and function.
`connection_status_callback` is also used as struct field in net_crypto.
2022-03-28 21:12:08 +00:00
Tha14
73b0e0fed7
Add information regarding git submodules, cmp 2022-03-28 22:49:31 +03:00
iphydf
6cc8ef3771
cleanup: Add more null checks in tox_new.
So the rest of the code can assume non-null more.
2022-03-28 14:52:38 +00:00
iphydf
f13029417e
test: Remove save_load_test from autotools build.
It keeps timing out. Not great, but it's covered by other builds.
2022-03-28 00:11:47 +00:00
iphydf
24065cf5a9
chore: Update bootstrap daemon checksum. 2022-03-27 23:30:37 +00:00
zugz (tox)
c38f21f888
fix: Correct calculation of packet sent time 2022-03-27 23:30:36 +00:00
iphydf
e4558a287c
perf: Make time move a lot faster in fuzzing runs. 2022-03-27 22:52:35 +00:00
iphydf
ae369dc2e7
test: Enable more tests for msan. 2022-03-27 22:26:15 +00:00
iphydf
b768c153ae
chore: Add third_party to toxcore-sources docker image.
This is needed so other/docker/coverage/run works.
2022-03-27 22:01:19 +00:00
iphydf
bb7b1e9b3a
cleanup: Make addr_resolve a private function.
This isn't used anywhere except in network_test. That test now checks
behaviour of the function actually used elsewhere in tox code, instead.
2022-03-27 20:10:42 +00:00
iphydf
478ef39b39
test: Add some support functions to make writing fuzzers easier. 2022-03-27 18:43:41 +00:00
iphydf
96ab8918dc
cleanup: Use _Static_assert in gcc/clang.
Hopefully they don't throw warnings at us.
2022-03-27 18:18:33 +00:00
sudden6
bc006beb4e
cleanup: split CMakeLists.txt and add some missing targets 2022-03-27 20:09:10 +02:00