From 35424b375a5346719013ca14a23e1ee9d6efc6a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Przemys=C5=82aw=20Bida?= Date: Wed, 13 Dec 2023 03:28:26 +0100 Subject: [PATCH] [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. --- src/posix/platform/udp.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/posix/platform/udp.cpp b/src/posix/platform/udp.cpp index 6d7c880a3..5726f0ede 100644 --- a/src/posix/platform/udp.cpp +++ b/src/posix/platform/udp.cpp @@ -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,