From 0623dc40387680641839c6b320d6919cd3cf03f0 Mon Sep 17 00:00:00 2001 From: Dirk Ziegelmeier Date: Wed, 22 Mar 2017 14:58:13 +0100 Subject: [PATCH] Apply [patch #9287] Possible null-pointer dereference from Mikhail Lappo in a modified way Moved the debug output to a location where we know that newpcb != NULL Fixes possible NULL pointer dereferencing in debug message output (cherry picked from commit 9e20fe2cfb01428e366e97fc0366cff9920ae921) --- src/api/api_msg.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/api/api_msg.c b/src/api/api_msg.c index dd99c1e0..edfce1e1 100644 --- a/src/api/api_msg.c +++ b/src/api/api_msg.c @@ -471,8 +471,6 @@ accept_function(void *arg, struct tcp_pcb *newpcb, err_t err) struct netconn *newconn; struct netconn *conn = (struct netconn *)arg; - LWIP_DEBUGF(API_MSG_DEBUG, ("accept_function: newpcb->tate: %s\n", tcp_debug_state_str(newpcb->state))); - if (conn == NULL) { return ERR_VAL; } @@ -490,6 +488,8 @@ accept_function(void *arg, struct tcp_pcb *newpcb, err_t err) return ERR_VAL; } + LWIP_DEBUGF(API_MSG_DEBUG, ("accept_function: newpcb->tate: %s\n", tcp_debug_state_str(newpcb->state))); + /* We have to set the callback here even though * the new socket is unknown. newconn->socket is marked as -1. */ newconn = netconn_alloc(conn->type, conn->callback);