diff options
author | Rainer Gerhards <rgerhards@adiscon.com> | 2013-05-15 12:19:18 +0200 |
---|---|---|
committer | Rainer Gerhards <rgerhards@adiscon.com> | 2013-05-15 12:19:18 +0200 |
commit | 3382800afc3b078780ac492e0c4ddc91fbec3eb6 (patch) | |
tree | aa5f6b59f5680e924b6a1c752dfeabc706628b3f /runtime | |
parent | bad876b26584379aba136a0e580e8ab6a5b95a6e (diff) | |
download | rsyslog-3382800afc3b078780ac492e0c4ddc91fbec3eb6.tar.gz rsyslog-3382800afc3b078780ac492e0c4ddc91fbec3eb6.tar.bz2 rsyslog-3382800afc3b078780ac492e0c4ddc91fbec3eb6.zip |
do not try to write to read-open encryption state file
Diffstat (limited to 'runtime')
-rw-r--r-- | runtime/libgcry.c | 10 | ||||
-rw-r--r-- | runtime/libgcry.h | 2 |
2 files changed, 7 insertions, 5 deletions
diff --git a/runtime/libgcry.c b/runtime/libgcry.c index 57380243..bbf6e1e6 100644 --- a/runtime/libgcry.c +++ b/runtime/libgcry.c @@ -299,9 +299,11 @@ eiClose(gcryfile gf, off64_t offsLogfile) size_t len; if(gf->fd == -1) return; - /* 2^64 is 20 digits, so the snprintf buffer is large enough */ - len = snprintf(offs, sizeof(offs), "%lld", offsLogfile); - eiWriteRec(gf, "END:", 4, offs, len); + if(gf->openMode == 'w') { + /* 2^64 is 20 digits, so the snprintf buffer is large enough */ + len = snprintf(offs, sizeof(offs), "%lld", offsLogfile); + eiWriteRec(gf, "END:", 4, offs, len); + } free(gf->readBuf); close(gf->fd); gf->fd = -1; @@ -505,7 +507,7 @@ rsgcryInitCrypt(gcryctx ctx, gcryfile *pgf, uchar *fname, char openMode) DEFiRet; CHKiRet(gcryfileConstruct(ctx, &gf, fname)); - gf->mode = openMode; + gf->openMode = openMode; gf->blkLength = gcry_cipher_get_algo_blklen(ctx->algo); diff --git a/runtime/libgcry.h b/runtime/libgcry.h index 7c704bcf..a3004a01 100644 --- a/runtime/libgcry.h +++ b/runtime/libgcry.h @@ -38,7 +38,7 @@ struct gcryfile_s { size_t blkLength; /* size of low-level crypto block */ uchar *eiName; /* name of .encinfo file */ int fd; /* descriptor of .encinfo file (-1 if not open) */ - char mode; /* 'r': read, 'w': write */ + char openMode; /* 'r': read, 'w': write */ gcryctx ctx; uchar *readBuf; int16_t readBufIdx; |