mirror of
https://github.com/espressif/openthread.git
synced 2026-10-19 14:08:13 +00:00
[udp] return error on source port mismatch in Udp::SendTo() (#3698)
This commit is contained in:
@@ -159,6 +159,9 @@ otError UdpSocket::SendTo(Message &aMessage, const MessageInfo &aMessageInfo)
|
||||
otError error = OT_ERROR_NONE;
|
||||
MessageInfo messageInfoLocal;
|
||||
|
||||
VerifyOrExit((aMessageInfo.GetSockPort() == 0) || (GetSockName().mPort == aMessageInfo.GetSockPort()),
|
||||
error = OT_ERROR_INVALID_ARGS);
|
||||
|
||||
messageInfoLocal = aMessageInfo;
|
||||
|
||||
if (messageInfoLocal.GetPeerAddr().IsUnspecified())
|
||||
@@ -183,6 +186,7 @@ otError UdpSocket::SendTo(Message &aMessage, const MessageInfo &aMessageInfo)
|
||||
{
|
||||
SuccessOrExit(error = Bind(GetSockName()));
|
||||
}
|
||||
|
||||
messageInfoLocal.SetSockPort(GetSockName().mPort);
|
||||
|
||||
#if OPENTHREAD_ENABLE_PLATFORM_UDP
|
||||
|
||||
Reference in New Issue
Block a user