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 9e20fe2cfb)
This commit is contained in:
Dirk Ziegelmeier 2017-03-22 14:58:13 +01:00 committed by goldsimon
parent f5438b1b43
commit 0623dc4038

View File

@ -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);