From e114e0d7e5c2df006fc89d8625274da099327e2e Mon Sep 17 00:00:00 2001 From: Rainer Gerhards Date: Tue, 11 Sep 2007 15:39:00 +0000 Subject: - removed compiler warnings in non-debug mode - fixed a bug that caused the CStr class to not honor the parameter to return NULL on empty string - causes a mem leak and can create favourable environment for other bugs (as it leads to empty hostnames) --- module-template.h | 2 +- msg.c | 12 ++++++------ stringbuf.c | 10 +++++++--- 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/module-template.h b/module-template.h index edf84a12..e3fe06de 100644 --- a/module-template.h +++ b/module-template.h @@ -175,7 +175,7 @@ static rsRetVal onSelectReadyWrite(void *pModData)\ * continue modularization. */ #define BEGINgetWriteFDForSelect \ -static rsRetVal getWriteFDForSelect(void *pModData, short *fd)\ +static rsRetVal getWriteFDForSelect(void *pModData, short __attribute__((unused)) *fd)\ {\ rsRetVal iRet = RS_RET_NONE;\ instanceData *pData = NULL; diff --git a/msg.c b/msg.c index 70234ec9..20480201 100644 --- a/msg.c +++ b/msg.c @@ -1560,7 +1560,7 @@ char *MsgGetProp(msg_t *pMsg, struct templateEntry *pTpe, * This was found and fixed by varmojefkoj on 2007-09-11 */ if(pTpe->data.field.options.bDropCC) { - int iLen = 0; + int iLenBuf = 0; char *pSrc = pRes; char *pDstStart; char *pDst; @@ -1568,13 +1568,13 @@ char *MsgGetProp(msg_t *pMsg, struct templateEntry *pTpe, while(*pSrc) { if(!iscntrl((int) *pSrc++)) - iLen++; + iLenBuf++; else bDropped = 1; } if(bDropped) { - pDst = pDstStart = malloc(iLen + 1); + pDst = pDstStart = malloc(iLenBuf + 1); if(pDst == NULL) { if(*pbMustBeFreed == 1) free(pRes); @@ -1678,7 +1678,7 @@ char *MsgGetProp(msg_t *pMsg, struct templateEntry *pTpe, */ if(pTpe->data.field.options.bSecPathDrop || pTpe->data.field.options.bSecPathReplace) { if(pTpe->data.field.options.bSecPathDrop) { - int iLen = 0; + int iLenBuf = 0; char *pSrc = pRes; char *pDstStart; char *pDst; @@ -1686,13 +1686,13 @@ char *MsgGetProp(msg_t *pMsg, struct templateEntry *pTpe, while(*pSrc) { if(*pSrc++ != '/') - iLen++; + iLenBuf++; else bDropped = 1; } if(bDropped) { - pDst = pDstStart = malloc(iLen + 1); + pDst = pDstStart = malloc(iLenBuf + 1); if(pDst == NULL) { if(*pbMustBeFreed == 1) free(pRes); diff --git a/stringbuf.c b/stringbuf.c index ff5e9332..53535e4b 100755 --- a/stringbuf.c +++ b/stringbuf.c @@ -352,9 +352,13 @@ rsRetVal rsCStrConvSzStrAndDestruct(rsCStrObj *pThis, uchar **ppSz, int bRetNULL assert(bRetNULL == 0 || bRetNULL == 1); if(pThis->pBuf == NULL) { - if((pRetBuf = malloc(sizeof(uchar))) == NULL) - ABORT_FINALIZE(RS_RET_OUT_OF_MEMORY); - *pRetBuf = '\0'; + if(bRetNULL == 0) { + if((pRetBuf = malloc(sizeof(uchar))) == NULL) + ABORT_FINALIZE(RS_RET_OUT_OF_MEMORY); + *pRetBuf = '\0'; + } else { + pRetBuf = NULL; + } } else pRetBuf = rsCStrGetSzStr(pThis); -- cgit v1.2.3