Commit Graph

925 Commits

Author SHA1 Message Date
Michael Jones
4e8524d9d7
avoid potential nullptr derefernence in udp_create_server_socket (#1496) 2024-05-26 18:22:31 -07:00
Michael Jones
f3b73f60d0
Change the various map functions to return bool instead of inconsistantly return 0, 1, or -1 (#1502) 2024-05-26 17:45:18 -07:00
Michael Jones
6fc5cf31e9
Check the result of malloc in del_alt_server (#1503) 2024-05-26 17:34:15 -07:00
Michael Jones
2c45aa731c
Avoid nullptr dereference of server variable in various functions (#1504) 2024-05-26 17:32:02 -07:00
Gustavo Garcia
14e6d16d14
Fix msvc analyzer error on goto label on rfc5769check (#1486)
rfc5769check.c file is using ERROR as a label for gotos but apparently
that name is already used for a constant and msvc analyzer detects it as
an error.

Rename it to "err" that is already used in other parts of the codebase
and also more consistent in terms of casing.

Co-authored-by: Gustavo Garcia <gustavogb@mail.com>
2024-05-05 12:19:10 +02:00
Stefan Junker
158fe9b698
Fix buffer overflow in generate_enc_password with increase rsalt by 2 (#1463)
before this change i see a bufferflow during `readable_string`.
2024-05-04 18:26:35 +02:00
Gustavo Garcia
386371c174
Fix lint errors 2024-04-21 23:05:29 +02:00
Nikolayshcx
eb3af26867
Add support for raw public keys (Rfc 7250) (#1458)
Resolving #1456

---------

Co-authored-by: nmegdanov <nikolay.megdanov@softavail.com>
2024-04-19 17:12:48 +02:00
Gustavo Garcia
c2d13700ac Fix clang-format lint warnings 2024-04-19 17:08:49 +02:00
Gustavo Garcia
28294cf053 Fix const during free warning in rfc5769check app 2024-04-19 16:23:30 +02:00
Kang Lin
5b68014699
Refactor: peer_input_handle (#1325) 2024-04-19 12:09:43 +02:00
NO NAME
3f66c028fa
Fix Cmake find issue in libevent (#1466)
Fixed an issue in libevent's CMake configuration where pthreads were not
correctly added to the optional components list, leading to a
compilation error. #1448

Co-authored-by: linwenchen <wenchen0803@qq.com>
2024-04-09 11:51:31 +02:00
Pavel Punsky
edebb9ad05
Print version only, no extra lines (#1441)
Before
<img width="615" alt="Screenshot 2024-03-02 at 2 47 48 PM"
src="https://github.com/coturn/coturn/assets/2505440/c3f01e97-914c-4391-af32-d3442d265e90">

After
<img width="402" alt="Screenshot 2024-03-02 at 2 47 28 PM"
src="https://github.com/coturn/coturn/assets/2505440/ce3deb7b-5f70-4158-8cd9-eceae0dcc995">
2024-03-31 09:53:21 +02:00
ashamedbit
412788b120
Fix memory leak in rfc5769check.c (#1410)
I came across the open issue #1368 which is a leaksanitizer report about
a leak that happens on make check. I was able to reproduce the bug on
running `make check` and was able to generate a patch for it. The leak
happens within function `check_oauth`.

Issue: The variable `base64encoded_ltp` is allocated within
`base64_encode` however it is not de-allocated within the coming loop.

I have verified that after the patch, the leak no longer occurs through
`leaksanitizer` (and there is no double free for that matter)

---------

Co-authored-by: Pavel Punsky <eakraly@users.noreply.github.com>
2024-03-03 14:04:40 -08:00
ashamedbit
456e2e81b3
Fix memory leak in netengine.c (#1411)
This is in response to issue #1366
The clang static analyzer basically claims that there is a memory leak
happening in `set_ssl_ctx` for the variable `args`. The leak is
triggered when the base event `base` is NULL and the condition within
`set_ssl_ctx` is not triggered. Therefore as a patch I am adding an else
condition to free it. (It cannot be freed after the event is created by
`event_new` because `args` can be invoked as argument for callback
function later on)

Please let me know if this patch is helpful :)

---------

Co-authored-by: Pavel Punsky <eakraly@users.noreply.github.com>
2024-03-02 14:15:58 -08:00
ashamedbit
68b9f19f7f
Fix memory leak on http_server.c (#1412)
This is in response to issue #1365.
The clang static analyzer basically claims that there is a memory leak
happening in `parse_http_request_1` for the variable `kv`. The leak is
triggered when evhttp_parse_query_str fails and is unable to obtain key
value pairs for a given URI. In this case ret is freed, however kv is
still not freed and thereafter not used. Therefore as a patch I am
freeing kv right after ret is freed.

Please let me know if this patch is helpful :)

---------

Co-authored-by: Pavel Punsky <eakraly@users.noreply.github.com>
2024-03-02 14:10:53 -08:00
Pavel Punsky
2c265c9777
Delete unused variable (#1437) 2024-02-25 16:07:08 -08:00
redraincatching
ac00b41a8e
changed variables in stunclient.c to bool (C11) (#1421)
# changed variables that appeared in `stunclient.c` and their uses to
`bool` to follow C11 idioms
## approach was as follows:
- if a variable of type `int` was only being used as a boolean, replace
it with bool as defined in `<stdbool.h>`
- replace its declaration and assignment with true/false, depending on
prior assignment as 0/1

changes were only made when i was certain the variables were not being
used as an int, so i may have missed some

---

## variables changed in `stunclient.c`
- `rfc5780`
- `change_ip`
- `change_port`

their usages were changed only where they appeared in the apps
directory, and then everywhere that generated a warning after make

- `stunclient.c` itself
- `natdiscovery.c`
2024-02-20 18:43:24 -08:00
redraincatching
0c8d646e2d
added missing function prototype of turn_random_number() (#1428)
trivial - cmake generated a warning that `ns_turn_msg.c` used a function
that had no prior prototype - most other files used the `turn_random()`
function but this uses `turn_random_number()` which has no prototype, so
i've added it to the header file
2024-02-10 20:57:33 -08:00
Jan Brasna
9dfe8d5128
Fix no-tls warning typo (#1426)
Trivial log warning typo introduced in #1256 corrected.
2024-02-09 20:15:19 -08:00
Michael Jones
2459db6266
Adjust wording in cmake message when prometheous cannot be found. (#1418) 2024-01-31 17:57:20 -08:00
Michael Jones
da332ed9e7
Add the InsertBraces command for clang-format to ensure that all conditionals always have braces (#1408)
- Why? Because code where conditionals lack braces is much harder to read, and prone to indentation confusion.
- How? Just added an extra flag to .clang-format and re-ran clang-format on all the files.

I also moved .clang-format up to the top level of the repo so that it can be applied to the fuzz targets as well.
2024-01-27 16:38:40 -08:00
Pavel Punsky
0afbc6204d
Replace HeapAlloc with malloc (#1378)
Use malloc/free instead of HeapAlloc/HeapFree
2024-01-18 21:08:28 -08:00
korayvt
348380f248
Added sessionID to some log lines (#1334)
Co-authored-by: KORAY VATANSEVER <koray.vatansever@turkcell.com.tr>

Some events are missed when logs are filtered by session ID. That's why I added the sessionID to some log lines.
2024-01-17 22:16:57 -08:00
Cybermilitia
7546c24b2f
Missing session ID in coturn logs for denied IP - 1330 (#1332)
Co-authored-by: CUMHUR KARAHAN <cumhur.karahan@turkcell.com.tr>

Added session id parameter to use it in "A peer IP denied in the range" logs. Besides, server ID has been made visible in this logs.
Before
```
023-08-24T17:23:17.221745770+03:00 stdout F 268472: : ERROR: A peer IP 169.254.38.68 denied in the range: 169.254.0.0-169.254.255.255
```

And after - new view:
```
2023-09-28T10:53:49.627778472+03:00 stdout F 1247: : ERROR: session 006000000000000004: A peer IP 172.21.198.41 denied in the range: 172.21.198.40-172.21.198.50 in server 6
```
2024-01-15 19:12:24 -08:00
Pavel Punsky
acf607ee50
Fix mingw build (#1376) 2024-01-15 18:26:54 -08:00
Pavel Punsky
c062d5e2af
Simplify macOS detection macros (#1372) 2024-01-15 15:18:35 -08:00
Pavel Punsky
f8e9892d3e
Fix potential null passed to function expecting nonnull (#1373) 2024-01-15 15:13:32 -08:00
Evgeny Khramtsov
7ecfb537e9
Only set MHD_USE_DUAL_STACK if IPv6 is available (#1362)
Co-authored-by: Evgeny Khramtsov <evgeny.khramtsov@ringcentral.com>

If IPv6 is not enabled during runtime, prometheus server fails to start with `EAFNOSUPPORT` because `MHD_USE_DUAL_STACK` is set unconditionally.

This PR fixes it. As a bonus, it also checks if libmicrohttpd is compiled with IPv6 support.
2024-01-14 12:49:59 -08:00
Kang Lin
294f897ccd
CMake: find prometheus(fix #1304) (#1315)
fix #1304
2023-11-22 20:34:53 -08:00
Subhra264
9485c9567e
Fix: Return correct error code for create_relay_connection in case of RESERVATION-TOKEN failure (#1319)
Fixes #1266 

According to RFC 5766, [section 6.2](https://www.rfc-editor.org/rfc/rfc5766#section-6.2) point no. 5, the turn server needs to reject the request with 508 (Insufficient Capacity) error code when the given RESERVATION-TOKEN is not valid.
2023-11-22 20:30:27 -08:00
Pavel Punsky
99cc8aaa65
Reduce ifdefs in code: TURN_NO_PROMETHEUS (#1116)
TURN_NO_PROMETHEUS define is used in minimal amount of places now
2023-11-05 17:49:03 -08:00
Richard Russo
4bc872b663
strncpy doesn't return size_t (#1296)
follow up to https://github.com/coturn/coturn/pull/1282/files
2023-11-05 17:48:32 -08:00
Dave Lambley
20c8d86a34
Return a 400 response to HTTP requests (#1231)
For our deployment, it is useful if coturn returns a valid HTTP response to an HTTP request. To do this on the same port as STUN/TURN and without enabling the admin site, I have extended `read_client_connection()` to return a canned HTTP response, in response to an HTTP request, rather than immediately closing the connection.
2023-11-05 17:25:12 -08:00
Gustavo Garcia
597b36c5a2
Fix missing strncpy in fix_stun_check_message_integrity_str (#1282)
Co-authored-by: Gustavo Garcia <gustavogb@mail.com>
Co-authored-by: Pavel Punsky <eakraly@users.noreply.github.com>
2023-10-04 10:06:40 -07:00
Pavel Punsky
95c2967252
Fix memleak in pgsql_reread_realms (#1278)
Fixes #1259

If `ur_string_map_put ` fails then the string that was just `strdup`-ed
will leak memory
Now the return value is checked and memory free-ed in case of failure
2023-10-02 16:20:14 +02:00
Gustavo Garcia
88ced47138
Replace srand/rand with srandom/random (#1279)
- srandom/random provide stronger randomness characteristics than
srand/rand in some operating systems.
- usage of srand/rand is not very consistent in coturn.

There is room for more refactoring and use apputils helper functions in
ns_turn_msg.c too but i'm not sure that dependency from "client" module
to "apps" module is a good idea yet.

Thx @0xdea

Co-authored-by: Gustavo Garcia <gustavogb@mail.com>
2023-10-02 16:19:57 +02:00
Gustavo Garcia
4e0d21e1b5
Fix memcpy len checks stun_is_challenge_response_str (#1280)
Add missing checks for length of realm/nonce/server_name before copying
those values to the buffer passed to stun_is_challenge_response_str.

The function stun_is_challenge_response_str is only used in uclient test
application.

Thank you very much @0xdea

Co-authored-by: Gustavo Garcia <gustavogb@mail.com>
2023-10-02 16:19:38 +02:00
Alexander Udovichenko
2a695ea855
Add warning and disable web admin if no-tls option used (#1256)
Fixes https://github.com/coturn/coturn/issues/1239

https to web ui freeze in browser if no_tls option used, because no tls
stuff initialized.
This PR add warning about this and comment aboute this in default config
2023-08-27 16:27:37 -07:00
Pavel Punsky
2850550be1
Fix formatting to fix lint error (#1258) 2023-08-27 16:26:37 -07:00
Aaron Bird
0f450f5492
Fix error of make command in Cygwin environment (#1236)
Environment:
- Windows 10
- Cygwin 2.925

make output:
```
<command-line>: note: this is the location of the previous definition
src/apps/common/ns_turn_utils.c:53:10: fatal error: sys/syscall.h: No such file or directory
   53 | #include <sys/syscall.h>
      |          ^~~~~~~~~~~~~~~
compilation terminated.
In file included from src/client/ns_turn_ioaddr.h:34,
                 from src/client/ns_turn_msg.h:34,
                 from src/apps/common/stun_buffer.h:34,
                 from src/apps/common/stun_buffer.c:31:
src/ns_turn_defs.h:223: warning: "TURN_NO_SCTP" redefined
  223 | #define TURN_NO_SCTP
      |
<command-line>: note: this is the location of the previous definition
make: *** [Makefile:127: bin/turnutils_oauth] Error 1
```
2023-08-13 17:14:16 -07:00
Cybermilitia
72cf9ba52b
Fix recursive call in delete alternate server (#1250)
I tested the code part by using manual and automated tools for more than
2 years.

Fixes #823 

When you try to delete an alternate server in the list by using "das :" command on the CLI, the session gets stuck and can't response although alternate server is removed.

The problem appears to be related to calling del_alt_server function in the same function recursively.

Co-authored-by: CUMHUR KARAHAN <cumhur.karahan@turkcell.com.tr>
2023-08-13 16:38:19 -07:00
Robert Scheck
8f9446cf8f
Change printf() to TURN_LOG_FUNC() for --no-stdout-log (#1221) 2023-06-01 19:38:33 -07:00
rim
7bc932a905
Fix build with libressl 3.6+ (#1198)
Tested on FreeBSD 13/stable
2023-05-14 16:38:58 -07:00
Pavel Punsky
af8a057eac
Update version to 4.6.2 (#1174)
Update version number, generate authors and changelog files

Release notes (short summary of changes)
```
- Make sure microhttpd starts using epoll if supported
- Add sessioncount to prometheus metrics
- Add STUN request/response/error prometheus counters
- Cleanup logs on turnserver start
- Fix duplicate stdout log output
- Log threadId to logs to aid in multi-threaded debugging
- Optional build info compiled into turnserver binary
- Fix arguments expansion in `docker-entrypoint.sh`
- Santise database connection strings before printing to log
- Support Windows MSVC
- Add configuration option for TLS 1.3 ciphersuites
- Improve openssl3 and FIPS support
- Use single SSL_CTX for TLS and DTLS support
- Update openssl API use to non-deprecated version
- Set string bytes to null to prevent random origin
- Fix memory corruption on socket close
- Fix packet backlog fifo that processed packets in reverse order in some scenarios
- Fix off-by-one when terminating gcm_nonce
- Fixes to Redis memleaks and socketleaks
- Fix malformed response to mobility refresh request
- Fuzzing support
- Ignore raw UDP if no_udp is enabled
- Better detect availability of SCTP protocol
```

---------

Co-authored-by: tyranron <tyranron@gmail.com>
2023-04-10 19:00:08 -07:00
Cédric DIJOUX
67beeb83b1
Fix MSVC CI build (#1182)
Removing windows.h inclusion, not needed with ws2tcpip.h. Causes some
struct redefinitions.
2023-04-01 18:28:27 -07:00
Thibaut ACKERMANN
242eb78227
Prometheus: make sure microhttpd starts using epoll if supported (#1173)
In some cases the prometheus server was started using SELECT even if
EPOLL was supported.
Some flags were changed in microhttpd and now we use MHD_VERSION to make
sure to use the right ones in all cases (support old version, for ubuntu
16.04 for ex).

This fixes the issue #1167

I also added a log to make sure we know which version is used,
especially to inform the user that the SELECT version might lead to
issues on highly used servers.
2023-03-19 18:04:04 -07:00
Stefan Sundin
43f8b873a7
Fix typo in mainrelay.c (#1169) 2023-03-12 17:29:39 -07:00
Pavel Punsky
79fb65519c
Remove unused include that breaks OpenBSD (#1165)
PR #855 introduced new include <ssys/sysinfo.h> 
It is not required for compilation or turnserver function but breaks
OpenBSD build (which does not have this file)
This PR removes the include to restore OpenBSD build compatibility

Fixes #1162

Test Plan:
TBD - need some one to test build
2023-03-06 08:50:12 +01:00
r3g_5z
212e782355
use santisied psql string (#1144)
Noticed the plaintext password of my postgresql server in my coturn
logs, but postgresql errors would return the password sanitised. Simple
fix to log the sanitised string.


![image](https://user-images.githubusercontent.com/112147643/213053494-c8a5d226-0b04-4c8d-9b52-3e1330291a39.png)


Signed-off-by: r3g_5z <june@girlboss.ceo>

Signed-off-by: r3g_5z <june@girlboss.ceo>
2023-01-19 17:55:46 -08:00