- Fix a potential division by zero crash in `toxav/audio.c` when
`lp_sampling_rate` is 0.
- Fix unsafe hex string parsing in `bootstrap_daemon/config.c` that
could leave variables uninitialized (replacing `sscanf` with a safe
helper).
Also address various clang-tidy findings:
- Enforce const correctness and fix implicit bool conversions in
`toxav`.
- Sort includes in `toxav`.
Instead of transitively loading them from dependencies, we should be
explicit about what each object needs. The downside of this is that it's
not clear whether the object and its dependency use the same common
dependency. The upside is that we don't expose those getters of internal
dependencies.
Allows clients to prevent leaking IP addresses through DNS lookups. This
option, together with disabling Tox UDP, entirely prevents any UDP
packets being sent by toxcore.
A continuation of the cleanup done in
b7404f24f6.
tox-bootrstrapd historically had used ints for boolean values, as it was
initially written in C89 which has no stdbool.h. Since then it has
modernized and moved on to using C11, but the usage of the int type to
represent boolean values, "boolean ints", remained. Recently, driven by
a desire to eliminate implicit int-to-bool conversion, @iphydf did a
cleanup in b7404f24f6, changing some of
the boolean ints to bools and doing manual int-to-bool conversion on the
remaining boolean ints. This left the codebase in an inconsistent state
of both ints and bools now being used to represent boolean values, not
to mention that the explicit int-to-bool conversions are a bit ugly. The
only boolean ints that remained are those stemming from libconfig's
config_lookup_bool() taking an *int parameter to return a boolean value,
as libconfig still uses C89. This commit adds a wrapper function around
libconfig's config_lookup_bool() that takes a *bool instead, eliminating
the remaining boolean ints and majority of the explicit int-to-bool
conversions in tox-bootstrapd.
Also started teaching it about toxcore's alloc/dealloc functions in
hopes of it catching some errors (it doesn't seem to be very good at
this, but maybe better than nothing?).
We now depend on libsodium unconditionally. Future work will require
functions from libsodium, and nobody we're aware of uses the nacl build
for anything other than making sure it still works on CI.
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.
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.
As a side-effect, DHT now always accepts LAN discovery packets, even
when LAN discovery is disabled. When LAN discovery is disabled, those
packets are ignored.
It was kind of thread-safe, maybe, but there was a data race that makes
tsan unhappy. We now do interface detection once per Tox instance
instead of once per process.
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.