mirror of
git://erdgeist.org/opentracker
synced 2025-01-26 22:56:26 +00:00
Prevent proxied ips of the wrong flavour to poison our clients
This commit is contained in:
parent
5b98dcf3a3
commit
aca3ee0ac8
12
ot_http.c
12
ot_http.c
@ -420,9 +420,17 @@ static ssize_t http_handle_announce( const int64 sock, struct ot_workstruct *ws,
|
||||
if( accesslist_is_blessed( cookie->ip, OT_PERMISSION_MAY_PROXY ) ) {
|
||||
ot_ip6 proxied_ip;
|
||||
char *fwd = http_header( ws->request, ws->header_size, "x-forwarded-for" );
|
||||
if( fwd && scan_ip6( fwd, proxied_ip ) )
|
||||
if( fwd && scan_ip6( fwd, proxied_ip ) ) {
|
||||
/* If proxy reports an ipv6 address but we can only handle v4 (or vice versa), bail out */
|
||||
#ifndef WANT_V6
|
||||
if( !ip6_isv4mapped(proxied_ip) )
|
||||
#else
|
||||
if( ip6_isv4mapped(proxied_ip) )
|
||||
#endif
|
||||
HTTPERROR_400_PARAM;
|
||||
|
||||
OT_SETIP( &ws->peer, proxied_ip );
|
||||
else
|
||||
} else
|
||||
OT_SETIP( &ws->peer, cookie->ip );
|
||||
} else
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user