[PATCH 3/7] ip6: Perform sanity check before processing NEWLINK messages
- From: Thomas Graf <tgraf redhat com>
- To: dcbw redhat com
- Cc: Thomas Graf <tgraf redhat com>, networkmanager-list gnome org
- Subject: [PATCH 3/7] ip6: Perform sanity check before processing NEWLINK messages
- Date: Fri, 9 Sep 2011 11:39:05 +0200
Verifies that provided message consists of at least the link message
header. nlmsg_parse() does this so it needs to be called prior to
accessing the message contents.
---
src/ip6-manager/nm-ip6-manager.c | 25 +++++++++++++------------
1 files changed, 13 insertions(+), 12 deletions(-)
diff --git a/src/ip6-manager/nm-ip6-manager.c b/src/ip6-manager/nm-ip6-manager.c
index f0dc7c3..a8e88be 100644
--- a/src/ip6-manager/nm-ip6-manager.c
+++ b/src/ip6-manager/nm-ip6-manager.c
@@ -970,6 +970,19 @@ process_newlink (NMIP6Manager *manager, struct nl_msg *msg)
struct nlattr *pi[IFLA_INET6_MAX + 1];
int err;
+ /* FIXME: we have to do this manually for now since libnl doesn't yet
+ * support the IFLA_PROTINFO attribute of NEWLINK messages. When it does,
+ * we can get rid of this function and just grab IFLA_PROTINFO from
+ * nm_ip6_device_sync_from_netlink(), then get the IFLA_INET6_FLAGS out of
+ * the PROTINFO.
+ */
+ err = nlmsg_parse (hdr, sizeof (*ifi), tb, IFLA_MAX, link_policy);
+ if (err < 0) {
+ nm_log_dbg (LOGD_IP6, "ignoring invalid newlink netlink message "
+ "while parsing PROTINFO attribute");
+ return NULL;
+ }
+
ifi = nlmsg_data (hdr);
if (ifi->ifi_family != AF_INET6) {
nm_log_dbg (LOGD_IP6, "ignoring netlink message family %d", ifi->ifi_family);
@@ -983,18 +996,6 @@ process_newlink (NMIP6Manager *manager, struct nl_msg *msg)
return NULL;
}
- /* FIXME: we have to do this manually for now since libnl doesn't yet
- * support the IFLA_PROTINFO attribute of NEWLINK messages. When it does,
- * we can get rid of this function and just grab IFLA_PROTINFO from
- * nm_ip6_device_sync_from_netlink(), then get the IFLA_INET6_FLAGS out of
- * the PROTINFO.
- */
-
- err = nlmsg_parse (hdr, sizeof (*ifi), tb, IFLA_MAX, link_policy);
- if (err < 0) {
- nm_log_dbg (LOGD_IP6, "(%s): error parsing PROTINFO attribute", device->iface);
- return NULL;
- }
if (!tb[IFLA_PROTINFO]) {
nm_log_dbg (LOGD_IP6, "(%s): message had no PROTINFO attribute", device->iface);
return NULL;
--
1.7.6
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]