Skip to content

Commit 8e5391a

Browse files
committed
NanostackInterface: Check input address is IPv6
For the two calls that use the address - sendto and connect, check that it actually is an IPv6 address.
1 parent c9f9ffa commit 8e5391a

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

features/nanostack/FEATURE_NANOSTACK/nanostack-interface/NanostackInterface.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -716,6 +716,10 @@ int NanostackInterface::socket_sendto(void *handle, const SocketAddress &address
716716
return NSAPI_ERROR_NO_SOCKET;
717717
}
718718

719+
if (address.get_ip_version() != NSAPI_IPv6) {
720+
return NSAPI_ERROR_UNSUPPORTED;
721+
}
722+
719723
nanostack_lock();
720724

721725
int ret;
@@ -849,6 +853,10 @@ int NanostackInterface::socket_connect(void *handle, const SocketAddress &addr)
849853
return NSAPI_ERROR_NO_SOCKET;
850854
}
851855

856+
if (addr.get_ip_version() != NSAPI_IPv6) {
857+
return NSAPI_ERROR_UNSUPPORTED;
858+
}
859+
852860
nanostack_lock();
853861

854862
int ret;

0 commit comments

Comments
 (0)