summaryrefslogtreecommitdiffstats
path: root/runtime
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2012-06-06 10:22:39 +0200
committerRainer Gerhards <rgerhards@adiscon.com>2012-06-06 10:22:39 +0200
commite593f6a22fbebe7a06dd4b08b378ab5d12e7d8ad (patch)
tree8a215a692fb38059fca9707161a5b6f59f342cab /runtime
parentd6874305fff15ce2d9862ef000d81fd2ea56ae23 (diff)
downloadrsyslog-e593f6a22fbebe7a06dd4b08b378ab5d12e7d8ad.tar.gz
rsyslog-e593f6a22fbebe7a06dd4b08b378ab5d12e7d8ad.tar.xz
rsyslog-e593f6a22fbebe7a06dd4b08b378ab5d12e7d8ad.zip
fixing memleak in recent group resolve patch
also added some error checking
Diffstat (limited to 'runtime')
-rw-r--r--runtime/cfsysline.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/runtime/cfsysline.c b/runtime/cfsysline.c
index a33810ed..08ca65ca 100644
--- a/runtime/cfsysline.c
+++ b/runtime/cfsysline.c
@@ -342,8 +342,8 @@ static rsRetVal doGetGID(uchar **pp, rsRetVal (*pSetHdlr)(void*, uid_t), void *p
struct group gBuf;
DEFiRet;
uchar szName[256];
- long bufSize = 2048;
- char * stringBuf = malloc(bufSize);
+ int bufSize = 2048;
+ char * stringBuf = NULL;
assert(pp != NULL);
assert(*pp != NULL);
@@ -353,13 +353,15 @@ static rsRetVal doGetGID(uchar **pp, rsRetVal (*pSetHdlr)(void*, uid_t), void *p
ABORT_FINALIZE(RS_RET_NOT_FOUND);
}
+
+ CHKmalloc(stringBuf = malloc(bufSize));
while(pgBuf == NULL) {
errno = 0;
getgrnam_r((char*)szName, &gBuf, stringBuf, bufSize, &pgBuf);
if((pgBuf == NULL) && (errno == ERANGE)) {
/* Increase bufsize and try again.*/
bufSize *= 2;
- stringBuf = realloc(stringBuf, bufSize);
+ CHKmalloc(stringBuf = realloc(stringBuf, bufSize));
}
}
@@ -380,6 +382,7 @@ static rsRetVal doGetGID(uchar **pp, rsRetVal (*pSetHdlr)(void*, uid_t), void *p
skipWhiteSpace(pp); /* skip over any whitespace */
finalize_it:
+ free(stringBuf);
RETiRet;
}