From 0bbf6490f50bef5c21b237cd20e69e5b12a9916e Mon Sep 17 00:00:00 2001 From: goldsimon Date: Fri, 12 May 2017 20:34:16 +0200 Subject: [PATCH] setsockopt: allow SO_BROADCAST for UDP sockets only --- src/api/sockets.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/api/sockets.c b/src/api/sockets.c index d6cee222..cd4cc7da 100644 --- a/src/api/sockets.c +++ b/src/api/sockets.c @@ -2852,6 +2852,11 @@ lwip_setsockopt_impl(int s, int level, int optname, const void *optval, socklen_ #if SO_REUSE case SO_REUSEADDR: #endif /* SO_REUSE */ + if ((optname == SO_BROADCAST) && + (NETCONNTYPE_GROUP(sock->conn->type) != NETCONN_UDP)) { + done_socket(sock); + return ENOPROTOOPT; + } LWIP_SOCKOPT_CHECK_OPTLEN_CONN_PCB(sock, optlen, int); if (*(const int*)optval) { ip_set_option(sock->conn->pcb.ip, optname);