Commit Graph

1782 Commits

Author SHA1 Message Date
lhywk
5ab95e1a5a
Fix memory and resource leaks in udp_create_server_socket( ) (#1714)
### Describe

Hi,

Fixes resource and memory leaks in `udp_create_server_socket()` by
ensuring that the socket file descriptor (`udp_fd`) and dynamically
allocated memory (`server_addr`) are properly released on failure.

Specifically, if `addr_bind()`, `event_new()`, or `event_add()` fails,
the function now closes the socket and frees memory to prevent leaks.

### Expected Behavior

On any failure during socket binding or event registration, both
`udp_fd` and `server_addr` should be released to avoid leaking system
resources.

### Actual Behavior

Previously, if `addr_bind()`, `event_new()`, or `event_add()` failed,
the function would return early without closing the socket or freeing
memory, causing file descriptor and heap memory leaks.

This patch addresses overlooked memory and resource cleanup on failure
paths, improving server stability through targeted and essential
changes.

Thanks for reviewing.

Co-authored-by: Gustavo Garcia <gustavogb@gmail.com>
2025-07-03 10:23:59 +02:00
Shane
2944775261
Add define to disable OAuth support (#1713)
Redoing https://github.com/coturn/coturn/pull/1664 as requested. This
adds an optional OAUTH_DISABLED define to allow for disabling OAuth
support.
2025-07-02 11:36:50 +02:00
redraincatching
0f8cdde961
typo correction (#1715)
@ggarber i noticed too late that i used `0x03` instead of `0x02` by
mistake - this is an issue because it means that `add_requested_family`
will never be set when ipv6 is being used, so this should be fixed
2025-07-01 14:10:45 +02:00
tyranron
bc7cd74718
Update Debian "bookworm" to 20250630 snapshot in Docker image 2025-07-01 14:34:38 +03:00
redraincatching
a3a7450104
refactored tri-state to bools (#1709)
refactored random tri-state to use two random booleans for clarity
2025-07-01 12:41:22 +02:00
redraincatching
16f801f646
addressed null pointer deref warnings (#1712)
addressing issues raised by code scanning, specifically null pointer
dereferences in server

ns_turn_server.c
-
[33](https://github.com/redraincatching/coturn/security/code-scanning/33)
ignored, the `is_rfc5780()` function exits early if the server is null
- this also catches
[36](https://github.com/redraincatching/coturn/security/code-scanning/36)
-
[34](https://github.com/redraincatching/coturn/security/code-scanning/34)
addressed
-
[174](https://github.com/redraincatching/coturn/security/code-scanning/174)
addressed

ns_turn_maps.c
-
[27](https://github.com/redraincatching/coturn/security/code-scanning/27),
[160](https://github.com/redraincatching/coturn/security/code-scanning/160),
[161](https://github.com/redraincatching/coturn/security/code-scanning/161),
[162](https://github.com/redraincatching/coturn/security/code-scanning/162),
[163](https://github.com/redraincatching/coturn/security/code-scanning/163),
[164](https://github.com/redraincatching/coturn/security/code-scanning/164),
[165](https://github.com/redraincatching/coturn/security/code-scanning/165)
false positives, suppressed with assert()

ns_turn_allocations.c
-
[9](https://github.com/redraincatching/coturn/security/code-scanning/9)
addressed

---------

Co-authored-by: Gustavo Garcia <gustavogb@gmail.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-07-01 12:40:11 +02:00
redraincatching
cb74638149
removed unnecessary null check (#1706)
removing an unnecessary null check as raised in [this code
scan](https://github.com/redraincatching/coturn/security/code-scanning/179)

the variable is confirmed to not be null in an outer loop guard

also changed the name of the variable in `rtcp_map_put`'s function
declaration to match that used in its function definition
2025-06-20 09:51:52 -07:00
Gustavo Garcia
62d91b0bc5
Fix compiler warnings in source files (#1704)
Two compiler warnings were addressed:

* In `src/apps/relay/http_server.c`, line 77, a `-Wpointer-sign` warning
occurred when initializing a `char *` with the `uint8_t *` return type
of `ioa_network_buffer_data()`.
* An explicit cast `(char *)` was added to
`ioa_network_buffer_data(nbh_http)` to resolve the type mismatch.

* In `src/apps/relay/acme.c`, line 59, a `-Wchar-subscripts` warning was
present because a `char` variable `c` was used as an array index. `char`
can be signed, potentially leading to negative indices.
* Initially, `c` was cast to `(unsigned char)` at the point of use:
`A[(unsigned char)c]`.
* This was later improved by changing the declaration of `c` from `const
char` to `const unsigned char c = req[k]

---------

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
2025-06-17 15:25:26 +02:00
redraincatching
afec2e2add
guarantee no oob write in strncat (#1702)
based on [this codescanning
alert](https://github.com/redraincatching/coturn/security/code-scanning/166)

guarantees that the `turn_params.cipher_list` will be null-terminated,
and that the call to strncpy cannot attempt to access out-of-bounds
memory
2025-06-12 11:15:46 +02:00
Scott Godin
1368e65988
Fix issues with Global Allocation Count for drain mode (#1699)
Fix issues with Global Allocation Count for drain mode

- move increment/decrement logic out of userdb.c and tie to Prometheus
logic for allocation tracking instead
- log global allocation count decrements at INFO level, when drain mode
is on
2025-06-11 14:15:36 -07:00
tyranron
14e6919996
Update Debian "bookworm" to 20250610 snapshot in Docker image 2025-06-11 11:12:58 +02:00
Amin Farjadi
9c039d9026
fix: comment out verbose mode by default (#1696)
Following the comments, verbose mode should be commented out by default.
2025-06-03 20:52:26 +02:00
tyranron
aa685e2669
Upgrade Docker image to 4.7.0 Coturn version 2025-06-02 14:44:49 +02:00
tyranron
f272bb4db7
Upgrade Alpine to 3.22 version in Docker image 2025-06-02 13:59:15 +02:00
Pavel Punsky
678996a529
Update version to 4.7.0 (#1691)
Set new release version to 4.7.0
Updating minor version due to some breaking changes in options to enable
more secure/robust configuration without additional flags (or relying on
recommended conf file which people seem to skip during updates)
2025-05-30 14:13:59 -07:00
Pavel Punsky
cc5e18fc89
Make older TLS versions optional (#1693)
TLSv1 and TLSv1.1 can be enabled using `--tlsv1` and `--tlsv1_1`
arguments accordingly
That assumes openssl version being used has these versions enabled
(which as of openssl-3.5 is not by default)
2025-05-30 09:20:14 -07:00
Gustavo Garcia
d7197fa263
Add missing close socket when ioa_socket call fails (#1694)
Fixes [#1071](https://github.com/coturn/coturn/issues/1071)

Not sure how this case can happen but better to handle the error case.

Co-authored-by: tyranron <tyranron@gmail.com>
2025-05-30 09:19:24 -07:00
Michael Jones
9ae1e3b3cb
Add spdx tags to all source files (#1510)
With notable exceptions of:

src/apps/common/win/*
src/apps/relay/telnet.*

The purpose of this change is to add the SPDX tags from
https://spdx.dev/, which is a linux foundation project, to the source
code.

This provides automated code provenance tools, which are used in setting
up software bill of materials reports, an easy time verifying that the
code license is known and no incompatibilities are present in a
codebase.

No copyright date, author, or license changes are made.

Note also that
7e525c8e1c
is the original commit for the ACME code (acme.h and acme.c) which was
then moved to acme.h and acme.c in this commit
d4686750ee
but neither commit indicates what license the ACME code was submitted
as.

https://github.com/coturn/coturn?tab=License-1-ov-file#readme is the
3-clause BSD license, but https://github.com/coturn/coturn/pull/672
documents that the author's intent was for the MIT license. So I've used
the SPDX tag and content of the MIT license for this change.
2025-05-30 11:56:04 +02:00
Michael Jones
0af0fc3ec2
Address various minor clang-tidy warnings (#1513)
No specific methodology other than checking the github CI output for the
`clang-tidy` job, and fixing things one at a time.
2025-05-29 19:12:50 -07:00
Gustavo Garcia
b47648490c
Update reference to old draft in README to RFC8016
Fixes #1177
2025-05-29 13:23:48 +02:00
Pavel Punsky
14f84fa48c
[BREAKING] Deprecate response-origin-only-with-rfc5780 (#1690)
Make this true - response-origin-only will only be enabled with rfc5780 option enabled
2025-05-28 16:37:20 -07:00
Pavel Punsky
4cc076d424
[BREAKING] Invert no-stun-backward-compatibility to be default on (#1689)
Deprecate `--no-stun-backward-compatibility` and set it to true by
default
Add new option `--stun-backward-compatibility`, off by default

Update example/recommended configuration files

This is a breaking change as passing `--no-stun-backward-compatibility`
will be rejected as invalid argument
2025-05-28 16:23:33 -07:00
Pavel Punsky
368355a06f
Invert RFC5780 option to default off (#1688)
Invert `--no-rfc5780` option to be true by default
Make it `--rfc5780` to enable it
Update example/recommended configuration files

Passing `--no-rfc5780` will have no effect as this is the default
behavior now
2025-05-28 15:08:57 -07:00
Gustavo Garcia
ce56a78a7a
Add modules diagram to developer doc (#1685)
Add basic diagram with modules of coturn inside Developer.md.

I also wanted to move the existing Flow chart to mermaid so that our doc
doesn't depend on external tools but i couldn't find the time to do it
properly (horizontal arrows are hard to represent with mermaid) so i
postponed that part.

This is the result of the mermaid diagram: 
![Screenshot 2025-05-26 at 12 54
29](https://github.com/user-attachments/assets/860bd56b-cb4a-462c-b931-a82c9d52fdc9)
2025-05-26 13:57:13 +02:00
Gustavo Garcia
f17cd2d854
Fix compilation warning with const - non const conversions (#1686)
When building with default configuration at least in MacOS we get
warnings about those conversions from const char* to char*. Fix it by
making all those argv ""const char*"
2025-05-26 13:54:50 +02:00
Greg Troxel
f94a61b526
Makefile.in: Don't install sql schema into DOCSDIR (#1684)
sql schema files are installed into SCHEMADIR, which is the right place.
Don't install them an extra time.

Fixes #1631
2025-05-26 13:51:22 +02:00
Asmir Mehic
823fd71c98
Fix infinite loop in ns_turn_server.c (#1460)
In case ur_map_get returns 1 server will enter infinite loop because
newid != 0.

Co-authored-by: Asmir <asmir.mehic@viber.com>
2025-05-25 15:38:42 +02:00
Michael Jones
c37462b33a
Fix the ability to compile coturn using C++ compiler (#1546)
This adjusts the code to allow compilation with a C++ compiler, but
doesn't change the build to use a C++ compiler. Everything should
continue working as-is with existing c-compilers. This is just a "let it
work" change, not a "change how it works" change.
2025-05-25 10:53:13 +02:00
tyranron
60813060da
Update Debian "bookworm" to 20250520 snapshot in Docker image 2025-05-22 13:47:52 +02:00
Gustavo Garcia
de84ecefb1
Restore returning 200 OK on root prometheus path for health check (#1678)
Restore the support to return a 200 OK in the root prometheus endpoint
(/) as stated in the documentation.

This feature was lost when removing libpromhttp

Fixes #1672
2025-05-22 11:37:29 +02:00
Gustavo Garcia
8a71069517
Improve MySQL connection error logging to include actual MySQL error message (#1679)
Address #270

MySQL reconnectiong after priviledge drop and reporting missleading
error log.
"Cannot open MySQL DB connection: <%s>, runtime error\n"

Always include the mysql error message for additional context.
2025-05-22 11:29:36 +02:00
maddy
c0b2c8d389
redis: use dbname param when redis is unauthenticated (#1668)
Fixes a regression pointed out at
<https://github.com/coturn/coturn/pull/1488#issuecomment-2801027711>.

A regression was introduced in the last PR where the dbname parameter
was not respected if using redis without authentication. The logic for
sending the select command responsible for switching to the correct
database was wrongly guarded behind authentication being provided. This
PR flattens the control flow so the select command is always sent,
whether using authentication or not.
2025-05-21 18:58:35 +02:00
Gustavo Garcia
b0dbf5cb8c
Show allocations increment/decrement logs behind verbose flag (#1677)
Fix #1657 

This log was added in a recent refactor for draining support and it is
very noisy. With this change the log is moved behind the "verbose" flag
and also does a minor cleanup to not have 2 duplicated lines for logging
when one is enough.

Co-authored-by: Gustavo Garcia <gustavogb@mail.com>
2025-05-21 13:47:48 +02:00
Stefan Kieszkowski
24647a1e83
[Quick Fix] Fix Repeated Line in Example turnserver.conf (#1671)
The `#allocation-default-address-family="ipv4"` line is repeated twice
in the example config, changed the second one to be `"ipv6"` which I
assume it was intended to be.
2025-05-21 07:33:51 +02:00
tyranron
1adf0213d7
Update Debian "bookworm" to 20250428 snapshot in Docker image 2025-04-29 16:53:44 +02:00
tyranron
1bc31844e0
Update Debian "bookworm" to 20250407 snapshot in Docker image 2025-04-10 13:28:35 +03:00
Leonid Gorbachev
beaed33e90
change for incorrect handling of TURN_NO_TLS environment variable (#1663)
In version 4.5.1.3, there was a handling of TURN_NO_TLS environment
variable and the TURN_xxx environment variables can be set in the
following manner:
      **export TURN_NO_TLS=1**
      export TURN_NO_PQ=1
      export TURN_NO_MYSQL=1
      export TURN_NO_MONGO=1
      export TURN_NO_SQLITE=1
      ./configure


In versions 4.5.2 and later, handling of TURN_NO_TLS was removed, and
with this TURN_NO_TLS is set as-is OSCFLAGS:

831b7245aa/configure (L1021)
And now, to set no-tls properly during compile time, we have to do the
following:
      **export TURN_NO_TLS=-DTURN_NO_TLS**
      export TURN_NO_PQ=1
      export TURN_NO_GCM=1

Otherwise, if leave previous approach, it obviously causes an error
during compile time:
```
    cc: error: 1: linker input file not found: No such file or directory
```

With this PR i would like to restore consistency of environment
variables that used for ./configure
2025-03-30 13:16:28 -07:00
Pavel Punsky
791e4c9f7a
Add Content-Type header to prometheus response (#1662)
Prometheus v3 requires `Content-Type` header
Fixes #1658
2025-03-30 12:58:41 -07:00
tyranron
831b7245aa
Update Debian "bookworm" to 20250317 snapshot in Docker image 2025-03-18 12:23:25 +02:00
tyranron
7b46ba121d
Update Debian "bookworm" to 20250224 snapshot in Docker image 2025-03-04 14:08:35 +01:00
nicolas-laduguie
a21733b23d
Fix infinite loop while triggering SIGHUP and log file reset causing … (#1630)
…segmentation fault

This reverts commit 8f9446cf8f.
2025-02-20 21:14:07 -08:00
redraincatching
9f3da44285
rename and dependency extraction (#1634)
rebase and refactor of [this
pr](https://github.com/coturn/coturn/pull/1400) from last year that was
never merged

rename of cmake YAML file to match others and extraction of dependencies
to already existing composite action
2025-02-20 21:12:24 -08:00
redraincatching
01628a7a01
updated types to bool in _turn_params_ to reflect C11 (#1406)
approach was as follows, for the `_turn_params_` struct:
- if a variable of type `int` or `vint` was only being used as a
boolean, replace it with bool as defined in `<stdbool.h>`
- replace its declaration 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

no changes were made to other sections of the code as int-to-bool
assignment is allowed in C, only code within the structs were changed,
but that can be changed with a later commit

---

from a documentation perspective, it's not clear as to what purpose or
benefit the vint alias has. the definition in `ns_turn_defs.h` simply
reads

```c
typedef int vint;
typedef vint *vintp;
```
with no comments, and it seems most (but not all) `vint`s are being used
as interim booleans through the code. this may just be from lack of
knowledge of the codebase, but it doesn't seem useful in any way, so it
would be helpful if someone with more expertise could clarify

---------

Co-authored-by: Pavel Punsky <eakraly@users.noreply.github.com>
2025-02-20 21:03:13 -08:00
Kai Ren
1284a3f124
Explicitly install latest QEMU on CI for building Docker images (#1645) 2025-02-17 16:06:56 +01:00
tyranron
4945a42349
Decrease Docker BuildKit max-parallelism for ppc64le arch 2025-02-17 14:34:06 +02:00
tyranron
7273e70bf3
Update Alpine to 3.21.3 version in Docker image 2025-02-17 12:58:42 +02:00
tyranron
3b2fb7ccef
Update Debian "bookworm" to 20250203 snapshot in Docker image 2025-02-06 14:25:28 +02:00
tyranron
2acb4b1989
Update Debian "bookworm" to 20250113 snapshot in Docker image 2025-01-14 12:39:57 +02:00
tyranron
a85eefc48a
Update Alpine to 3.21.2 version in Docker image 2025-01-09 12:58:41 +02:00
tyranron
e825110d38
Update Alpine to 3.21.1 version in Docker image 2025-01-08 13:02:43 +02:00