1 From ffa2d56cac3d37715fe1381df81802774240da92 Mon Sep 17 00:00:00 2001
2 From: Dusan Stevanovic <dule@wire.com>
3 Date: Thu, 11 Mar 2021 10:58:32 +0100
4 Subject: [PATCH] turn: block forwarding to loopback/any
7 modules/turn/turn.c | 18 ++++++++++++++----
8 1 file changed, 14 insertions(+), 4 deletions(-)
10 --- a/modules/turn/turn.c
11 +++ b/modules/turn/turn.c
12 @@ -153,6 +153,7 @@ static bool indication_handler(struct re
13 struct stun_attr *data, *peer;
14 struct allocation *al;
16 + const struct sa *psa;
20 @@ -173,13 +174,17 @@ static bool indication_handler(struct re
24 - perm = perm_find(al->perms, &peer->v.xor_peer_addr);
25 + psa = &peer->v.xor_peer_addr;
26 + perm = perm_find(al->perms, psa);
32 - err = udp_send(al->rel_us, &peer->v.xor_peer_addr, &data->v.data);
33 + if (sa_is_loopback(psa) || sa_is_any(psa))
36 + err = udp_send(al->rel_us, psa, &data->v.data);
40 @@ -200,6 +205,7 @@ static bool raw_handler(int proto, const
44 + const struct sa *psa;
47 al = allocation_find(proto, src, dst);
48 @@ -219,7 +225,8 @@ static bool raw_handler(int proto, const
52 - perm = perm_find(al->perms, chan_peer(chan));
53 + psa = chan_peer(chan);
54 + perm = perm_find(al->perms, psa);
58 @@ -227,7 +234,10 @@ static bool raw_handler(int proto, const
60 mb->end = mb->pos + len;
62 - err = udp_send(al->rel_us, chan_peer(chan), mb);
63 + if (sa_is_loopback(psa) || sa_is_any(psa))
66 + err = udp_send(al->rel_us, psa, mb);