summaryrefslogtreecommitdiffstats
path: root/runtime/stream.c
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2013-05-16 09:49:22 +0200
committerRainer Gerhards <rgerhards@adiscon.com>2013-05-16 09:49:22 +0200
commitafe14ce2f6a514d9e2bf43501f1a02008d9ddea6 (patch)
tree56c33b8994057a1f6406aa793ab8569afcf56ed6 /runtime/stream.c
parent3aeafbdfadc73860a16dc965c14728a3e50a216c (diff)
downloadrsyslog-afe14ce2f6a514d9e2bf43501f1a02008d9ddea6.tar.gz
rsyslog-afe14ce2f6a514d9e2bf43501f1a02008d9ddea6.tar.bz2
rsyslog-afe14ce2f6a514d9e2bf43501f1a02008d9ddea6.zip
complete handle multiple blocks in encrypted queue files
Diffstat (limited to 'runtime/stream.c')
-rw-r--r--runtime/stream.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/runtime/stream.c b/runtime/stream.c
index a26f2451..5b1e105c 100644
--- a/runtime/stream.c
+++ b/runtime/stream.c
@@ -565,6 +565,8 @@ strmReadBuf(strm_t *pThis, int *padBytes)
int bRun;
long iLenRead;
size_t actualDataLen;
+ size_t toRead;
+ ssize_t bytesLeft;
ISOBJ_TYPE_assert(pThis, strm);
/* We need to try read at least twice because we may run into EOF and need to switch files. */
@@ -575,7 +577,17 @@ strmReadBuf(strm_t *pThis, int *padBytes)
* rgerhards, 2008-02-13
*/
CHKiRet(strmOpenFile(pThis));
- iLenRead = read(pThis->fd, pThis->pIOBuf, pThis->sIOBufSize);
+ if(pThis->cryprov == NULL) {
+ toRead = pThis->sIOBufSize;
+ } else {
+ CHKiRet(pThis->cryprov->GetBytesLeftInBlock(pThis->cryprovFileData, &bytesLeft));
+ if(bytesLeft == -1 || bytesLeft > pThis->sIOBufSize) {
+ toRead = pThis->sIOBufSize;
+ } else {
+ toRead = (size_t) bytesLeft;
+ }
+ }
+ iLenRead = read(pThis->fd, pThis->pIOBuf, toRead);
DBGOPRINT((obj_t*) pThis, "file %d read %ld bytes\n", pThis->fd, iLenRead);
/* end crypto */
if(iLenRead == 0) {
@@ -1506,6 +1518,7 @@ static rsRetVal strmSeekCurrOffs(strm_t *pThis)
FINALIZE;
}
+ /* As the cryprov may use CBC or similiar things, we need to read skip data */
targetOffs = pThis->iCurrOffs;
pThis->iCurrOffs = 0;
dbgprintf("DDDD: skip read offs %lld, data: ", (long long) targetOffs);