diff options
author | Miloslav Trmač <mitr@redhat.com> | 2012-09-03 18:59:59 +0200 |
---|---|---|
committer | Rainer Gerhards <rgerhards@adiscon.com> | 2012-09-04 10:18:52 +0200 |
commit | 2e9d740103c93cbe0cd084d7f3c70ff02e53a637 (patch) | |
tree | 2e2b7855f3eb7e52553d7e5e2943161c2a7ddd8e /plugins | |
parent | c27f5446c982c4caebdefe5cb8108d0a869b59a5 (diff) | |
download | rsyslog-2e9d740103c93cbe0cd084d7f3c70ff02e53a637.tar.gz rsyslog-2e9d740103c93cbe0cd084d7f3c70ff02e53a637.tar.xz rsyslog-2e9d740103c93cbe0cd084d7f3c70ff02e53a637.zip |
Don't store uninitialized data in trusted JSON properties
Add missing error handling.
Signed-off-by: Miloslav Trmač <mitr@redhat.com>
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/imuxsock/imuxsock.c | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/plugins/imuxsock/imuxsock.c b/plugins/imuxsock/imuxsock.c index 9d273a3d..61ce857c 100644 --- a/plugins/imuxsock/imuxsock.c +++ b/plugins/imuxsock/imuxsock.c @@ -817,15 +817,18 @@ SubmitMsg(uchar *pRcv, int lenRcv, lstn_t *pLstn, struct ucred *cred, struct tim json_object_object_add(json, "uid", jval); jval = json_object_new_int(cred->gid); json_object_object_add(json, "gid", jval); - getTrustedProp(cred, "comm", propBuf, sizeof(propBuf), &lenProp); - jval = json_object_new_string((char*)propBuf); - json_object_object_add(json, "appname", jval); - getTrustedExe(cred, propBuf, sizeof(propBuf), &lenProp); - jval = json_object_new_string((char*)propBuf); - json_object_object_add(json, "exe", jval); - getTrustedProp(cred, "cmdline", propBuf, sizeof(propBuf), &lenProp); - jval = json_object_new_string((char*)propBuf); - json_object_object_add(json, "cmd", jval); + if(getTrustedProp(cred, "comm", propBuf, sizeof(propBuf), &lenProp) == RS_RET_OK) { + jval = json_object_new_string((char*)propBuf); + json_object_object_add(json, "appname", jval); + } + if(getTrustedExe(cred, propBuf, sizeof(propBuf), &lenProp) == RS_RET_OK) { + jval = json_object_new_string((char*)propBuf); + json_object_object_add(json, "exe", jval); + } + if(getTrustedProp(cred, "cmdline", propBuf, sizeof(propBuf), &lenProp) == RS_RET_OK) { + jval = json_object_new_string((char*)propBuf); + json_object_object_add(json, "cmd", jval); + } } else { memcpy(pmsgbuf, pRcv, lenRcv); memcpy(pmsgbuf+lenRcv, " @[", 3); |