Commit Graph

851 Commits

Author SHA1 Message Date
iphydf
478ef39b39
test: Add some support functions to make writing fuzzers easier. 2022-03-27 18:43:41 +00:00
sudden6
bc006beb4e
cleanup: split CMakeLists.txt and add some missing targets 2022-03-27 20:09:10 +02:00
sudden6
48fb45887f
try to save the fuzzed save file again
This should test some additional code paths.
2022-03-26 14:09:04 +01:00
iphydf
1928704065
test: Add fuzzer tests to the bazel build. 2022-03-25 18:48:41 +00:00
iphydf
2dcb946e62
cleanup: Reduce scope of array-typed variables where possible.
Cimple cannot actually find these without also causing false positives,
but I found them with cimple before removing the code causing false
positives again.
2022-03-21 12:02:46 +00:00
iphydf
c3a938e38c
cleanup: Avoid memset on structs.
Most of these were safe (some were not), but even the safe ones can
become unsafe (non-portable) later on when adding pointer or float members.
2022-03-19 12:32:36 +00:00
iphydf
cff9a18e39
cleanup: Split util.c out of the network library.
Also, don't include ccompat.h in header files. Instead, explicitly
include it in .c files.
2022-03-04 10:33:11 +00:00
iphydf
163e9c3b03
cleanup: Remove more boolean conversions (and a bugfix).
These were found by the new stronger type check in cimple. The one
bugfix is in `crypto_sha512_cmp`, which used to think `crypto_verify_32`
returns bool while actually it's -1/0/1.
2022-02-26 00:03:56 +00:00
iphydf
093927ba4f
test: Add mallocfail and proxy test to our coverage runs. 2022-02-25 01:55:28 +00:00
sudden6
e42441e3cf
chore: remove DHT_test.c since it's unused 2022-02-22 22:30:27 +01:00
iphydf
6be655c56c
cleanup: Return boolean constants, not ints from bool functions. 2022-02-22 17:50:17 +00:00
iphydf
b7f95bbe70
cleanup: Remove any disallowed casts.
The ones in toxav weren't needed. The ones in network.c are
non-trivially correct. Now, the code is more easily verifiable.
2022-02-22 02:19:29 +00:00
iphydf
f98137d697
refactor: Move tox_new_log to auto_test_support.
This is only used in auto tests.
2022-02-21 17:39:10 +00:00
iphydf
86a528a37a
chore: Add a .clang-format that mostly agrees with astyle. 2022-02-21 16:16:16 +00:00
iphydf
6a6bc029de
cleanup: Remove unused execution trace library. 2022-02-19 11:44:13 +00:00
iphydf
84a03bc2ed
cleanup: Enable tokstyle's -Wlarge-struct-params. 2022-02-18 10:49:46 +00:00
iphydf
7b2f6c34c6
cleanup: Apply stronger type checks and fix errors.
Found a bug, too: file recv and chunk events were intermittently
converting to `uint32_t`, losing precision.
2022-02-17 22:34:56 +00:00
Maxim Biro
25216f86e7
Don't attempt to install the same package twice 2022-02-13 22:54:10 -05:00
sudden6
acf85eee46
fix: remove bogus asserts in fuzzer harness 2022-02-14 00:38:42 +01:00
iphydf
a3cd1102f7
perf: Reduce minimal encoding size of packed events.
We're using a union-like encoding now with an enum telling which union
member to set.
2022-02-12 17:44:44 +00:00
iphydf
10f86f6c00
cleanup: Add more nonnull and nullable annotations. 2022-02-09 20:03:34 +00:00
iphydf
2ed9b1927f
doc: Add doxygen configuration and netlify publishing. 2022-02-05 15:59:45 +00:00
jfreegman
5619b5e056
Make more functions take const pointers to IP_Port
We additionally now make local copies of the IP_Port param instead
of modifying the passed argument
2022-02-03 11:17:29 -05:00
iphydf
fcabbd2ed4
chore: Disable some cimple warnings for now.
So we can push the latest cimple to toktok-stack and then start fixing
the warnings.
2022-02-03 01:50:23 +00:00
iphydf
5fbcbb6c83
cleanup: Remove uses of strcpy and sprintf.
Use of `strcpy` in these particular cases was safe, but it's hard to
tell and also useless. `strcpy` would effectively need to do another
`strlen` which we already did.

Also removed sprintf, which was also safe in this case but it's easier to
be "obviously safe", especially for static analysers.
2022-01-17 18:25:40 +00:00
iphydf
044ae636a3
chore: Mark unsafe code as testonly.
We want to ensure that nobody links against testing code in production.
2022-01-16 09:10:53 +00:00
iphydf
685b78d31d
chore: Add asan/tsan bazel builds.
These have all dependencies built with asan/tsan, so they can do deeper
sanity checks such as checking what opus is doing with our buffers.

The asan check currently fails for me locally, so these are not yet set
to be required for PRs to be merged.
2022-01-12 20:33:21 +00:00
jfreegman
360acd0f42
Replace all instances of atoi with strtol
atoi doesn't check if the conversion from string to int succeeded
which doesn't allow us to do proper error handling.

We also now make sure that the port argument is a valid port
in addition to being properly converted
2022-01-12 14:08:45 -05:00
iphydf
9b7279ab24
chore: Run tokstyle with 3 cores.
This seems to be the sweet spot for the current tokstyle implementation.
4 cores gives the same speedup, 5 also, 6 makes it slower, and 2 also
makes it slower.
2022-01-12 18:52:46 +00:00
iphydf
c1b32bd7a1
chore: Enable compiler layering check.
This ensures that we're explicit about what we depend on and avoids
transitive dependencies.
2022-01-11 15:26:32 +00:00
sudden6
e04b890817
add scripts to run the fuzzing process
This adds scripts and Dockerfiles to run the fuzzing process standalone
or with OSS-Fuzz/ClusterFuzzLite integrations.
2022-01-10 21:05:51 +01:00
sudden6
7dd8dbd897
intercept network, crypto and time
This fuzzing harness must be as deterministic as possible for the fuzzer
to detect additional coverage reliably.
2022-01-10 21:05:49 +01:00
sudden6
9eb88798a3
add fuzzing harnesses
Toxsave harness ported to libFuzzer interface.
New harness for bootstrap phase.
2022-01-10 20:57:00 +01:00
zugz (tox)
64a48c0e78
cleanup: Remove hardening code from DHT 2021-12-30 00:00:01 +00:00
iphydf
6b75f8b889
chore: Remove config.h.
This aligns the autotools build with the cmake build, which doesn't have
a config.h file. It also removes the ambiguity of config.h and
other/bootstrap_daemon/src/config.h.
2021-12-15 10:26:50 +00:00
iphydf
74bc87f277
test: Make ERROR logging fatal in tests.
This doesn't currently work, because we get a lot of errors during tests.
This should not happen. Either those errors are warnings, or something is
wrong with either the code or the test.
2021-12-14 13:00:25 +00:00
iphydf
5c53e6a30f
chore: Add autotools build; exempt crypto_pwhash from tokstyle. 2021-12-13 18:47:45 +00:00
iphydf
cdc0286050
cleanup: Minor fixes in test code.
* Buffer overrun in auto test.
* Resource leak in AFL test code.
2021-12-07 17:13:58 +00:00
iphydf
d930ecca4c
chore: Run infer static analyser on circle ci builds.
Also running some other analysis that we used to have on Travis.
2021-12-06 20:25:50 +00:00
iphydf
f8ab32aaa4
Add a check that we don't have any unused functions.
This check puts all of our code in a C++ anonymous namespace, which is
effectively making all functions `static`. This allows the compiler to
determine that a function is unused, so we can delete it.
2020-05-02 22:00:09 +01:00
iphydf
f3c6fc6771
Add execution trace option for debugging.
Use `cmake -DEXECUTION_TRACE=ON` to use it.
2020-04-27 23:10:27 +00:00
iphydf
f0ae0511c2
Make afl_toxsave.c a bit more portable; fix memleak.
malloc.h doesn't exist on most platforms, and certainly not in stdc. No
functions from malloc.h are actually used here, and stdlib.h is enough.
2020-04-05 09:08:44 +00:00
sudden6
6732e5ef2f
Add basic test adapter for AFL 2020-03-24 16:49:41 +01:00
iphydf
11ad5471b9
Use spdx license identifier instead of GPL blurb. 2020-03-14 13:06:19 +00:00
iphydf
e671490989
Use rules_cc instead of native cc_library rules. 2020-03-12 12:20:54 +00:00
iphydf
28baf9632f
Remove testing/av_test.c.
It's a maintenance burden. Nobody uses this. It depends on an ancient
version of opencv that less and less systems actually have.
2020-03-02 21:07:55 +00:00
iphydf
0f7138c010
Upgrade bazel to 2.1.1.
Removed av_test, because it depends on an ancient opencv that starts to
really not exist on modern systems anymore.
2020-03-02 14:23:44 +00:00
zugz (tox)
744dc2f5da
Make saving and loading the responsibility of Tox rather than Messenger 2018-10-20 11:03:10 +02:00
iphydf
700accb3c7
Use bool for IPv6 flag in test programs and DHT_bootstrap. 2018-10-16 22:11:53 +00:00
iphydf
605dfe882c
Consistently use camel case enum names.
Including in tests and implementation files.
2018-10-09 17:33:37 +00:00
yangfl
d3d5b701cb
Fix typos 2018-09-19 18:16:13 +00:00
iphydf
f59e6ff0cb
Ignore "unused-result" warning in super_donators code. 2018-09-06 13:28:08 +00:00
iphydf
6872c14e1a
Avoid use of global mutable state in mono_time on win32.
This uses a trick to get read-write access to `this` from a `const`
member function, similar to C++ `mutable`, but uglier.
2018-09-03 20:03:47 +00:00
iphydf
515196dfa2
Include necessary opencv2 header on OSX.
opencv2 is deprecated and homebrew ships with opencv3 now.
2018-08-30 21:11:17 +00:00
iphydf
473cde24d8
Update copyright to 2018. 2018-08-26 18:57:29 +00:00
iphydf
a1035cf814
Add some tests for ping_array.
No timeout test here yet, because we don't yet have the ability to
manipulate time at will, so we would have to actually sleep.
2018-08-26 17:32:19 +00:00
zugz (tox)
8e0aea1add
handle libsodium dependency of misc_tools correctly for autotools 2018-08-20 22:36:15 +02:00
zugz (tox)
14484c6879
make Mono_Time an argument to current_time_monotonic 2018-08-19 23:41:43 +02:00
endoffile78
30960dcc7e
Add save file generator, save compatibility test, and generate a save file 2018-08-19 10:38:51 +00:00
iphydf
9fb87056bc
Set _POSIX_C_SOURCE to 200112L. We need it for C99 compat.
It is invalid to compile an XPG3, XPG4, XPG4v2, or XPG5 application
using c99.  The same is true for POSIX.1-1990, POSIX.2-1992, POSIX.1b,
and POSIX.1c applications. Likewise, it is invalid to compile an XPG6
or a POSIX.1-2001 application with anything other than a c99 or later
compiler.  Therefore, Solaris libc forces an error in both cases.
2018-08-17 22:43:24 +00:00
iphydf
d6d305feeb
Use per-instance Mono_Time for Messenger and onion. 2018-08-16 21:01:43 +00:00
iphydf
54066f338f
Reduce the number of times unix_time_update is called.
Reduced by, e.g.:
* `file_transfer_test`: 33% of the `clock_gettime` calls.
* `tox_many_test`: 53% of the `clock_gettime` calls.

Other tests will see similar improvements. Real world applications will
be closer to 40-50% improvement, since tox_many_test has 100 nodes, while
file_transfer_test has 2 nodes.
2018-08-16 21:01:38 +00:00
crypto-universe
3036cc1f23
Fix possible resource leaks in test 2018-08-15 22:50:24 +00:00
iphydf
a509d25324
Fix some printf format specifiers. 2018-08-13 11:02:32 +00:00
zugz (tox)
fb89c03dd2
Add simple deterministic random number generator for tests 2018-08-12 15:22:34 +00:00
iphydf
3fe0551417
Assert that we don't divide by 0 in random_testing.cc.
This is always true due to the condition function, but if we introduce a
bug that makes the condition not be applied, this causes undefined
behaviour.
2018-08-12 14:52:52 +00:00
iphydf
d92c96e783
Fix a few warnings from clang.
Also remove the use of a VLA in a context where there can be unbounded
memory allocations.
2018-08-12 14:09:59 +00:00
iphydf
f627a26a7b
Run Clang global static analysis on Travis.
This uses a single .cc file containing almost all the code in the
repository to perform whole program analysis.
2018-07-22 02:34:30 +00:00
iphydf
7245ac11ef
Avoid implementations in .h files or #including .c files.
Also, avoid the need for putting `_XOPEN_SOURCE` in every test file.
2018-07-21 20:44:26 +00:00
iphydf
abc17b0f89
Factor out time keeping code into its own module: mono_time.c.
It turns out, `unix_time` is also monotonic, and is used as such, so I've
renamed the new functions to `mono_time_*`.

2018-07-08:
```
00:01 <@irungentoo> the idea used to be that the unix_time() function
  could go backward in time but I think I might have started using it like
  if it could not after I changed it so that it would never go back in time
```
2018-07-09 21:04:50 +00:00
iphydf
8739f7fccb
Make tox.c unambiguously parseable.
Rules:
1. Constants are uppercase names: THE_CONSTANT.
2. SUE[1] types start with an uppercase letter and have at least one
   lowercase letter in it: The_Type, THE_Type.
3. Function types end in "_cb": tox_friend_connection_cb.
4. Variable and function names are all lowercase: the_function.

This makes it easier for humans reading the code to determine what an
identifier means. I'm not convinced by the enum type name change, but I
don't know a better rule. Currently, a lot of enum types are spelled like
constants, which is confusing.

[1] struct/union/enum
2018-07-05 23:09:28 +00:00
iphydf
64d0297acc
Add #include <cstdio> for std::printf. 2018-07-04 14:21:12 +00:00
iphydf
b9a75d98b2
Remove broken conference tests.
These display some idea, but the tests are not implemented correctly. We
will need to implement the idea correctly later, but for now we can't use
these.
2018-06-29 18:25:44 +00:00
iphydf
29b2dd6315
Use clang-format for C++ code.
`clang-format -style='{BasedOnStyle: Google, ColumnLimit: 100}'`
2018-06-24 20:17:53 +00:00
iphydf
5c2600d87b
Add new Circle CI configuration.
This one has ASAN enabled, unlike Travis.
2018-06-24 19:51:34 +00:00
iphydf
cfff361679
Add random testing program.
This can be used as a random stress test for toxcore.
Adjust the weights to make certain actions more or less likely.
2018-06-23 12:43:09 +00:00
Maxim Biro
7d399cedcf
Improve network error reporting on Windows
Windows doesn't report network errors though errno, it has its own facilities.
2018-04-17 19:07:50 -04:00
iphydf
fa8927aa0f
Move struct DHT_Friend into DHT.c. 2018-03-16 02:07:39 +00:00
iphydf
aa05095419
Remove the use of the 'hh' format specifier.
It's not supported in mingw.

See https://github.com/TokTok/c-toxcore/issues/786.
2018-03-16 01:57:26 +00:00
iphydf
d3b286cb43
Fix a bunch of compiler warnings and remove suppressions. 2018-02-24 22:20:22 +00:00
zoff99
721358208b
Improve video key frame sending.
This change does not include the addition of VP9. We do that in a
separate pull request.

Changes:

* fix the video bug (video frames larger than 65KBytes) by sending full
  frame length in alternate header field
* improve video frame reconstruction logic with slots
* configure video encoder and decoder to be multihtreaded
* set error resilience flags on video codec
* change encoder and decoder softdeadline
2018-02-11 23:31:46 +00:00
iphydf
36ba80aacb
Remove csrc from the RTPHeader struct.
This is not used by anything in the code, so we shouldn't have it in the
header.
2018-02-08 13:20:40 +00:00
iphydf
52f6e4e7c5
Move tox_shell program to the toxins repository.
https://github.com/TokTok/toxins/tree/master/tox_shell
2018-02-06 13:06:22 +00:00
iphydf
a3a0e553f3
Move irc_syncbot to the toxins repository. 2018-02-06 11:45:50 +00:00
iphydf
f71ec8dd02
Move the tox_sync tool to the toxins repository. 2018-02-05 18:15:31 +00:00
iphydf
92ffad1a72
Use nullptr as NULL pointer constant instead of NULL or 0.
This changes only code, no string literals or comments.
2018-01-30 23:35:50 +00:00
iphydf
6e0ac337c9
Avoid clashes with "build" directories on case-insensitive file systems. 2018-01-28 15:17:34 +00:00
xhe
651ef3adb6
Make audio/video bit rates "properties"
follow TokTok#731. This commit
completely removed all things in namespace bit_rate, and deprecated
functions are to be added back in another commit. set_xxx() is treadted
as a property of namespace audio&video, same as bit_rate change event.

toxav_basic_test is fixed, either.
2018-01-28 13:21:57 +00:00
iphydf
9c03439ad0
Fix out of bounds read in error case in messenger_test.
Also got rid of two VLAs. They are overused a bit in toxcore. In
irc_syncbot, the array was uninitialised and then filled by a recv system
call. This can cause uninitialised reads if recv doesn't fill the entire
array. It could not cause out of bounds read directly, because a
NUL-terminator was in place, but both cases are undefined behaviour.
2018-01-26 01:30:06 +00:00
iphydf
42636861d8
Publish a single public BUILD target for c-toxcore. 2018-01-22 21:18:24 +00:00
iphydf
e6c04ef028
Use self-built portaudio instead of system-provided. 2018-01-22 00:44:19 +00:00
iphydf
52778aed93
Make BUILD files more finely-grained.
This allows us to precisely see which libraries depend on which and lets
us split them up more, if necessary.
2018-01-21 19:44:09 +00:00
iphydf
1cecb6c87a
Add BUILD files for all the little tools in the repo.
Also, fix av_test.c, since I broke it last time.
2018-01-21 01:31:11 +00:00
iphydf
822dd2fac2
Don't allocate or dereference Tox_Options in tests.
This struct will soon become opaque.
2018-01-21 00:14:43 +00:00
iphydf
98febe0589
Add testing/*.c (except av_test) to bazel build. 2018-01-20 19:32:12 +00:00
iphydf
d7583a719a
Remove nTox from the repo.
It's a maintenance burden nobody uses. Let's make toxic the official
console client, instead.
2018-01-20 19:05:53 +00:00
iphydf
18a33169b8
Add bazel build scripts for c-toxcore.
This allows us and users to reproducibly build verified versions of the
library with checksums. It will power the toktok-stack continuous build
with checked-in checksums at specific git revisions.
2018-01-18 16:11:52 +00:00
iphydf
643eea60bb
Make DHT a module-private type. 2018-01-16 20:06:07 +00:00
iphydf
cec5fea71b
Remove hstox test for now.
This isn't adding value. We're going to redo the whole rpc test framework
in the future, after a lot of refactoring that the hstox test currently
just stands in the way of.
2018-01-15 11:29:51 +00:00
iphydf
1eea3f0ab6
Fix some memory or file descriptor leaks in test code.
Also some missing return value checks for `fopen`.
2018-01-14 19:15:28 +00:00