1
0

In net.c sockaddr structures' had their *_len fields set to 0, so recvfrom didn't fill an inaddr field.

This commit is contained in:
Alexander Andreev 2024-03-25 05:02:05 +04:00
parent 58c3b3fada
commit b225b63cdf
Signed by: Arav
GPG Key ID: 25969B23DCB5CA34

View File

@ -33,6 +33,7 @@ int net_client_init(net_t *const n, const char *const raddr, const char *const r
memset(&n->raddr, 0, sizeof(n->raddr)); memset(&n->raddr, 0, sizeof(n->raddr));
memcpy(&n->raddr, cri->ai_addr, sizeof(n->raddr)); memcpy(&n->raddr, cri->ai_addr, sizeof(n->raddr));
n->raddr_len = sizeof(n->raddr);
freeaddrinfo(ri); freeaddrinfo(ri);
@ -69,9 +70,10 @@ int net_server_init(net_t *const n, const char *const laddr, const char *const l
} }
memset(&n->inaddr, 0, sizeof(n->inaddr)); memset(&n->inaddr, 0, sizeof(n->inaddr));
n->inaddr_len = 0; n->inaddr_len = sizeof(n->inaddr);
memset(&n->raddr, 0, sizeof(n->raddr)); memset(&n->raddr, 0, sizeof(n->raddr));
n->raddr_len = sizeof(n->raddr);
memset(&n->laddr, 0, sizeof(n->laddr)); memset(&n->laddr, 0, sizeof(n->laddr));
memcpy(&n->laddr, cli->ai_addr, sizeof(n->raddr)); memcpy(&n->laddr, cli->ai_addr, sizeof(n->raddr));
@ -88,10 +90,10 @@ void net_destroy(net_t *n) {
} }
memset(&n->raddr, 0, sizeof(n->raddr)); memset(&n->raddr, 0, sizeof(n->raddr));
n->raddr_len = 0; n->raddr_len = sizeof(n->raddr);
memset(&n->laddr, 0, sizeof(n->laddr)); memset(&n->laddr, 0, sizeof(n->laddr));
memset(&n->inaddr, 0, sizeof(n->inaddr)); memset(&n->inaddr, 0, sizeof(n->inaddr));
n->inaddr_len = 0; n->inaddr_len = sizeof(n->inaddr);
} }
ssize_t net_send(net_t *const n, const char *const buf, int buf_len) { ssize_t net_send(net_t *const n, const char *const buf, int buf_len) {