diff options
author | Rainer Gerhards <rgerhards@adiscon.com> | 2007-07-23 13:07:30 +0000 |
---|---|---|
committer | Rainer Gerhards <rgerhards@adiscon.com> | 2007-07-23 13:07:30 +0000 |
commit | 8f236abd49739c0f791c5b893433f7dfa40d3dd8 (patch) | |
tree | 03f0811bf92e1fded5b85976864523d1c0b05e7c | |
parent | e1acf47244aa6ac6d8151f81bc19cf2fe5ce362d (diff) | |
download | rsyslog-8f236abd49739c0f791c5b893433f7dfa40d3dd8.tar.gz rsyslog-8f236abd49739c0f791c5b893433f7dfa40d3dd8.tar.xz rsyslog-8f236abd49739c0f791c5b893433f7dfa40d3dd8.zip |
fixed a memory leak in config file parsing thanks to varmojfekoj for the
patch
-rw-r--r-- | ChangeLog | 2 | ||||
-rw-r--r-- | parse.c | 22 | ||||
-rwxr-xr-x | stringbuf.c | 2 | ||||
-rw-r--r-- | syslogd.c | 10 |
4 files changed, 22 insertions, 14 deletions
@@ -1,5 +1,7 @@ --------------------------------------------------------------------------- Version 1.17.3 (rgerhards), 2007-07-2? +- fixed a memory leak in config file parsing + thanks to varmojfekoj <varmojfekoj@gmail.com> for the patch - rsyslogd now checks on startup if it is capable to performa any work at all. If it cant, it complains and terminates thanks to Michel Samia for providing the patch! @@ -42,7 +42,7 @@ rsRetVal rsParsDestruct(rsParsObj *pThis) rsCHECKVALIDOBJECT(pThis, OIDrsPars); if(pThis->pCStr != NULL) - RSFREEOBJ(pThis->pCStr); + rsCStrDestruct (pThis->pCStr); RSFREEOBJ(pThis); return RS_RET_OK; } @@ -86,7 +86,7 @@ rsRetVal rsParsConstructFromSz(rsParsObj **ppThis, unsigned char *psz) /* create parser */ if((iRet = rsParsConstruct(&pThis)) != RS_RET_OK) { - RSFREEOBJ(pCS); + rsCStrDestruct (pCS); return(iRet); } @@ -242,7 +242,7 @@ rsRetVal parsDelimCStr(rsParsObj *pThis, rsCStrObj **ppCStr, char cDelim, int bT while(pThis->iCurrPos < rsCStrLen(pThis->pCStr) && *pC != cDelim) { if((iRet = rsCStrAppendChar(pCStr, *pC)) != RS_RET_OK) { - RSFREEOBJ(pCStr); + rsCStrDestruct (pCStr); return(iRet); } ++pThis->iCurrPos; @@ -257,14 +257,14 @@ rsRetVal parsDelimCStr(rsParsObj *pThis, rsCStrObj **ppCStr, char cDelim, int bT * remove anything at its end. */ if((iRet = rsCStrFinish(pCStr)) != RS_RET_OK) { - RSFREEOBJ(pCStr); + rsCStrDestruct (pCStr); return(iRet); } if(bTrimTrailing) { if((iRet = rsCStrTrimTrailingWhiteSpace(pCStr)) != RS_RET_OK) { - RSFREEOBJ(pCStr); + rsCStrDestruct (pCStr); return iRet; } } @@ -317,13 +317,13 @@ rsRetVal parsQuotedCStr(rsParsObj *pThis, rsCStrObj **ppCStr) * we might later introduce other things, like \007! */ if((iRet = rsCStrAppendChar(pCStr, *pC)) != RS_RET_OK) { - RSFREEOBJ(pCStr); + rsCStrDestruct (pCStr); return(iRet); } } } else { /* regular character */ if((iRet = rsCStrAppendChar(pCStr, *pC)) != RS_RET_OK) { - RSFREEOBJ(pCStr); + rsCStrDestruct (pCStr); return(iRet); } } @@ -335,13 +335,13 @@ rsRetVal parsQuotedCStr(rsParsObj *pThis, rsCStrObj **ppCStr) ++pThis->iCurrPos; /* 'eat' trailing quote */ } else { /* error - improperly quoted string! */ - RSFREEOBJ(pCStr); + rsCStrDestruct (pCStr); return RS_RET_MISSING_TRAIL_QUOTE; } /* We got the string, let's finish it... */ if((iRet = rsCStrFinish(pCStr)) != RS_RET_OK) { - RSFREEOBJ(pCStr); + rsCStrDestruct (pCStr); return(iRet); } @@ -384,7 +384,7 @@ rsRetVal parsAddrWithBits(rsParsObj *pThis, struct NetAddr **pIP, int *pBits) while(pThis->iCurrPos < rsCStrLen(pThis->pCStr) && *pC != '/' && *pC != ',' && !isspace((int)*pC)) { if((iRet = rsCStrAppendChar(pCStr, *pC)) != RS_RET_OK) { - RSFREEOBJ(pCStr); + rsCStrDestruct (pCStr); return(iRet); } ++pThis->iCurrPos; @@ -393,7 +393,7 @@ rsRetVal parsAddrWithBits(rsParsObj *pThis, struct NetAddr **pIP, int *pBits) /* We got the string, let's finish it... */ if((iRet = rsCStrFinish(pCStr)) != RS_RET_OK) { - RSFREEOBJ(pCStr); + rsCStrDestruct (pCStr); return(iRet); } diff --git a/stringbuf.c b/stringbuf.c index 21859509..c737e3fe 100755 --- a/stringbuf.c +++ b/stringbuf.c @@ -106,7 +106,7 @@ void rsCStrDestruct(rsCStrObj *pThis) { /* rgerhards 2005-10-19: The free of pBuf was contained in conditional compilation. * The code was only compiled if STRINGBUF_TRIM_ALLOCSIZE was set to 1. I honestly - * do not know why it was so, I think it was an artefact. Anyhow, I have changed this + * do not know why it was so, I think it was an artifact. Anyhow, I have changed this * now. Should there any issue occur, this comment hopefully will shed some light * on what happened. I re-verified, and this function has never before been called * by anyone. So changing it can have no impact for obvious reasons... @@ -2349,7 +2349,7 @@ static void processMsg(msg_t *pMsg) MsgDestruct(pMsg); (void) close(f->f_file); f->f_file = -1; - } + } } return; /* we are done with emergency loging */ } @@ -3544,11 +3544,17 @@ static void die(int sig) * easier. */ tplDeleteAll(); + if(consfile.f_iov != NULL) free(consfile.f_iov); if(consfile.f_bMustBeFreed != NULL) free(consfile.f_bMustBeFreed); + if(emergfile.f_iov != NULL) + free(emergfile.f_iov); + if(emergfile.f_bMustBeFreed != NULL) + free(emergfile.f_bMustBeFreed); + #ifndef TESTING remove_pid(PidFile); #endif @@ -4948,7 +4954,7 @@ static rsRetVal cflineProcessPropFilter(uchar **pline, register selector_t *f) logerrorSz("error: invalid compare operation '%s' - ignoring selector", (char*) rsCStrGetSzStr(pCSCompOp)); } - RSFREEOBJ(pCSCompOp); /* no longer needed */ + rsCStrDestruct (pCSCompOp); /* no longer needed */ /* read compare value */ iRet = parsQuotedCStr(pPars, &f->f_filterData.prop.pCSCompValue); |