diff options
Diffstat (limited to 'tools')
-rw-r--r-- | tools/omfwd.c | 4 | ||||
-rw-r--r-- | tools/syslogd.c | 14 |
2 files changed, 15 insertions, 3 deletions
diff --git a/tools/omfwd.c b/tools/omfwd.c index c8fedfc9..4d730f4b 100644 --- a/tools/omfwd.c +++ b/tools/omfwd.c @@ -437,11 +437,11 @@ CODESTARTdoAction */ if(pData->compressionLevel && (l > MIN_SIZE_FOR_COMPRESS)) { Bytef *out; - uLongf destLen = sizeof(out) / sizeof(Bytef); + uLongf destLen = iMaxLine + iMaxLine/100 +12; /* recommended value from zlib doc */ uLong srcLen = l; int ret; /* TODO: optimize malloc sequence? -- rgerhards, 2008-09-02 */ - CHKmalloc(out = (Bytef*) malloc(iMaxLine + iMaxLine/100 + 12)); + CHKmalloc(out = (Bytef*) malloc(destLen)); out[0] = 'z'; out[1] = '\0'; ret = compress2((Bytef*) out+1, &destLen, (Bytef*) psz, diff --git a/tools/syslogd.c b/tools/syslogd.c index f686a769..ff6369c3 100644 --- a/tools/syslogd.c +++ b/tools/syslogd.c @@ -3238,7 +3238,6 @@ static rsRetVal mainThread() glbl.SetHUPisRestart(0); /* we can not do restart-type HUPs with dropped privs */ } - /* END OF INTIALIZATION * ... but keep in mind that we might do a restart and thus init() might * be called again. If that happens, we must shut down the worker thread, @@ -3247,6 +3246,19 @@ static rsRetVal mainThread() */ DBGPRINTF("initialization completed, transitioning to regular run mode\n"); + /* close stderr and stdout if they are kept open during a fork. Note that this + * may introduce subtle security issues: if we are in a jail, one may break out of + * it via these descriptors. But if I close them earlier, error messages will (once + * again) not be emitted to the user that starts the daemon. As root jail support + * is still in its infancy (and not really done), we currently accept this issue. + * rgerhards, 2009-06-29 + */ + if(!(Debug || NoFork)) { + close(1); + close(2); + bErrMsgToStderr = 0; + } + mainloop(); finalize_it: |