Skip to content

Commit

Permalink
lib/posix-socket: Fix raddr set call in uk_sys_accept
Browse files Browse the repository at this point in the history
uk_socket_evd_raddr_set receives *addr_len as an input parameter,
which means that NullPointerException is generated when addr_len is
NULL. Also, al->evd structure is present only when
CONFIG_LIBPOSIX_SOCKET_EVENTS enabled so wrapping usages under #ifdef.

Signed-off-by: Oleksii Moisieiev <[email protected]>
Reviewed-by: Michalis Pappas <[email protected]>
Approved-by: Simon Kuenzer <[email protected]>
GitHub-Closes: unikraft#1269
  • Loading branch information
oleksiimoisieiev authored and razvand committed Jan 23, 2024
1 parent 4567716 commit 255f72f
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/posix-socket/socket.c
Original file line number Diff line number Diff line change
Expand Up @@ -341,9 +341,11 @@ int uk_sys_accept(const struct uk_file *sock, int blocking,
_socket_init(al, n->driver, new_data);

al_listener = __containerof(sock, struct socket_alloc, f);
#if CONFIG_LIBPOSIX_SOCKET_EVENTS
uk_socket_evd_init_from(&al->evd, &al_listener->evd);
uk_socket_evd_laddr_set_from(&al->evd, &al_listener->evd);
uk_socket_evd_raddr_set(&al->evd, addr, *addr_len);
uk_socket_evd_raddr_set(&al->evd, addr, (addr_len ? *addr_len : 0));
#endif /* CONFIG_LIBPOSIX_SOCKET_EVENTS */

if (flags & SOCK_NONBLOCK)
mode |= O_NONBLOCK;
Expand Down

0 comments on commit 255f72f

Please sign in to comment.