net: lwm2m: Reinitialize address length before recvfrom is called

`addrlen` parameter is updated on each `recvfrom` call, indicating the
actual address length returned. In case both, IPv4 and IPv6 are used on
different sockets (i. e. on regular LWM2M socket and FOTA socket), the
returned address length will differ.

In case `from_addr_len` is not reinitialized on each iteration, the
value stored in the `from_addr_len` variable will eventually indicate
the smaller IPv4 address size, therefore resulting in a failure in a
consecutive call on an IPv6 socket.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
This commit is contained in:
Robert Lubos 2020-07-01 15:34:30 +02:00 committed by Carles Cufí
commit 38adddac00

View file

@ -4124,7 +4124,6 @@ static void socket_receive_loop(void)
ssize_t len;
int i;
from_addr_len = sizeof(from_addr);
while (1) {
/* wait for sockets */
if (sock_nfds < 1) {
@ -4161,6 +4160,7 @@ static void socket_receive_loop(void)
continue;
}
from_addr_len = sizeof(from_addr);
sock_fds[i].revents = 0;
len = recvfrom(sock_ctx[i]->sock_fd, in_buf,
sizeof(in_buf) - 1, 0,