From 48319cd31f3d15f1417d4ebd8003d93978ad36a9 Mon Sep 17 00:00:00 2001 From: Ken Date: Tue, 18 Nov 2008 12:30:57 +0100 Subject: bugfix: removed memory leak in ompgsql Signed-off-by: Rainer Gerhards --- ChangeLog | 4 ++++ plugins/ompgsql/ompgsql.c | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index ec115b0e..7a06dc93 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,8 @@ --------------------------------------------------------------------------- +Version 2.0.7 V2-STABLE (rgerhards), 2008-??-?? +- bugfix: memory leak in ompgsql + Thanks to Ken for providing the patch +--------------------------------------------------------------------------- Version 2.0.6 V2-STABLE (rgerhards), 2008-??-?? - bugfix: memory leaks in rsyslogd, primarily in singlethread mode Thanks to Frederico Nunez for providing the fix diff --git a/plugins/ompgsql/ompgsql.c b/plugins/ompgsql/ompgsql.c index 24a68a5f..db48982b 100644 --- a/plugins/ompgsql/ompgsql.c +++ b/plugins/ompgsql/ompgsql.c @@ -177,12 +177,12 @@ rsRetVal writePgSQL(uchar *psz, instanceData *pData) dbgprintf("writePgSQL: %s", psz); /* try insert */ - PQexec(pData->f_hpgsql, (char*)psz); + PQclear(PQexec(pData->f_hpgsql, (char*)psz)); if(PQstatus(pData->f_hpgsql) != CONNECTION_OK) { /* error occured, try to re-init connection and retry */ closePgSQL(pData); /* close the current handle */ CHKiRet(initPgSQL(pData, 0)); /* try to re-open */ - PQexec(pData->f_hpgsql, (char*)psz); + PQclear(PQexec(pData->f_hpgsql, (char*)psz)); if(PQstatus(pData->f_hpgsql) != CONNECTION_OK) { /* re-try insert */ /* we failed, giving up for now */ reportDBError(pData, 0); -- cgit v1.2.3 From 3c236053cf87a16dfd7449f729e477dffd6e2fae Mon Sep 17 00:00:00 2001 From: Rainer Gerhards Date: Thu, 18 Dec 2008 12:08:57 +0100 Subject: bugfix: "$CreateDirs off" also disabled file creation Thanks to William Tisater for analyzing this bug and providing a patch. The actual code change is heavily based on William's patch. --- ChangeLog | 5 ++++- omfile.c | 42 +++++++++++++++++++++++------------------- 2 files changed, 27 insertions(+), 20 deletions(-) diff --git a/ChangeLog b/ChangeLog index 7a06dc93..8d7b5b40 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,9 +1,12 @@ --------------------------------------------------------------------------- Version 2.0.7 V2-STABLE (rgerhards), 2008-??-?? +- bugfix: "$CreateDirs off" also disabled file creation + Thanks to William Tisater for analyzing this bug and providing a patch. + The actual code change is heavily based on William's patch. - bugfix: memory leak in ompgsql Thanks to Ken for providing the patch --------------------------------------------------------------------------- -Version 2.0.6 V2-STABLE (rgerhards), 2008-??-?? +Version 2.0.6 V2-STABLE (rgerhards), 2008-08-07 - bugfix: memory leaks in rsyslogd, primarily in singlethread mode Thanks to Frederico Nunez for providing the fix - bugfix: copy&paste error lead to dangling if - this caused a very minor diff --git a/omfile.c b/omfile.c index 6fcf45ba..7c1ab4f3 100644 --- a/omfile.c +++ b/omfile.c @@ -369,26 +369,30 @@ static void prepareFile(instanceData *pData, uchar *newFileName) */ if(makeFileParentDirs(newFileName, strlen((char*)newFileName), pData->fDirCreateMode, pData->dirUID, - pData->dirGID, pData->bFailOnChown) == 0) { - pData->fd = open((char*) newFileName, O_WRONLY|O_APPEND|O_CREAT|O_NOCTTY, - pData->fCreateMode); - if(pData->fd != -1) { - /* check and set uid/gid */ - if(pData->fileUID != (uid_t)-1 || pData->fileGID != (gid_t) -1) { - /* we need to set owner/group */ - if(fchown(pData->fd, pData->fileUID, - pData->fileGID) != 0) { - if(pData->bFailOnChown) { - int eSave = errno; - close(pData->fd); - pData->fd = -1; - errno = eSave; - } - /* we will silently ignore the chown() failure - * if configured to do so. - */ - } + pData->dirGID, pData->bFailOnChown) != 0) { + return; /* we give up */ + } + } + /* no matter if we needed to create directories or not, we now try to create + * the file. -- rgerhards, 2008-12-18 (based on patch from William Tisater) + */ + pData->fd = open((char*) newFileName, O_WRONLY|O_APPEND|O_CREAT|O_NOCTTY, + pData->fCreateMode); + if(pData->fd != -1) { + /* check and set uid/gid */ + if(pData->fileUID != (uid_t)-1 || pData->fileGID != (gid_t) -1) { + /* we need to set owner/group */ + if(fchown(pData->fd, pData->fileUID, + pData->fileGID) != 0) { + if(pData->bFailOnChown) { + int eSave = errno; + close(pData->fd); + pData->fd = -1; + errno = eSave; } + /* we will silently ignore the chown() failure + * if configured to do so. + */ } } } -- cgit v1.2.3