Skip to content

Commit 46d4e24

Browse files
authored
posix os_socket_accept: stop assuming socklen_t is unsigned int (#4488)
1 parent db942f3 commit 46d4e24

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

core/shared/platform/common/posix/posix_socket.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -220,12 +220,17 @@ int
220220
os_socket_accept(bh_socket_t server_sock, bh_socket_t *sock, void *addr,
221221
unsigned int *addrlen)
222222
{
223-
*sock = accept(server_sock, addr, addrlen);
224-
223+
if (addr == NULL) {
224+
*sock = accept(server_sock, NULL, NULL);
225+
}
226+
else {
227+
socklen_t len = *addrlen;
228+
*sock = accept(server_sock, addr, &len);
229+
*addrlen = len;
230+
}
225231
if (*sock < 0) {
226232
return BHT_ERROR;
227233
}
228-
229234
return BHT_OK;
230235
}
231236

0 commit comments

Comments
 (0)