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
Commit adds check to `otPlatUdpBindToNetif` if backbone interface is set
to correct value to prevent `setsockopt` from crashing the ot-daemon.
  • Loading branch information
canisLupus1313 committed Dec 11, 2023
1 parent bf99448 commit 78a8bea
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() == 0 || 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 78a8bea

Please sign in to comment.