diff options
author | Rainer Gerhards <rgerhards@adiscon.com> | 2008-03-14 18:20:38 +0000 |
---|---|---|
committer | Rainer Gerhards <rgerhards@adiscon.com> | 2008-03-14 18:20:38 +0000 |
commit | b1dac8fddae882918ca3dbe1ffbd6386119a13c7 (patch) | |
tree | c2ff331f0aba6175503ba30648cd7822b171037d /tcps_sess.c | |
parent | 29b95dc1c1cc8020e3fb7d00610fb226cae1bd98 (diff) | |
download | rsyslog-b1dac8fddae882918ca3dbe1ffbd6386119a13c7.tar.gz rsyslog-b1dac8fddae882918ca3dbe1ffbd6386119a13c7.tar.xz rsyslog-b1dac8fddae882918ca3dbe1ffbd6386119a13c7.zip |
oversize message handling in TCP/GSSAPI receiver
Diffstat (limited to 'tcps_sess.c')
-rw-r--r-- | tcps_sess.c | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/tcps_sess.c b/tcps_sess.c index 2a6b300a..4b619da1 100644 --- a/tcps_sess.c +++ b/tcps_sess.c @@ -249,7 +249,6 @@ processDataRcvd(tcps_sess_t *pThis, char c) DEFiRet; ISOBJ_TYPE_assert(pThis, tcps_sess); -dbgprintf("processDataRcvd char %c, state %d\n", c, pThis->inputState); if(pThis->inputState == eAtStrtFram) { if(isdigit((int) c)) { pThis->inputState = eInOctetCnt; @@ -275,6 +274,14 @@ dbgprintf("processDataRcvd char %c, state %d\n", c, pThis->inputState); dbgprintf("Framing Error: invalid octet count\n"); errmsg.LogError(NO_ERRCODE, "Framing Error in received TCP message: " "invalid octet count %d.\n", pThis->iOctetsRemain); + } else if(pThis->iOctetsRemain > MAXLINE) { + /* while we can not do anything against it, we can at least log an indication + * that something went wrong) -- rgerhards, 2008-03-14 + */ + dbgprintf("truncating message with %d octets - MAXLINE is %d\n", + pThis->iOctetsRemain, MAXLINE); + errmsg.LogError(NO_ERRCODE, "received oversize message: size is %d bytes, " + "MAXLINE is %d, truncating...\n", pThis->iOctetsRemain, MAXLINE); } pThis->inputState = eInMsg; } @@ -297,8 +304,13 @@ dbgprintf("processDataRcvd char %c, state %d\n", c, pThis->inputState); pThis->iMsg = 0; pThis->inputState = eAtStrtFram; } else { - /* IMPORTANT: here we copy the actual frame content to the message! */ - *(pThis->msg + pThis->iMsg++) = c; + /* IMPORTANT: here we copy the actual frame content to the message - for BOTH framing modes! + * If we have a message that is larger than MAXLINE, we truncate it. This is the best + * we can do in light of what the engine supports. -- rgerhards, 2008-03-14 + */ + if(pThis->iMsg < MAXLINE) { + *(pThis->msg + pThis->iMsg++) = c; + } } if(pThis->eFraming == TCP_FRAMING_OCTET_COUNTING) { |