diff options
author | Thomas Haller <thaller@redhat.com> | 2018-12-03 13:41:39 +0100 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2018-12-03 13:47:42 +0100 |
commit | d45eed4437fda2bf84a4e5023d99873c42cadf84 (patch) | |
tree | ba2c3826e01fd16cdb6f41c3fe51e14a811b7b61 | |
parent | 5fb800125fd753c7d7ba66f1ad1eaa899b73741e (diff) |
core: avoid calling platform code with invalid ifindex
Since commit 945c904f956 "platform: assert against valid ifindex and
remove duplicate assertions", it is no longer allowed to call certain
platform functions with invalid ifindex.
These trigger now an assertion. Note that the assertion is merely a
g_return_val_if_fail(), hence in non-debug mode, this does not lead to
a crash.
Fixes: 945c904f956580616f0d71b13c63f525c184060c
-rw-r--r-- | src/devices/nm-acd-manager.c | 2 | ||||
-rw-r--r-- | src/devices/nm-device.c | 3 | ||||
-rw-r--r-- | src/devices/nm-lldp-listener.c | 2 |
3 files changed, 4 insertions, 3 deletions
diff --git a/src/devices/nm-acd-manager.c b/src/devices/nm-acd-manager.c index 42dff5379..7be0374ba 100644 --- a/src/devices/nm-acd-manager.c +++ b/src/devices/nm-acd-manager.c @@ -65,7 +65,7 @@ struct _NMAcdManager { char _sbuf[64]; \ \ nm_log ((level), _NMLOG_DOMAIN, \ - self ? nm_platform_link_get_name (NM_PLATFORM_GET, self->ifindex) : "", \ + self && self->ifindex > 0 ? nm_platform_link_get_name (NM_PLATFORM_GET, self->ifindex) : NULL, \ NULL, \ "%s%s: " _NM_UTILS_MACRO_FIRST (__VA_ARGS__), \ _NMLOG_PREFIX_NAME, \ diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c index c2223a985..3e48f2005 100644 --- a/src/devices/nm-device.c +++ b/src/devices/nm-device.c @@ -4846,7 +4846,8 @@ nm_device_master_release_slaves (NMDevice *self) if (priv->state == NM_DEVICE_STATE_FAILED) reason = NM_DEVICE_STATE_REASON_DEPENDENCY_FAILED; - if (!nm_platform_link_get (nm_device_get_platform (self), priv->ifindex)) + if ( priv->ifindex <= 0 + || !nm_platform_link_get (nm_device_get_platform (self), priv->ifindex)) configure = FALSE; c_list_for_each_safe (iter, safe, &priv->slaves) { diff --git a/src/devices/nm-lldp-listener.c b/src/devices/nm-lldp-listener.c index c0484ed30..ae1806370 100644 --- a/src/devices/nm-lldp-listener.c +++ b/src/devices/nm-lldp-listener.c @@ -128,7 +128,7 @@ typedef struct { int _ifindex = (self) ? NM_LLDP_LISTENER_GET_PRIVATE (self)->ifindex : 0; \ \ _nm_log (_level, _NMLOG_DOMAIN, 0, \ - nm_platform_link_get_name (NM_PLATFORM_GET, _ifindex), \ + _ifindex > 0 ? nm_platform_link_get_name (NM_PLATFORM_GET, _ifindex) : NULL, \ NULL, \ "%s%s: " _NM_UTILS_MACRO_FIRST (__VA_ARGS__), \ _NMLOG_PREFIX_NAME, \ |