proto: allow dumping protocol handlers without config_params
authorOlof Sivertsson <osivertsson@gmail.com>
Wed, 3 Jan 2018 09:35:13 +0000 (10:35 +0100)
committerHans Dedecker <dedeckeh@gmail.com>
Wed, 3 Jan 2018 15:57:43 +0000 (16:57 +0100)
When ubus invokes proto_dump_handlers, and a struct proto_handler has
been added with a NULL config_params, a segmentation fault occurs.

Avoid this segmentation fault by checking for a NULL config_params
before further access.

Signed-off-by: Olof Sivertsson <olof.sivertsson@zenterio.com>
proto.c

diff --git a/proto.c b/proto.c
index 9eb31c5e778b9c7818ff156354be2d2ce714e150..6047735daec00d4a595110fd1b3fb687d8b13c2e 100644 (file)
--- a/proto.c
+++ b/proto.c
@@ -591,7 +591,7 @@ proto_dump_handlers(struct blob_buf *b)
                void *v;
 
                c = blobmsg_open_table(b, p->name);
-               if (p->config_params->validate) {
+               if (p->config_params && p->config_params->validate) {
                        int i;
 
                        v = blobmsg_open_table(b, "validate");