summaryrefslogtreecommitdiffstats
path: root/runtime/stream.c
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2013-05-16 07:58:50 +0200
committerRainer Gerhards <rgerhards@adiscon.com>2013-05-16 07:58:50 +0200
commit3aeafbdfadc73860a16dc965c14728a3e50a216c (patch)
tree7013d8e047c6fb802b012c1b4ea8651cd4176037 /runtime/stream.c
parent940bdc4c4117117beb7e34c84e5ea5bd3f441d4f (diff)
downloadrsyslog-3aeafbdfadc73860a16dc965c14728a3e50a216c.tar.gz
rsyslog-3aeafbdfadc73860a16dc965c14728a3e50a216c.tar.bz2
rsyslog-3aeafbdfadc73860a16dc965c14728a3e50a216c.zip
properly handle padding bytes when reading queue files
Diffstat (limited to 'runtime/stream.c')
-rw-r--r--runtime/stream.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/runtime/stream.c b/runtime/stream.c
index 0cac4f07..a26f2451 100644
--- a/runtime/stream.c
+++ b/runtime/stream.c
@@ -559,11 +559,12 @@ finalize_it:
* rgerhards, 2008-02-13
*/
static rsRetVal
-strmReadBuf(strm_t *pThis)
+strmReadBuf(strm_t *pThis, int *padBytes)
{
DEFiRet;
int bRun;
long iLenRead;
+ size_t actualDataLen;
ISOBJ_TYPE_assert(pThis, strm);
/* We need to try read at least twice because we may run into EOF and need to switch files. */
@@ -584,8 +585,11 @@ strmReadBuf(strm_t *pThis)
else { /* good read */
/* here we place our crypto interface */
if(pThis->cryprov != NULL) {
- pThis->cryprov->Decrypt(pThis->cryprovFileData, pThis->pIOBuf, &iLenRead);
-dbgprintf("DDDD: data read, decrypted: %1024.1024s\n", pThis->pIOBuf);
+ actualDataLen = iLenRead;
+ pThis->cryprov->Decrypt(pThis->cryprovFileData, pThis->pIOBuf, &actualDataLen);
+ *padBytes = iLenRead - actualDataLen;
+ iLenRead = actualDataLen;
+dbgprintf("DDDD: data read (padBytes %d), decrypted: %1024.1024s\n", *padBytes, pThis->pIOBuf);
}
pThis->iBufPtrMax = iLenRead;
bRun = 0; /* exit loop */
@@ -608,6 +612,7 @@ finalize_it:
*/
static rsRetVal strmReadChar(strm_t *pThis, uchar *pC)
{
+ int padBytes = 0; /* in crypto mode, we may have some padding (non-data) bytes */
DEFiRet;
ASSERT(pThis != NULL);
@@ -623,8 +628,9 @@ static rsRetVal strmReadChar(strm_t *pThis, uchar *pC)
/* do we need to obtain a new buffer? */
if(pThis->iBufPtr >= pThis->iBufPtrMax) {
- CHKiRet(strmReadBuf(pThis));
+ CHKiRet(strmReadBuf(pThis, &padBytes));
}
+ pThis->iCurrOffs += padBytes;
/* if we reach this point, we have data available in the buffer */
@@ -1495,7 +1501,6 @@ static rsRetVal strmSeekCurrOffs(strm_t *pThis)
ISOBJ_TYPE_assert(pThis, strm);
-dbgprintf("DDDD: seekCurrOffs file #%d, offs %lld\n", pThis->fd, (long long) pThis->iCurrOffs);
if(pThis->cryprov == NULL || pThis->tOperationsMode != STREAMMODE_READ) {
iRet = strmSeek(pThis, pThis->iCurrOffs);
FINALIZE;