session: ignore non-string username attribute upon restore
authorJo-Philipp Wich <jo@mein.io>
Thu, 15 Mar 2018 11:22:34 +0000 (12:22 +0100)
committerJo-Philipp Wich <jo@mein.io>
Thu, 15 Mar 2018 11:29:15 +0000 (12:29 +0100)
When restoring session information from blob data, only consider the
embedded username attribute if it is a string value.

Other types may cause invalid memory accesses when attempting to strcmp()
the attribute value.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
session.c

index 3bef025bf23ba852fbaf7e9b8f3bf2a252bf7c64..3ed45197ab9d039e89a189f6bb5c152fa60c61a8 100644 (file)
--- a/session.c
+++ b/session.c
@@ -1288,6 +1288,9 @@ rpc_session_from_blob(struct uci_context *uci, struct blob_attr *attr)
        blobmsg_for_each_attr(data, tb[RPC_DUMP_DATA], rem) {
                rpc_session_set(ses, data);
 
+               if (blobmsg_type(data) != BLOBMSG_TYPE_STRING)
+                       continue;
+
                if (!strcmp(blobmsg_name(data), "username"))
                        user = blobmsg_get_string(data);
        }