From 422e7963de05849ee807092914ce19dabcea08cf Mon Sep 17 00:00:00 2001 From: Simon Goldschmidt Date: Wed, 24 Aug 2011 21:12:12 +0200 Subject: [PATCH] fixed bug #33956 Wrong error returned when calling accept() on UDP connections --- CHANGELOG | 4 ++++ src/api/api_msg.c | 2 ++ src/api/sockets.c | 8 ++++++++ 3 files changed, 14 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index f98b075e..aa9f3100 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -21,6 +21,10 @@ HISTORY ++ Bugfixes: + 2011-08-24: Simon Goldschmidt + * api_msg.c, sockets.c: fixed bug #33956 Wrong error returned when calling + accept() on UDP connections + 2011-08-24: Simon Goldschmidt * sockets.h: fixed bug #34057 socklen_t should be a typedef diff --git a/src/api/api_msg.c b/src/api/api_msg.c index f9f709e7..76ac49e7 100644 --- a/src/api/api_msg.c +++ b/src/api/api_msg.c @@ -1089,6 +1089,8 @@ do_listen(struct api_msg_msg *msg) } } } + } else { + msg->err = ERR_ARG; } } } diff --git a/src/api/sockets.c b/src/api/sockets.c index a9a85c37..e7d8e1e9 100644 --- a/src/api/sockets.c +++ b/src/api/sockets.c @@ -336,6 +336,10 @@ lwip_accept(int s, struct sockaddr *addr, socklen_t *addrlen) err = netconn_accept(sock->conn, &newconn); if (err != ERR_OK) { LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_accept(%d): netconn_acept failed, err=%d\n", s, err)); + if (NETCONNTYPE_GROUP(netconn_type(sock->conn)) != NETCONN_TCP) { + sock_set_errno(sock, EOPNOTSUPP); + return EOPNOTSUPP; + } sock_set_errno(sock, err_to_errno(err)); return -1; } @@ -537,6 +541,10 @@ lwip_listen(int s, int backlog) if (err != ERR_OK) { LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_listen(%d) failed, err=%d\n", s, err)); + if (NETCONNTYPE_GROUP(netconn_type(sock->conn)) != NETCONN_TCP) { + sock_set_errno(sock, EOPNOTSUPP); + return EOPNOTSUPP; + } sock_set_errno(sock, err_to_errno(err)); return -1; }