diff options
author | Jo-Philipp Wich <jo@mein.io> | 2021-11-02 23:00:20 +0100 |
---|---|---|
committer | Jo-Philipp Wich <jo@mein.io> | 2021-11-02 23:23:00 +0100 |
commit | eaaaf88a3a40d364b3950dbefc554b80cdc85845 (patch) | |
tree | e2115daf6781693a6dc19110f92fc53c52642986 /lib | |
parent | a0512eaf305d54661adec6893154161e5be01b2e (diff) |
nl80211: fix wiphy dump reply merge logic
Extract the wiphy index from the response message and use it to select
the item to merge the fragment information into.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/nl80211.c | 35 |
1 files changed, 20 insertions, 15 deletions
diff --git a/lib/nl80211.c b/lib/nl80211.c index 0352eab..45c2bf4 100644 --- a/lib/nl80211.c +++ b/lib/nl80211.c @@ -1918,7 +1918,8 @@ cb_reply(struct nl_msg *msg, void *arg) struct nlmsghdr *hdr = nlmsg_hdr(msg); struct genlmsghdr *gnlh = nlmsg_data(hdr); request_state_t *s = arg; - uc_value_t *o; + uc_value_t *o, *idx; + int64_t i; bool rv; o = ucv_object_new(s->vm); @@ -1929,23 +1930,27 @@ cb_reply(struct nl_msg *msg, void *arg) if (rv) { if (hdr->nlmsg_flags & NLM_F_MULTI) { - if (!s->res) { - if (s->merge) { - s->res = o; - } - else { - s->res = ucv_array_new(s->vm); - ucv_array_push(s->res, o); + if (!s->res) + s->res = ucv_array_new(s->vm); + + if (s->merge) { + idx = ucv_object_get(o, "wiphy", NULL); + i = idx ? ucv_int64_get(idx) : -1; + + if (i >= 0) { + idx = ucv_array_get(s->res, i); + + if (idx) { + deep_merge_object(idx, o); + ucv_put(o); + } + else { + ucv_array_set(s->res, i, o); + } } } else { - if (s->merge) { - deep_merge_object(s->res, o); - ucv_put(o); - } - else { - ucv_array_push(s->res, o); - } + ucv_array_push(s->res, o); } } else { |