diff options
author | Rainer Gerhards <rgerhards@adiscon.com> | 2013-09-26 14:55:47 +0200 |
---|---|---|
committer | Rainer Gerhards <rgerhards@adiscon.com> | 2013-09-26 14:55:47 +0200 |
commit | dfae5feb8c09c285a7af403f07a18254d0a86ad3 (patch) | |
tree | c9622a02caa86218c8b31ed1df261bbb88a7544f /runtime/msg.c | |
parent | b810f0dd3ade85efeb7dc9b99fade798764d0ac2 (diff) | |
download | rsyslog-dfae5feb8c09c285a7af403f07a18254d0a86ad3.tar.gz rsyslog-dfae5feb8c09c285a7af403f07a18254d0a86ad3.tar.bz2 rsyslog-dfae5feb8c09c285a7af403f07a18254d0a86ad3.zip |
mmrfc5424addhmac: correctly handle empty structured data
Diffstat (limited to 'runtime/msg.c')
-rw-r--r-- | runtime/msg.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/runtime/msg.c b/runtime/msg.c index 18f72086..85f83502 100644 --- a/runtime/msg.c +++ b/runtime/msg.c @@ -4073,10 +4073,14 @@ MsgAddToStructuredData(msg_t *pMsg, uchar *toadd, rs_size_t len) uchar *newptr; rs_size_t newlen; DEFiRet; - newlen = pMsg->lenStrucData + len; + newlen = (pMsg->pszStrucData[0] == '-') ? len : pMsg->lenStrucData + len; CHKmalloc(newptr = (uchar*) realloc(pMsg->pszStrucData, newlen+1)); pMsg->pszStrucData = newptr; - memcpy(pMsg->pszStrucData+pMsg->lenStrucData, toadd, len); + if(pMsg->pszStrucData[0] == '-') { /* empty? */ + memcpy(pMsg->pszStrucData, toadd, len); + } else { + memcpy(pMsg->pszStrucData+pMsg->lenStrucData, toadd, len); + } pMsg->pszStrucData[newlen] = '\0'; pMsg->lenStrucData = newlen; finalize_it: |