Skip to content

Commit

Permalink
Check if interface address returned by pj_getipinterface() is link-lo…
Browse files Browse the repository at this point in the history
…cal address (#3442)
  • Loading branch information
sauwming committed Mar 20, 2023
1 parent 195cd37 commit 74b0df1
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions pjlib/src/pj/sock_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -1068,6 +1068,21 @@ PJ_DEF(pj_status_t) pj_getipinterface(int af,
return PJ_ENOTFOUND;
}

#if defined(PJ_HAS_IPV6) && PJ_HAS_IPV6
/* Check if the local address is link-local but the destination
* is not link-local.
*/
if (af == pj_AF_INET6() &&
IN6_IS_ADDR_LINKLOCAL(&itf_addr->ipv6.sin6_addr) &&
(!IN6_IS_ADDR_LINKLOCAL(&dst_addr.ipv6.sin6_addr)))
{
TRACE_((THIS_FILE, "Local interface address is link-local and "
"the destination host is external"));

return PJ_ENOTFOUND;
}
#endif

if (p_dst_addr)
*p_dst_addr = dst_addr;

Expand Down

0 comments on commit 74b0df1

Please sign in to comment.