Commit Graph

603 Commits

Author SHA1 Message Date
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
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
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
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
Tha14
5a88159b8f
Pass "b" for fopen to fix bugs on windows 2022-01-24 16:00:01 +02:00
iphydf
7f94e411a9
chore: Add cpplint to the CI. 2022-01-17 23:42:38 +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
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
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
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
iphydf
2671095f4a
cleanup: Merge crypto_core and crypto_core_mem.
The remaining memory functions are small and don't need their own file.
2022-01-15 01:34:14 +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
iphydf
8d19757f8e
chore: Add mypy Python type check.
Also fix the types in all Python files.
2022-01-14 19:55:37 +00:00
iphydf
d23222c92f
chore: Run static analysers in multiple variants.
Currently: 1) libsodium and 2) nacl.

Note that the "nacl" variant is actually libsodium. We just want to make
sure the static analysers see the `VANILLA_NACL` code paths.
2022-01-14 10:45:11 +00: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
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
f5f22a5c76
chore: Enable layering check in all c-toxcore build files. 2022-01-12 18:33:13 +00: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
eebc516d55
chore: Disable the OpenMP cracker in bazel for now.
I broke it. I'll re-enable it if/when I fix omp support in the bazel
build.
2022-01-11 13:29:53 +00:00
sudden6
faf39ef94f
update tox-bootstrapd.sha256
__LINE__ macros were changed due to inserting #ifdef
2022-01-10 21:05:51 +01: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
iphydf
f46f51e554
cleanup: Don't use memcpy where assignment can be used.
See https://github.com/TokTok/hs-tokstyle/pull/104.
2022-01-10 10:58:42 +00:00
Robin Linden
23df660fd2
Remove always-true check in receivepacket error handling 2022-01-10 02:27:13 +01:00
iphydf
5ab301ecab
chore: Remove all references to Travis CI.
Travis gave up on FOSS, so no more free advertisement for Travis.
2022-01-10 01:17:46 +00:00
iphydf
73484d8995
cleanup: Use calloc instead of malloc for struct allocations.
`malloc` is used only for byte/int arrays. Also, we no longer allow plain
`void *` allocations. Every allocation should have a real value type.
2022-01-09 22:42:50 +00:00
iphydf
83d5d0d280
cleanup: Remove useless parentheses. 2022-01-06 20:36:03 +00:00
iphydf
e848853968
chore: Remove old travis docker scripts.
These aren't useful anymore. We don't have travis anymore, so there's no
need to simulate the travis CI environment.
2022-01-02 19:41:46 +00:00
jfreegman
7318127dca
Remove dead code
Neither of these clauses can ever be reached.

Also attempt to fix travis Windows build
2022-01-01 19:44:11 -05:00
iphydf
8cd4827a14
cleanup: Reduce the scope of for-loop iterator variables.
Found by tokstyle after https://github.com/TokTok/hs-tokstyle/pull/95.
2022-01-01 03:26:41 +00:00
iphydf
6f61de54d3
chore: Add "tcc" and "compcert" compiler targets.
It's nice we are able to compile with `tcc`. Let's not break that.
CompCert is also neat, but its interpreter mode doesn't work on tox, so
we only use the compiler.
2021-12-30 23:09:23 +00:00
iphydf
1e11865c4c
chore: Add bootstrap daemon docker image build.
This will also push to dockerhub on merge.
2021-12-23 15:54:24 +00:00
iphydf
ac5df0692c
chore: Add docker image for running circleci/cmake-{asan,tsan}.
Use `make asan` or `make tsan` to run a similar setup to the one we run
on circleci.
2021-12-22 10:14:16 +00:00
iphydf
74bf0fc2c8
chore: Disable -Wmissing-braces.
This flag isn't helpful for the most common case of aggregate
initialisation, namely `{0}`. We don't want to be writing `{{{0}}}` with
some brittle number of braces.
2021-12-21 12:04:04 +00:00
iphydf
4746a8b3af
cleanup: Remove apidsl; remove crypto_memcmp.
* `crypto_memcmp` was replaced by more specific functions. We never want
  to compare arbitrary amounts of data this way. We use these functions
  to compare key material.
* apidsl has been bothering people, so now we un-bother them. You're
  welcome.
* Added the memlock/unlock functions from the New Group Chats branch.
* Remove some system dependencies in crypto_core_mem.c.
* Renamed UPPERCASE_NAMES to Snake_Camel_Case names.
2021-12-19 19:22:38 +00:00
jfreegman
a42b0d62ae
Fix format-source
APIDSL no longer works with these header files
2021-12-17 16:00:59 -05:00
sudden6
b14d9328b4
update build scripts 2021-12-17 20:34:13 +01:00
sudden6
828312c2f9
perf: improve speed of cracker.c
- more inteligent secret key generation
- use OpenMP for multithreading
- leave old cracker, because it's simple
- update old cracker to new coding style
2021-12-17 20:11:18 +01:00
iphydf
2ba2cbd8e9
chore: Fix gen-file.sh: it wasn't globbing properly.
Also fix crypto_core_test.cc to comply with the stack frame limit.
2021-12-14 21:26:52 +00:00
iphydf
cd83c9282c
chore: Add .cc files to the static analysis. 2021-12-14 19:33:18 +00:00
iphydf
5c1796d3c4
chore: Use docker for the autotools ci build.
This makes it easier to run it locally for testing and ensures the
dockerfile continues to work.
2021-12-14 15:51:51 +00:00
Maxim Biro
064ec836fe
Make CodeFactor happy 2021-12-14 08:55:53 -05:00
Maxim Biro
805858716e
Fix file permission issue in toxchat/bootstrap-node
/var/lib/tox-bootstrapd on the host is owned by hosts's tox-bootstrapd
and chowned 700, but the container attempts to access it as its own
tox-bootstrapd user with possibly different uid:gid, which will fail if
host's tox-bootstrapd user has different uid:gid than the tox-bootstrapd
user inside the container.

This change makes the container use host's tox-bootstrapd uid:gid, which
fixes the issue.
2021-12-14 08:55:52 -05:00
Maxim Biro
0538273479
Update base images of toxchat/bootstrap-node 2021-12-14 08:55:48 -05:00
iphydf
30c939e4ab
cleanup: Fix some clang-tidy warnings and make them errors.
The android warnings are disabled now because they suggest using
linux-only extensions of libc. Useful for android indeed, but we're
targeting non-android and non-linux systems as well.
2021-12-10 15:21:27 +00:00
iphydf
fd91bbdd7b
test: Add a simple test for ip_ntoa.
Just to demonstrate that it will never exceed its input buffer.
2021-12-09 20:51:15 +00:00
Maxim Biro
4e8e556a93
Fix previous refactor
Includes should be sorted alphabetically and null-terminating is
unnecessary with snprintf.
2021-12-09 13:23:06 -05:00
jfreegman
edf9d66717
Add logger to onion and onion announce objects
This will be used in the future
2021-12-07 13:01:15 -05:00
iphydf
1ce6aab5da
cleanup: Ensure that error codes are always initialised.
In this case, there was no way it would not be, but a code change down
the stack could cause a variable to become uninitialised. This avoids a
gcc warning and is more locally-correct.
2021-12-07 15:12:42 +00:00
iphydf
101e235131
cleanup: Fix last instance of -Wcast-align and enable the warning.
We used to have lots of these in the code, but now that all the endian
stuff is no longer dependent on host byte order, we can re-enable the
warning flag and catch any future violations.
2021-12-07 14:51:31 +00:00
iphydf
2db6599be5
test: Add some simple tests for list.c.
These are pretty useless, but I'm adding the list_test.cc file for future
better tests to be written in.
2021-12-07 10:32:45 +00:00
Robin Linden
4348b96a5b
Release 0.2.13 2021-12-06 23:28:52 +01: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
sudden6
0320e2eb8e
fix missing braces in computed macro value
Using this value in any computation might not work as expected.
2021-12-05 14:20:04 +01:00
Maxim Biro
0d5f85485b
Update deps used in Windows build scripts 2021-02-25 13:59:18 +03:00
redmanmale
98c148179f
Add Cygwin build script 2021-02-25 13:57:42 +03:00
jfreegman
00f2f41dbb
Use heap memory instead of stack for large variables
The default stack size for musl-libc is 128kb. Therefore we should try to keep stack
allocations well below this limit in order to avoid stack overflows.
2020-11-20 19:15:58 -05:00
Robin Linden
5d2b1e3861
Update tox-bootstrapd checksum due to newer packages in Alpine
* g++       9.2.0-r4  -> 9.3.0-r0
* gcc       9.2.0-r4  -> 9.3.0-r0
* libatomic 9.2.0-r4  -> 9.3.0-r0
* libcurl   7.67.0-r0 -> 7.67.0-r1
* libgcc    9.2.0-r4  -> 9.3.0-r0
* libgomp   9.2.0-r4  -> 9.3.0-r0
* libstdc++ 9.2.0-r4  -> 9.3.0-r0
* python3   3.8.2-r0  -> 3.8.2-r1
2020-11-16 16:22:55 +01:00
iphydf
8f4400b9b4
cleanup: Make pylint and mypy happy with bootstrap_node_info.py. 2020-05-06 10:59:47 +01:00
iphydf
3851cfb652
Add autotools build to localbuild docker images. 2020-05-05 23:41:16 +01:00
iphydf
8c0fd40356
refactor: Remove multi-declarators entirely.
We no longer allow `int a, b;`. In the few cases where we used it, we
instead better

* limit the scope of the identifier (e.g. in a for-init-decl)
* split the line and have 2 separate declarators, because the
  identifiers designate different types of things (e.g. friend numbers
  and group numbers).
2020-05-05 23:22:29 +01:00
iphydf
48bd200acb
refactor: Disallow multiple initialised declarators per decl.
We no longer allow:

```c
int a = 0, b = 0;
int a[3], b[3];
int a, *b;
```

But we do still allow (for now):

```c
int a, b;
```
2020-05-05 22:56:35 +01:00
iphydf
c1a2ea3309
Use bash arrays instead of strings for static analysis scripts.
These are more robust wrt. spaces in names.
2020-05-05 01:53:01 +01:00
iphydf
02a5bdc60c
Add logging to TCP and onion client. 2020-05-04 01:27:36 +01:00
iphydf
4efe541814
Add a script to run Travis CI locally.
This isn't quite Travis, but close enough for local testing.
2020-05-03 16:59:26 +01:00
iphydf
88b90c8225
Fix a bug in savedata loading when malloc fails.
Also added a bunch of asserts to tests where they don't check allocs.
2020-05-03 14:13:48 +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
2570ddcb17
Fix errors on error paths found by oomer.
* Use-after-free because we free network before dht in one case.
* Various unchecked allocs in tests (not so important).
* We used to not check whether ping arrays were actually allocated in DHT.
* `ping_kill` and `ping_array_kill` used to crash when passing NULL.

Also:
* Added an assert in all public API functions to ensure tox isn't NULL.
  The error message you get from that is a bit nicer than "Segmentation
  fault" when clients (or our tests) do things wrong.
* Decreased the sleep time in iterate_all_wait from 20ms to 5ms.
  Everything seems to still work with 5ms, and this greatly decreases
  the amount of time spent per test run, making oomer run much faster.
2020-05-02 21:47:08 +01:00
Robin Linden
9be4dbb433
Release 0.2.12 2020-05-01 12:58:27 +02:00
iphydf
a2d586b782
Rework the toxchat/bootstrap-node Docker image.
* Use fully static build for the bootstrap daemon.
* Store a sha256sum of the binary in the repo.
* Updated documentation for it.
* Add support for fully static build in cmake.
* Enable the docker build on every PR, so we catch changes to the
  checksum. I realise this is adding toil, but having the checksum is
  valuable for security of released binaries.
2020-04-26 16:13:24 +00:00
ImgBotApp
6ef80efbf5
[ImgBot] Optimize images
*Total -- 23.11kb -> 12.21kb (47.19%)

/other/tox.png -- 17.50kb -> 6.99kb (60.05%)
/other/tox-warning.png -- 5.61kb -> 5.21kb (7.04%)

Signed-off-by: ImgBotApp <ImgBotHelp@gmail.com>
2020-04-24 21:55:23 +00:00
iphydf
7c0eb5c70b
Enable TCP relay test in Bazel and autotools build.
This test was fixed by @robinlinden, but not enabled in all builds.
2020-04-20 09:28:00 +00:00
iphydf
2538905e4f
Install ci-tools and get tokstyle via the script it provides. 2020-04-08 17:56:42 +00:00
iphydf
0964961557
Migrate format-source script to new apidsl web app.
This one is unfortunately a little more complicated to use. I may add a
simpler API later, but for now, it's JSON-based (because I couldn't get
binary data to work without it getting mangled somewhere along the way -
JSON is at least text-transport-safe).
2020-04-04 21:18:05 +00:00
Maxim Biro
40dd88596e
Add minimal save generator 2020-04-04 16:38:28 -04: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
Maxim Biro
7c63b0f734
Update tox-bootstrapd's dockerfile to use Debian Buster 2020-03-03 01:23:24 -05:00
Maxim Biro
ac5c9ebce4
Fix tox-bootstrapd's README 2020-03-03 01:23:22 -05:00
zugz (tox)
08e6a1863e
bump libsodium version in appveyor.yml and windows Dockerfile 2019-11-17 13:40:34 +01:00
Maxim Biro
ebf3a82de8
Use new WineHQ Debian package repository key 2019-01-03 22:02:22 -05:00
iphydf
72ef08597e
Allow unauthenticated wine packages in the Windows build. 2019-01-03 10:49:37 +00:00
Maxim Biro
5530e41742
Increase NOFILE limit for tox-bootstrapd
tox-bootstrapd can use around 600 TCP sockets during TCP server's normal
functioning. Many systems default to having a soft limit of 1024 open file
descriptors, which we are close to reaching, so it was suggested we bump that
limit to a higher number. iphy suggested increasing it to 32768.
2018-11-04 20:10:09 -05:00
Maxim Biro
b6dde3c76f
Use cmake to build toxcore in tox-boostrapd's Dockerfile 2018-10-17 14:45:44 -04:00
Maxim Biro
9b98ac1342
tox-bootstrapd's Dockerfile shouldn't use master branch 2018-10-17 14:45:36 -04:00
Maxim Biro
f45bf686ae
Don't warn about macro expansion in run-clang 2018-10-16 21:35:44 -04:00