Merge pull request #10331 from miri64/emb6/fix/sock-info-src

emb6_sock_udp: copy receive remote correctly
This commit is contained in:
José Alamos 2018-11-06 11:52:21 +01:00 committed by GitHub
commit 1f6ea0ec08
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -187,7 +187,7 @@ int sock_udp_recv(sock_udp_t *sock, void *data, size_t max_len,
if (remote != NULL) { if (remote != NULL) {
remote->family = AF_INET6; remote->family = AF_INET6;
remote->netif = SOCK_ADDR_ANY_NETIF; remote->netif = SOCK_ADDR_ANY_NETIF;
memcpy(&remote->addr, &sock->recv_info.src, sizeof(ipv6_addr_t)); memcpy(&remote->addr, sock->recv_info.src, sizeof(ipv6_addr_t));
remote->port = sock->recv_info.src_port; remote->port = sock->recv_info.src_port;
} }
res = (int)sock->recv_info.datalen; res = (int)sock->recv_info.datalen;
@ -235,11 +235,11 @@ int sock_udp_send(sock_udp_t *sock, const void *data, size_t len,
else if (sock->sock.udp_conn->rport == 0) { else if (sock->sock.udp_conn->rport == 0) {
return -ENOTCONN; return -ENOTCONN;
} }
/* cppcheck-supress nullPointerRedundantCheck /* cppcheck-suppress nullPointerRedundantCheck
* remote == NULL implies that sock != NULL (see assert at start of * (reason: remote == NULL implies that sock != NULL (see assert at start of
* function) * that's why it is okay in the if-statement above to check * function) * that's why it is okay in the if-statement above to check
* sock->... without checking (sock != NULL) first => this check afterwards * sock->... without checking (sock != NULL) first => this check afterwards
* isn't redundant */ * isn't redundant) */
if (sock == NULL) { if (sock == NULL) {
int res; int res;
if ((res = _reg(&tmp, NULL, NULL, NULL, NULL)) < 0) { if ((res = _reg(&tmp, NULL, NULL, NULL, NULL)) < 0) {