Skip to content

Commit

Permalink
[posix] verify in otPlatUdpBindToNetif if Backbone Interface is set. (
Browse files Browse the repository at this point in the history
openthread#9696)

Commit adds check to `otPlatUdpBindToNetif` if backbone interface is
set to correct value to prevent `setsockopt` from crashing the
ot-daemon.
  • Loading branch information
Przemysław Bida authored Dec 13, 2023
1 parent a62e238 commit 35424b3
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/posix/platform/udp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,11 @@ otError otPlatUdpBindToNetif(otUdpSocket *aUdpSocket, otNetifIdentifier aNetifId
case OT_NETIF_BACKBONE:
{
#if OPENTHREAD_CONFIG_BACKBONE_ROUTER_ENABLE
if (otSysGetInfraNetifName() == nullptr || otSysGetInfraNetifName()[0] == '\0')
{
otLogWarnPlat("No backbone interface given, %s fails.", __func__);
ExitNow(error = OT_ERROR_INVALID_ARGS);
}
#if __linux__
VerifyOrExit(setsockopt(fd, SOL_SOCKET, SO_BINDTODEVICE, otSysGetInfraNetifName(),
strlen(otSysGetInfraNetifName())) == 0,
Expand Down

0 comments on commit 35424b3

Please sign in to comment.