Commit Graph

5123 Commits

Author SHA1 Message Date
jfreegman
96814c4645
Use proper method for generating random numbers in a range
Using modulus creates a bias in its output. The libsodium
randombytes_uniform() function guarantees a uniform distribution
of possible outputs
2022-02-05 11:14:45 -05: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
13e4ff47fe
chore: Sync all comments between header and source files. 2022-02-04 22:43:02 +00:00
iphydf
074051078d
chore: Make all top level comments doxygen style /**.
This allows tokstyle to match them between header and source.
2022-02-04 22:43:02 +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
Maxim Biro
cda6c9b6e8
Fix potential freeing of an immutable static buffer
strerror_r() has two versions: GNU-specific and XSI-compliant. The XSI
version always stores the string in the provided buffer, but the GNU
version might store it in the provided buffer or it might use some
immutable static buffer instead. Since we always free the error string,
we might end up freeing the immutable static buffer.
2022-02-04 08:09:14 -05:00
iphydf
28dc8c1ded
cleanup: Don't pass the whole DHT object to lan discovery.
It only needs net and dht public key.
2022-02-03 20:50:36 +00:00
iphydf
014cc42249
chore: Make run-infer script use docker.
So people can run it locally more easily.
2022-02-03 20:11:16 +00:00
jfreegman
1d3778fc53
Move duplicate code for converting IPv4-in-6 to IPv4 to a function 2022-02-03 12:32:30 -05: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
jfreegman
5880971af8
Make functions take const pointer to IP_Port wherever possible
An IP_Port is a fairly large data structure, and copying them down
the call stack creates a lot of unnecessary overhead.
2022-02-03 10:54:48 -05:00
jfreegman
3a72ed5fae
Properly copy Node_format using serialized format
Also fix a bad comment
2022-02-02 22:00:06 -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
71965a0f3b
feat: Add WASM build for toxcore and websocket bootstrap node.
The websocket bootstrap node will be running on Heroku.
2022-02-02 16:05:25 +00:00
iphydf
727982d2f9
fix: Fix bootstrap on emscripten/wasm.
Also added a whole bunch of logging that I needed while debugging the
issue. The solution in the end is that bootstrap needs to resolve IPs,
and getaddrinfo fails in the browser. Most of the time we bootstrap
against IPs anyway, so trying to parse as IP address first will shortcut
that.
2022-02-01 21:00:09 +00:00
jfreegman
da4ef6481e
Add some toxav bounds/sanity checks 2022-01-31 14:46:08 -05:00
jfreegman
95d0f5ccbe
Use latest toktok-stack msan version 2022-01-31 14:32:50 -05:00
iphydf
2e7c5b4b24
chore: Use latest instead of versioned toktok-stack image. 2022-01-30 19:15:30 +00:00
iphydf
b6f48b3b7d
chore: Rename bazel-release to -opt and -debug to -dbg. 2022-01-29 22:21:13 +00:00
jfreegman
52c31efb97
Small refactor of DHT getnodes function 2022-01-29 16:52:25 -05:00
jfreegman
3f4ea3d5fd
Remove brackets from ip_ntoa ipv6 formatting
The brackets serve no purpose and make us do extra string
parsing when using the output for other things

Also removed a useless call to ip_ntoa in LAN_discovery.c
2022-01-29 15:29:14 -05:00
iphydf
2b783c4170
chore: Don't run sonar scan on pull requests.
This reverts commit e3d20afc6a.

It doesn't work.
2022-01-29 16:29:50 +00:00
jfreegman
791fd01349
Make some non-const pointers const 2022-01-29 11:14:56 -05:00
jfreegman
8c3bd7fc35
Fix some unintentional integer down-casts
None of these currently cause any bugs from what I
can see, but they're still incorrect.
2022-01-28 09:57:17 -05:00
Robin Linden
2cfa872818
Add a Bazel Buildifier CI job 2022-01-28 00:55:07 +01:00
Maxim Biro
b2ea0e5c76
Add programs for creating savedata & bootstrap keys 2022-01-27 16:31:07 -05:00
jfreegman
d2f98b83c2
Fix some minor issues with autotests
- Do null check on autotox pointer for all public functions
- Reverse argument order: autotoxes -> count instead of opposite
2022-01-26 10:27:41 -05:00
zugz (tox)
1157e4e68c
Separate run_auto_tests into a library 2022-01-25 14:25:36 -05:00
Tha14
5a88159b8f
Pass "b" for fopen to fix bugs on windows 2022-01-24 16:00:01 +02:00
jfreegman
ade11eb35d
Fix group av memory leak
Introduced in 762a601
2022-01-22 14:52:05 -05:00
jfreegman
10d59d610b
Refactor autotest live network bootstrapping
- Use one node list and public bootstrap function for all autotests
- Use ifdefs for testnet/mainnet nodes
- Replace a few broken nodes with working ones
2022-01-22 11:24:28 -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
e3d20afc6a
chore: Run sonar scan on pull requests. 2022-01-17 23:23:14 +00:00
jfreegman
fc18810ba8
Fix buffer overwrite in bootstrap config 2022-01-17 17:56:47 -05:00
iphydf
fdadcb0a90
chore: Add a make_single_file script, used for CI.
This will also be used for static analysers that can't deal with multiple
source files.
2022-01-17 21:12:25 +00:00
jfreegman
c5c8aeeefe
Replace magic numbers with appropriately named constants 2022-01-17 13:55:56 -05:00
iphydf
9dfad80017
cleanup: Remove our only use of flexible array members in toxcore.
We still have them in toxav. That will need to be cleaned up later.
Flexible array members have very limited usefulness. In this particular
case, it's almost entirely useless. It confuses static analysers and is
yet one more C feature we need to understand and support. It is also the
only reason we need special support in tokstyle for calloc with a `+`
operator in the member size.
2022-01-17 18:37:16 +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
2856943531
chore: Expose public API headers as files in bazel.
They were already exposed as `cc_library`, but we need to make the files
as text available so that binding generators can access them.
2022-01-17 01:03:47 +00:00
iphydf
4ce02c0af9
refactor: Deduplicate a bunch of code in TCP client/server.
Also generally a bit of cleanup and better layering.
2022-01-16 09:41:08 +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
f52bc798c8
cleanup: Split large switch statement into functions. 2022-01-16 02:45:24 +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
c7ecee7c15
cleanup: Remove old check Suite compat layer.
This doesn't do anything useful for us. It was there so we don't need to
rewrite the tests (which I just did). Finally this is now cleaned up.
2022-01-16 01:37:37 +00:00
iphydf
422c8d1125
cleanup: Make parameters pointers-to-const where possible. 2022-01-16 01:28:25 +00:00
iphydf
09bb9b8a23
cleanup: Make Networking_Core pointer-to-const where possible. 2022-01-16 01:09:44 +00:00
iphydf
c081a50201
cleanup: Use pointer cast instead of memcpy in qsort callback.
No need to make copies of the data. There is no concurrency in qsort.
2022-01-16 00:12:44 +00:00
iphydf
0d27eb2f90
cleanup: Deduplicate a somewhat complex loop in DHT.c. 2022-01-15 21:25:14 +00:00