aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJiri Pirko <jiri@resnulli.us>2014-12-18 20:00:25 +0100
committerJiri Pirko <jiri@resnulli.us>2014-12-18 20:00:25 +0100
commit5c7ab994287e046260a1e4c457840c909072c412 (patch)
tree0f0a9e2a26238ec9c358e0699a31fd4690d09e40
parent7b13dfad38f43e2a32caba076b25900afaf26ea0 (diff)
downloadlibteam-5c7ab994287e046260a1e4c457840c909072c412.tar.gz
libteam: check phys_port_id_len in update_phys_port_id
Signed-off-by: Jiri Pirko <jiri@resnulli.us>
-rw-r--r--libteam/ifinfo.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/libteam/ifinfo.c b/libteam/ifinfo.c
index 484ac1b..a6e384c 100644
--- a/libteam/ifinfo.c
+++ b/libteam/ifinfo.c
@@ -149,6 +149,8 @@ static void update_phys_port_id(struct team_ifinfo *ifinfo,
nl_data = rtnl_link_get_phys_port_id(link);
if (nl_data) {
phys_port_id_len = nl_data_get_size(nl_data);
+ if (phys_port_id_len > MAX_PHYS_PORT_ID_LEN)
+ phys_port_id_len = 0;
phys_port_id = nl_data_get(nl_data);
}
@@ -156,7 +158,8 @@ static void update_phys_port_id(struct team_ifinfo *ifinfo,
ifinfo->phys_port_id_len = phys_port_id_len;
set_changed(ifinfo, CHANGED_PHYS_PORT_ID_LEN);
}
- if (memcmp(ifinfo->phys_port_id, phys_port_id, phys_port_id_len)) {
+ if (phys_port_id_len &&
+ memcmp(ifinfo->phys_port_id, phys_port_id, phys_port_id_len)) {
memcpy(ifinfo->phys_port_id, phys_port_id, phys_port_id_len);
set_changed(ifinfo, CHANGED_PHYS_PORT_ID);
}