From fcd2daf57cfec0d6572601c905d2d0d92464e777 Mon Sep 17 00:00:00 2001 From: Thomas Mueller Date: Fri, 16 Dec 2016 15:44:00 +0100 Subject: [PATCH] fixed race condition in return value of netconn_gethostbyname() (and thus also lwip_gethostbyname/_r() and lwip_getaddrinfo()) Signed-off-by: sg --- CHANGELOG | 4 ++++ src/api/api_lib.c | 7 ++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 8877eaee..4371f02e 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -26,6 +26,10 @@ HISTORY ++ Bugfixes: + 2016-12-16: Thomas Mueller + * api_lib.c: fixed race condition in return value of netconn_gethostbyname() + (and thus also lwip_gethostbyname/_r() and lwip_getaddrinfo()) + 2016-12-15: David van Moolenbroek * opt.h, tcp: added LWIP_HOOK_TCP_ISN() to implement less predictable initial sequence numbers (see contrib/addons/tcp_isn for an example implementation) diff --git a/src/api/api_lib.c b/src/api/api_lib.c index 1e356aa0..98f232d8 100644 --- a/src/api/api_lib.c +++ b/src/api/api_lib.c @@ -932,6 +932,7 @@ netconn_gethostbyname(const char *name, ip_addr_t *addr) sys_sem_t sem; #endif /* LWIP_MPU_COMPATIBLE */ err_t err; + err_t cberr; LWIP_ERROR("netconn_gethostbyname: invalid name", (name != NULL), return ERR_ARG;); LWIP_ERROR("netconn_gethostbyname: invalid addr", (addr != NULL), return ERR_ARG;); @@ -964,13 +965,13 @@ netconn_gethostbyname(const char *name, ip_addr_t *addr) } #endif /* LWIP_NETCONN_SEM_PER_THREAD */ - err = tcpip_callback(lwip_netconn_do_gethostbyname, &API_VAR_REF(msg)); - if (err != ERR_OK) { + cberr = tcpip_callback(lwip_netconn_do_gethostbyname, &API_VAR_REF(msg)); + if (cberr != ERR_OK) { #if !LWIP_NETCONN_SEM_PER_THREAD sys_sem_free(API_EXPR_REF(API_VAR_REF(msg).sem)); #endif /* !LWIP_NETCONN_SEM_PER_THREAD */ API_VAR_FREE(MEMP_DNS_API_MSG, msg); - return err; + return cberr; } sys_sem_wait(API_EXPR_REF_SEM(API_VAR_REF(msg).sem)); #if !LWIP_NETCONN_SEM_PER_THREAD