From 6fb104a94f9d0065639d2227a163664fe878b6a3 Mon Sep 17 00:00:00 2001 From: Andreas Henriksson Date: Thu, 25 Jul 2013 22:26:32 +0200 Subject: [PATCH] Fix pointer confusion for nested attribute parsing A reference to a pointer is passed as data, the resulting attribute payload should be stored in the dereferenced location to return it to the caller. --- src/netlink.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/netlink.c b/src/netlink.c index c0b60c22..aaac8c4b 100644 --- a/src/netlink.c +++ b/src/netlink.c @@ -337,7 +337,7 @@ static int link_filter_cb (const struct nlmsghdr *nlh, #if HAVE_TCA_STATS2 static int qos_attr_cb (const struct nlattr *attr, void *data) { - struct gnet_stats_basic *bs = *(struct gnet_stats_basic **)data; + struct gnet_stats_basic **bs = (struct gnet_stats_basic **)data; /* skip unsupported attribute in user-space */ if (mnl_attr_type_valid (attr, TCA_STATS_MAX) < 0) @@ -345,12 +345,12 @@ static int qos_attr_cb (const struct nlattr *attr, void *data) if (mnl_attr_get_type (attr) == TCA_STATS_BASIC) { - if (mnl_attr_validate2 (attr, MNL_TYPE_UNSPEC, sizeof (*bs)) < 0) + if (mnl_attr_validate2 (attr, MNL_TYPE_UNSPEC, sizeof (**bs)) < 0) { ERROR ("netlink plugin: qos_attr_cb: TCA_STATS_BASIC mnl_attr_validate2 failed."); return MNL_CB_ERROR; } - bs = mnl_attr_get_payload (attr); + *bs = mnl_attr_get_payload (attr); return MNL_CB_STOP; } -- 2.30.2