[posix] verify in otPlatUdpBindToNetif if Backbone Interface is set. (#9696)

Commit adds check to `otPlatUdpBindToNetif` if backbone interface is
set to correct value to prevent `setsockopt` from crashing the
ot-daemon.
This commit is contained in:
Przemysław Bida
2023-12-12 18:28:26 -08:00
committed by GitHub
parent a62e238b7f
commit 35424b375a
+5
View File
@@ -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,