Skip to content

Commit 98db4d9

Browse files
AndreyDodonov-EHcfriedt
authored andcommitted
net: lib: http_server: prevent busfault if socket family is AF_UNSPEC
If webserver uses custom socket creation, and it's family is AF_UNSPEC, net_sprint_addr will return NULL, which leads to LOG_DBG crashing with busfault. Add NULL check for that. Signed-off-by: Andrey Dodonov <[email protected]>
1 parent a317f19 commit 98db4d9

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

subsys/net/lib/http/http_server_core.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -276,8 +276,9 @@ static int accept_new_client(int server_fd)
276276
return new_socket;
277277
}
278278

279-
LOG_DBG("New client from %s:%d",
280-
net_sprint_addr(sa.ss_family, &net_sin((struct sockaddr *)&sa)->sin_addr),
279+
const char * const addrstr =
280+
net_sprint_addr(sa.ss_family, &net_sin((struct sockaddr *)&sa)->sin_addr);
281+
LOG_DBG("New client from %s:%d", addrstr != NULL ? addrstr : "<unknown>",
281282
ntohs(net_sin((struct sockaddr *)&sa)->sin_port));
282283

283284
return new_socket;

0 commit comments

Comments
 (0)