From 9572db262cb9ac578b6cf5ee87a0e1e2095f2e61 Mon Sep 17 00:00:00 2001 From: Simon Goldschmidt Date: Thu, 20 Feb 2014 22:32:57 +0100 Subject: [PATCH] Fixed bug #39718: disconnecting an UDP socket reports an error --- src/api/sockets.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/api/sockets.c b/src/api/sockets.c index e77bb8b4..a298869d 100644 --- a/src/api/sockets.c +++ b/src/api/sockets.c @@ -550,10 +550,6 @@ lwip_connect(int s, const struct sockaddr *name, socklen_t namelen) return -1; } - /* check size, familiy and alignment of 'name' */ - LWIP_ERROR("lwip_connect: invalid address", IS_SOCK_ADDR_LEN_VALID(namelen) && - IS_SOCK_ADDR_TYPE_VALID_OR_UNSPEC(name) && IS_SOCK_ADDR_ALIGNED(name), - sock_set_errno(sock, err_to_errno(ERR_ARG)); return -1;); LWIP_UNUSED_ARG(namelen); if (name->sa_family == AF_UNSPEC) { LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_connect(%d, AF_UNSPEC)\n", s)); @@ -561,6 +557,12 @@ lwip_connect(int s, const struct sockaddr *name, socklen_t namelen) } else { ipX_addr_t remote_addr; u16_t remote_port; + + /* check size, familiy and alignment of 'name' */ + LWIP_ERROR("lwip_connect: invalid address", IS_SOCK_ADDR_LEN_VALID(namelen) && + IS_SOCK_ADDR_TYPE_VALID_OR_UNSPEC(name) && IS_SOCK_ADDR_ALIGNED(name), + sock_set_errno(sock, err_to_errno(ERR_ARG)); return -1;); + SOCKADDR_TO_IPXADDR_PORT((name->sa_family == AF_INET6), name, &remote_addr, remote_port); LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_connect(%d, addr=", s)); ipX_addr_debug_print(name->sa_family == AF_INET6, SOCKETS_DEBUG, &remote_addr);