Merge branch 'fix-statan-findings' of https://github.com/rgerhards/rsyslog into master-candidate

This commit is contained in:
Rainer Gerhards 2016-01-29 19:35:27 +01:00
commit 140838e5d9
6 changed files with 34 additions and 20 deletions

View File

@ -319,6 +319,8 @@ getIndexTypeAndParent(instanceData *pData, uchar **tpls,
uchar **srchIndex, uchar **srchType, uchar **parent,
uchar **bulkId)
{
if(tpls == NULL)
return;
if(pData->dynSrchIdx) {
*srchIndex = tpls[1];
if(pData->dynSrchType) {
@ -385,7 +387,7 @@ static rsRetVal
setCurlURL(wrkrInstanceData_t *pWrkrData, instanceData *pData, uchar **tpls)
{
char authBuf[1024];
uchar *searchIndex;
uchar *searchIndex = 0;
uchar *searchType;
uchar *parent;
uchar *bulkId;
@ -394,10 +396,11 @@ setCurlURL(wrkrInstanceData_t *pWrkrData, instanceData *pData, uchar **tpls)
int r;
DEFiRet;
char separator;
const int bulkmode = pData->bulkmode;
setBaseURL(pData, &url);
if(pData->bulkmode) {
if(bulkmode) {
r = es_addBuf(&url, "_bulk", sizeof("_bulk")-1);
parent = NULL;
} else {
@ -459,9 +462,9 @@ buildBatch(wrkrInstanceData_t *pWrkrData, uchar *message, uchar **tpls)
{
int length = strlen((char *)message);
int r;
uchar *searchIndex;
uchar *searchIndex = 0;
uchar *searchType;
uchar *parent;
uchar *parent = NULL;
uchar *bulkId = NULL;
DEFiRet;
# define META_STRT "{\"index\":{\"_index\": \""

View File

@ -102,7 +102,7 @@ SetCnfParam(void *pT, struct nvlst *lst, int paramType)
{
lmcry_gcry_t *pThis = (lmcry_gcry_t*) pT;
int i, r;
unsigned keylen;
unsigned keylen = 0;
uchar *key = NULL;
uchar *keyfile = NULL;
uchar *keyprogram = NULL;

View File

@ -11,7 +11,7 @@
*
* File begun on 2007-07-22 by RGerhards
*
* Copyright 2007-2015 Rainer Gerhards and Adiscon GmbH.
* Copyright 2007-2016 Rainer Gerhards and Adiscon GmbH.
*
* This file is part of the rsyslog runtime library.
*
@ -415,33 +415,43 @@ finalize_it:
* module list. Needed to prevent mem leaks.
*/
static inline void
abortCnfUse(cfgmodules_etry_t *pNew)
abortCnfUse(cfgmodules_etry_t **pNew)
{
free(pNew);
if(pNew != NULL) {
free(*pNew);
*pNew = NULL;
}
}
/* Add a module to the config module list for current loadConf.
* Requires last pointer obtained by readyModForCnf().
* The module pointer is handed over to this function. It is no
* longer available to caller one we are called.
*/
rsRetVal
addModToCnfList(cfgmodules_etry_t *pNew, cfgmodules_etry_t *pLast)
addModToCnfList(cfgmodules_etry_t **pNew, cfgmodules_etry_t *pLast)
{
DEFiRet;
assert(pNew != NULL);
assert(*pNew != NULL);
if(pNew == NULL)
ABORT_FINALIZE(RS_RET_ERR);
if(loadConf == NULL) {
abortCnfUse(pNew);
FINALIZE; /* we are in an early init state */
}
if(pLast == NULL) {
loadConf->modules.root = pNew;
loadConf->modules.root = *pNew;
} else {
/* there already exist entries */
pLast->next = pNew;
pLast->next = *pNew;
}
finalize_it:
if(pNew != NULL)
*pNew = NULL;
RETiRet;
}
@ -1054,8 +1064,8 @@ Load(uchar *pModName, sbool bConfLoad, struct nvlst *lst)
int bHasExtension;
void *pModHdlr, *pModInit;
modInfo_t *pModInfo;
cfgmodules_etry_t *pNew;
cfgmodules_etry_t *pLast;
cfgmodules_etry_t *pNew = NULL;
cfgmodules_etry_t *pLast = NULL;
uchar *pModDirCurr, *pModDirNext;
int iLoadCnt;
struct dlhandle_s *pHandle = NULL;
@ -1111,7 +1121,7 @@ Load(uchar *pModName, sbool bConfLoad, struct nvlst *lst)
/* regular modules need to be added to conf list (for
* builtins, this happend during initial load).
*/
addModToCnfList(pNew, pLast);
addModToCnfList(&pNew, pLast);
}
}
}
@ -1231,18 +1241,19 @@ Load(uchar *pModName, sbool bConfLoad, struct nvlst *lst)
errmsg.LogError(0, localRet,
"module '%s', failed processing config parameters",
pPathBuf);
abortCnfUse(pNew);
ABORT_FINALIZE(localRet);
}
}
pModInfo->bSetModCnfCalled = 1;
}
addModToCnfList(pNew, pLast);
addModToCnfList(&pNew, pLast);
}
finalize_it:
if(pPathBuf != pathBuf) /* used malloc()ed memory? */
free(pPathBuf);
if(iRet != RS_RET_OK)
abortCnfUse(&pNew);
pthread_mutex_unlock(&mutObjGlobalOp);
RETiRet;
}

View File

@ -200,6 +200,6 @@ PROTOTYPEObj(module);
*/
rsRetVal modulesProcessCnf(struct cnfobj *o);
uchar *modGetName(modInfo_t *pThis);
rsRetVal addModToCnfList(cfgmodules_etry_t *pNew, cfgmodules_etry_t *pLast);
rsRetVal addModToCnfList(cfgmodules_etry_t **pNew, cfgmodules_etry_t *pLast);
rsRetVal readyModForCnf(modInfo_t *pThis, cfgmodules_etry_t **ppNew, cfgmodules_etry_t **ppLast);
#endif /* #ifndef MODULES_H_INCLUDED */

View File

@ -1008,7 +1008,7 @@ regBuildInModule(rsRetVal (*modInit)(), uchar *name, void *pModHdlr)
DEFiRet;
CHKiRet(module.doModInit(modInit, name, pModHdlr, &pMod));
readyModForCnf(pMod, &pNew, &pLast);
addModToCnfList(pNew, pLast);
addModToCnfList(&pNew, pLast);
finalize_it:
RETiRet;
}

View File

@ -276,7 +276,7 @@ doDecrypt(FILE *logfp, FILE *eifp, FILE *outfp)
{
off64_t blkEnd;
off64_t currOffs = 0;
int r;
int r = 1;
int fd;
struct stat buf;