Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gnrc_sock_ip: fix memcpy()/memset() sizeof-type [2016.10-backport] #6098

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions sys/net/gnrc/sock/ip/gnrc_sock_ip.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
#include "gnrc_sock_internal.h"

int sock_ip_create(sock_ip_t *sock, const sock_ip_ep_t *local,
const sock_ip_ep_t *remote, uint8_t proto, uint16_t flags)
const sock_ip_ep_t *remote, uint8_t proto, uint16_t flags)
{
assert(sock);
if ((local != NULL) && (remote != NULL) &&
Expand All @@ -36,22 +36,22 @@ int sock_ip_create(sock_ip_t *sock, const sock_ip_ep_t *local,
(local->netif != remote->netif)) {
return -EINVAL;
}
memset(&sock->local, 0, sizeof(sock_ip_t));
memset(&sock->local, 0, sizeof(sock_ip_ep_t));
if (local != NULL) {
if (gnrc_af_not_supported(local->family)) {
return -EAFNOSUPPORT;
}
memcpy(&sock->local, local, sizeof(sock_ip_t));
memcpy(&sock->local, local, sizeof(sock_ip_ep_t));
}
memset(&sock->remote, 0, sizeof(sock_ip_t));
memset(&sock->remote, 0, sizeof(sock_ip_ep_t));
if (remote != NULL) {
if (gnrc_af_not_supported(remote->family)) {
return -EAFNOSUPPORT;
}
if (gnrc_ep_addr_any(remote)) {
return -EINVAL;
}
memcpy(&sock->remote, remote, sizeof(sock_ip_t));
memcpy(&sock->remote, remote, sizeof(sock_ip_ep_t));
}
gnrc_sock_create(&sock->reg, GNRC_NETTYPE_IPV6,
proto);
Expand Down