Hello,

while researching usage of local variables, I've come across a segmentation fault with this construct:

set $.top = "default";
set $.top!leaf = 1;

The crash has happened in json_object_object_get because parent is a string. Quick patch attached. Perhaps the error message should be louder to warn user.


--
Pavel Levshin
diff --git a/runtime/msg.c b/runtime/msg.c
index e159bba..e30ff67 100644
--- a/runtime/msg.c
+++ b/runtime/msg.c
@@ -4030,6 +4030,12 @@ msgAddJSONObj(msg_t *pM, uchar *name, struct json_object 
*json, struct json_obje
                }
                leaf = jsonPathGetLeaf(name, ustrlen(name));
                CHKiRet(jsonPathFindParent(*pjroot, name, leaf, &parent, 1));
+               if (json_object_get_type(parent) != json_type_object) {
+                       DBGPRINTF("msgAddJSON: not a container in json path,"
+                               "name is '%s'\n", name);
+                       json_object_put(json);
+                       ABORT_FINALIZE(RS_RET_INVLD_SETOP);
+               }
                leafnode = json_object_object_get(parent, (char*)leaf);
                if(leafnode == NULL) {
                        json_object_object_add(parent, (char*)leaf, json);
_______________________________________________
rsyslog mailing list
http://lists.adiscon.net/mailman/listinfo/rsyslog
http://www.rsyslog.com/professional-services/
What's up with rsyslog? Follow https://twitter.com/rgerhards
NOTE WELL: This is a PUBLIC mailing list, posts are ARCHIVED by a myriad of 
sites beyond our control. PLEASE UNSUBSCRIBE and DO NOT POST if you DON'T LIKE 
THAT.

Reply via email to