summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2016-04-20 11:44:23 +0200
committerThomas Haller <thaller@redhat.com>2016-04-20 12:09:40 +0200
commiteab817d34a38227a79b10e9c52d450bb8c7fa907 (patch)
tree69df8e799b875b64b288930b2c8f09c338ddb576
parent843a05f7cc95f864bb898f670cb6adbdf813dfce (diff)
downloadNetworkManager-eab817d34a38227a79b10e9c52d450bb8c7fa907.tar.gz
platform: restrict valid p_key for infiniband partitions
-rw-r--r--src/platform/nm-linux-platform.c2
-rw-r--r--src/platform/nm-platform.c6
2 files changed, 7 insertions, 1 deletions
diff --git a/src/platform/nm-linux-platform.c b/src/platform/nm-linux-platform.c
index 254f9c855d..f550a85cfa 100644
--- a/src/platform/nm-linux-platform.c
+++ b/src/platform/nm-linux-platform.c
@@ -5085,6 +5085,8 @@ _infiniband_partition_action (NMPlatform *platform, int parent, int p_key, const
gs_free char *path = NULL;
gs_free char *id = NULL;
+ nm_assert (p_key > 0 && p_key <= 0xffff && p_key != 0x8000);
+
obj_parent = nmp_cache_lookup_link (priv->cache, parent);
if (!obj_parent || !obj_parent->link.name[0])
g_return_val_if_reached (FALSE);
diff --git a/src/platform/nm-platform.c b/src/platform/nm-platform.c
index 0139867a0c..43532ebf3e 100644
--- a/src/platform/nm-platform.c
+++ b/src/platform/nm-platform.c
@@ -1902,7 +1902,11 @@ _infiniband_add_add_or_delete (NMPlatform *self,
_CHECK_SELF (self, klass, NM_PLATFORM_ERROR_BUG);
g_return_val_if_fail (parent >= 0, NM_PLATFORM_ERROR_BUG);
- g_return_val_if_fail (p_key >= 0, NM_PLATFORM_ERROR_BUG);
+ g_return_val_if_fail (p_key >= 0 && p_key <= 0xffff, NM_PLATFORM_ERROR_BUG);
+
+ /* the special keys 0x0000 and 0x8000 are not allowed. */
+ if (NM_IN_SET (p_key, 0, 0x8000))
+ return NM_PLATFORM_ERROR_UNSPECIFIED;
parent_link = nm_platform_link_get (self, parent);
if (!parent_link)