summaryrefslogtreecommitdiffstats
path: root/runtime/msg.c
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2012-09-03 20:15:50 +0200
committerRainer Gerhards <rgerhards@adiscon.com>2012-09-03 20:15:50 +0200
commitd8e7609abbda70ea5daae8de40749e7377bf99c2 (patch)
tree68b605aa6ce2cae4055b96c817d9928f8fa9ee8b /runtime/msg.c
parentb964910868b53bcc2fea96b170255a1de6e7994d (diff)
downloadrsyslog-d8e7609abbda70ea5daae8de40749e7377bf99c2.tar.gz
rsyslog-d8e7609abbda70ea5daae8de40749e7377bf99c2.tar.xz
rsyslog-d8e7609abbda70ea5daae8de40749e7377bf99c2.zip
bugfix: specifying json root in a template lead to abort
Thanks to Miloslav Trmač for alerting us of this problem.
Diffstat (limited to 'runtime/msg.c')
-rw-r--r--runtime/msg.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/runtime/msg.c b/runtime/msg.c
index a89a01d2..afc79042 100644
--- a/runtime/msg.c
+++ b/runtime/msg.c
@@ -2420,16 +2420,20 @@ getCEEPropVal(msg_t *pM, es_str_t *propName, uchar **pRes, int *buflen, unsigned
if(*pbMustBeFreed)
free(*pRes);
*pRes = NULL;
-dbgprintf("AAAA: enter getCEEProp\n");
+dbgprintf("AAAA: enter getCEEPropVal\n");
// TODO: mutex?
if(pM->json == NULL) goto finalize_it;
- name = (uchar*)es_str2cstr(propName, NULL);
+ if(!es_strbufcmp(propName, (uchar*)"!", 1)) {
+ field = pM->json;
+ } else {
+ name = (uchar*)es_str2cstr(propName, NULL);
dbgprintf("AAAA: name to search '%s'\n", name);
- leaf = jsonPathGetLeaf(name, ustrlen(name));
+ leaf = jsonPathGetLeaf(name, ustrlen(name));
dbgprintf("AAAA: leaf '%s'\n", leaf);
- CHKiRet(jsonPathFindParent(pM, name, leaf, &parent, 1));
- field = json_object_object_get(parent, (char*)leaf);
+ CHKiRet(jsonPathFindParent(pM, name, leaf, &parent, 1));
+ field = json_object_object_get(parent, (char*)leaf);
+ }
*pRes = (uchar*) strdup(json_object_get_string(field));
dbgprintf("AAAA: json_object_get_string() returns '%s'\n", *pRes);
*buflen = (int) ustrlen(*pRes);
@@ -2462,6 +2466,10 @@ dbgprintf("AAAA: enter getCEEPropJSON\n");
ABORT_FINALIZE(RS_RET_NOT_FOUND);
}
+ if(!es_strbufcmp(propName, (uchar*)"!", 1)) {
+ *pjson = pM->json;
+ FINALIZE;
+ }
name = (uchar*)es_str2cstr(propName, NULL);
dbgprintf("AAAA: name to search '%s'\n", name);
leaf = jsonPathGetLeaf(name, ustrlen(name));