Commit Graph

566 Commits

Author SHA1 Message Date
iphydf
a549807df7
refactor: Add mem module to allow tests to override allocators.
This will allow us to do more interesting things with memory allocation
within toxcore, and allow fuzzers to explore various allocation failure
paths.
2023-08-30 22:55:05 +00:00
iphydf
a1e2458412
docs: Fix doxygen config and remove some redundant comments.
Doxygen doesn't like these. We should probably remove all redundant
comments, but this was the set of comments doxygen complained about.
2023-08-16 07:53:19 +00:00
iphydf
2e02d56379
chore: Add missing module dependencies.
Also flip some callback asserts, because they can be reached by fuzzing
eventually.

Also update the bootstrapd checksum, since the alpine image changed a
bit.
2023-08-10 21:01:17 +00:00
iphydf
bff87ea8e4
cleanup: Avoid goto in msi.c. 2022-04-14 21:22:17 +00:00
iphydf
3576df9d79
chore: Add MISRA-2012 check using cppcheck's misra addon.
Disabled a whole bunch of rules from the MISRA-C set. Some of them
should be fixed, but most of the ones we violate have good reasons. This
PR documents those reasons.
2022-04-04 20:29:54 +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
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
6749974470
cleanup: Expose struct Tox to internal code.
To avoid unsafe casts that tokstyle doesn't allow and that can cause
random breakages.
2022-03-26 21:15:31 +00:00
iphydf
1fc05ce616
cleanup: Reduce scope of variables as requested by cimple. 2022-03-20 23:24:09 +00:00
iphydf
28623dcfa9
fix: Eliminate memory leak in toxav.
This happens when shutting down a toxav session when it still has some
packets in its internal queue. It's not a serious leak and happens very
rarely (1 in 300 runs of the toxav_many_test), but it can happen and
long-running tox instances that start and end calls a lot would
eventually discover this.
2022-03-15 17:19:44 +00:00
iphydf
83c9c0bd85
cleanup: Move all the group.h structs into group.c.
Almost nothing used these. The one thing that did only does it to get a
`Mono_Time` object. We should probably get that from elsewhere, but for
now the refactoring is just this simple move.
2022-03-13 17:49:50 +00:00
iphydf
e1e92c1ac1
docs: Clean up doxygen comments to be more doxygen-like. 2022-03-05 22:30:48 +00:00
iphydf
3275bb8fea
cleanup: Add explicit callback setters for MSI callbacks.
Instead of a callback ID and a `switch`.
2022-03-04 10:33:23 +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
64254d6459
cleanup: Don't reference local variables in macro bodies.
Tokstyle enforces this now.
2022-03-03 00:45:34 +00:00
iphydf
c20f878934
cleanup: Remove some more implicit bool conversions.
Also removed one explicit bool cast.
Also avoid using the same name for struct fields and global functions.
2022-03-01 18:16: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
cad7cf8344
cleanup: Remove superfluous parentheses on the rhs of assignments. 2022-02-25 01:02:11 +00:00
iphydf
2ce6f5b169
fix: Report failure to DHT bootstrap back to the client.
Also reduce log verbosity a bit.
2022-02-24 11:37:47 +00:00
Robin Linden
0ac930e1f6
cleanup: Clean up comparing bools with ints 2022-02-23 22:50:12 +00:00
Robin Linden
0ca2882b92
cleanup: Remove yet more implicit bool conversions 2022-02-23 22:00:46 +00:00
iphydf
b13590a86d
cleanup: Mark all local non-pointers as const where possible. 2022-02-23 19:30:01 +00:00
iphydf
70d75ae9a3
cleanup: Remove implicit conversions from uint32_t to bool. 2022-02-22 23:25:23 +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
e7bc611dac
cleanup: Enable most cppcheck warnings as errors.
Cleaned up some of the warnings it gives. Disabled the ones that are
less useful for us at this time.
2022-02-21 17:17:36 +00:00
iphydf
86a528a37a
chore: Add a .clang-format that mostly agrees with astyle. 2022-02-21 16:16:16 +00:00
iphydf
a9ccf1be26
cleanup: Remove all implicit bool conversions in if-conditions.
Note to reviewer: please review carefully. This was done manually.
2022-02-21 15:10:22 +00:00
iphydf
87c38ece30
cleanup: Avoid implicit bool conversions in logical operators. 2022-02-18 10:24:31 +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
iphydf
5e724d8909
cleanup: Avoid implicit pointer-to-bool conversion in if in toxav. 2022-02-17 20:33:24 +00:00
Robin Linden
f87a6df938
cleanup: Split msi callback array into 1 member per callback 2022-02-06 15:45:24 +01:00
iphydf
d39f803c7e
docs: Make crypto_core.h appear on doxygen. 2022-02-05 19:34:13 +00:00
iphydf
2ed9b1927f
doc: Add doxygen configuration and netlify publishing. 2022-02-05 15:59:45 +00:00
iphydf
7f0395b746
chore: Make the last few remaining top level comments doxygen style. 2022-02-04 23:25:45 +00:00
iphydf
1859d0f44a
cleanup: Ensure we limit the system headers included in .h files.
Most system headers contain functions (e.g. `memcpy` in `string.h`)
which aren't needed in our own header files. For the most part, our own
headers should only include types needed to declare our own types and
functions. We now enforce this so we think twice about which headers we
really need in the .h files.
2022-02-04 20:54:37 +00:00
jfreegman
da4ef6481e
Add some toxav bounds/sanity checks 2022-01-31 14:46:08 -05:00
jfreegman
791fd01349
Make some non-const pointers const 2022-01-29 11:14:56 -05:00
jfreegman
ade11eb35d
Fix group av memory leak
Introduced in 762a601
2022-01-22 14:52:05 -05:00
jfreegman
762a6017f9
Refactor group audio packet data handling
We now malloc and free the data field separately. This increases
readability of the code and gets rid of static analyzer false
positives.
2022-01-17 19:01:51 -05:00
iphydf
7f94e411a9
chore: Add cpplint to the CI. 2022-01-17 23:42:38 +00:00
iphydf
f7557b4c16
cleanup: Even more pointer-to-const parameters.
I missed these the first time around.
2022-01-16 02:35:08 +00:00
iphydf
6823fcbae1
cleanup: Stop using strerror directly.
We have a more portable wrapper that is now also thread-safe. Also
stopped using sprintf in the one place we used it. This doesn't really
help much, but it allows us to forbid sprintf globally.
2022-01-15 01:25:56 +00:00
jfreegman
dfa7a0183f
Refactor toxav_call_control
Control logic is now placed in control-specific helper functions
instead of having one giant confusing function that does everything
2022-01-13 17:50:39 -05:00
iphydf
4a2cb37e4b
fix: Fix some uninitialised memory errors found by valgrind and msan.
Also added a valgrind build to run it on every pull request. I've had to
disable a few tests because valgrind makes those run infinitely slowly,
consistently timing them out.
2022-01-13 20:15:21 +00:00
Maxim Biro
ce4b01df94
Fix the compiled out code too
Has the same double-unlock issue as the previous commit.

It also looks like rtp_free_msg() is gone and free() should be used
instead.
2022-01-12 10:49:33 -05:00
Maxim Biro
dbcfc8265e
Fix a double-unlocking mutex
Fixes #1694

Thanks to @ryancaicse for the pointer!
2022-01-12 10:49:30 -05:00
iphydf
cfb0aa8f25
cleanup: Remove extra parens around function arguments. 2022-01-12 07:02:29 +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
iphydf
9ab77e015d
cleanup: Fix calloc argument order.
See https://github.com/TokTok/hs-tokstyle/pull/102
2022-01-09 18:42:20 +00:00
jfreegman
0385315200
Make struct typedefs have the same name as their struct 2022-01-04 11:36:28 -05:00