wg: account for padding being in zero attribute

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
This commit is contained in:
Jason A. Donenfeld 2017-10-17 19:20:52 +02:00
parent 88b1d35ec0
commit fe703c0cf5
1 changed files with 6 additions and 0 deletions

View File

@ -683,6 +683,8 @@ static int parse_allowedip(const struct nlattr *attr, void *data)
struct wgallowedip *allowedip = data; struct wgallowedip *allowedip = data;
switch (mnl_attr_get_type(attr)) { switch (mnl_attr_get_type(attr)) {
case WGALLOWEDIP_A_UNSPEC:
break;
case WGALLOWEDIP_A_FAMILY: case WGALLOWEDIP_A_FAMILY:
if (!mnl_attr_validate(attr, MNL_TYPE_U16)) if (!mnl_attr_validate(attr, MNL_TYPE_U16))
allowedip->family = mnl_attr_get_u16(attr); allowedip->family = mnl_attr_get_u16(attr);
@ -733,6 +735,8 @@ static int parse_peer(const struct nlattr *attr, void *data)
struct wgpeer *peer = data; struct wgpeer *peer = data;
switch (mnl_attr_get_type(attr)) { switch (mnl_attr_get_type(attr)) {
case WGPEER_A_UNSPEC:
break;
case WGPEER_A_PUBLIC_KEY: case WGPEER_A_PUBLIC_KEY:
if (mnl_attr_get_payload_len(attr) == sizeof(peer->public_key)) if (mnl_attr_get_payload_len(attr) == sizeof(peer->public_key))
memcpy(peer->public_key, mnl_attr_get_payload(attr), sizeof(peer->public_key)); memcpy(peer->public_key, mnl_attr_get_payload(attr), sizeof(peer->public_key));
@ -806,6 +810,8 @@ static int parse_device(const struct nlattr *attr, void *data)
struct wgdevice *device = data; struct wgdevice *device = data;
switch (mnl_attr_get_type(attr)) { switch (mnl_attr_get_type(attr)) {
case WGDEVICE_A_UNSPEC:
break;
case WGDEVICE_A_IFINDEX: case WGDEVICE_A_IFINDEX:
if (!mnl_attr_validate(attr, MNL_TYPE_U32)) if (!mnl_attr_validate(attr, MNL_TYPE_U32))
device->ifindex = mnl_attr_get_u32(attr); device->ifindex = mnl_attr_get_u32(attr);