|
|
139d1c |
diff -up rsyslog-8.24.0/grammar/rainerscript.c.doGetGID_overflow rsyslog-8.24.0/grammar/rainerscript.c
|
|
|
139d1c |
--- rsyslog-8.24.0/grammar/rainerscript.c.doGetGID_overflow 2021-03-30 15:56:51.605271073 +0200
|
|
|
139d1c |
+++ rsyslog-8.24.0/grammar/rainerscript.c 2021-03-30 15:59:57.758153756 +0200
|
|
|
139d1c |
@@ -832,12 +832,27 @@ doGetGID(struct nvlst *valnode, struct c
|
|
|
139d1c |
{
|
|
|
139d1c |
char *cstr;
|
|
|
139d1c |
int r;
|
|
|
139d1c |
- struct group *resultBuf;
|
|
|
139d1c |
+ struct group *resultBuf = NULL;
|
|
|
139d1c |
struct group wrkBuf;
|
|
|
139d1c |
- char stringBuf[2048]; /* 2048 has been proven to be large enough */
|
|
|
139d1c |
+ char *stringBuf = NULL;
|
|
|
139d1c |
+ size_t bufSize = 1024;
|
|
|
139d1c |
+ int e;
|
|
|
139d1c |
|
|
|
139d1c |
cstr = es_str2cstr(valnode->val.d.estr, NULL);
|
|
|
139d1c |
- getgrnam_r(cstr, &wrkBuf, stringBuf, sizeof(stringBuf), &resultBuf);
|
|
|
139d1c |
+ do {
|
|
|
139d1c |
+ char *p;
|
|
|
139d1c |
+
|
|
|
139d1c |
+ /* Increase bufsize and try again.*/
|
|
|
139d1c |
+ bufSize *= 2;
|
|
|
139d1c |
+ p = realloc(stringBuf, bufSize);
|
|
|
139d1c |
+ if(!p) {
|
|
|
139d1c |
+ e = ENOMEM;
|
|
|
139d1c |
+ break;
|
|
|
139d1c |
+ }
|
|
|
139d1c |
+ stringBuf = p;
|
|
|
139d1c |
+ e = getgrnam_r(cstr, &wrkBuf, stringBuf, bufSize, &resultBuf);
|
|
|
139d1c |
+ } while(!resultBuf && (e == ERANGE));
|
|
|
139d1c |
+
|
|
|
139d1c |
if(resultBuf == NULL) {
|
|
|
139d1c |
parser_errmsg("parameter '%s': ID for group %s could not "
|
|
|
139d1c |
"be found", param->name, cstr);
|
|
|
139d1c |
@@ -849,6 +864,7 @@ doGetGID(struct nvlst *valnode, struct c
|
|
|
139d1c |
param->name, (int) resultBuf->gr_gid, cstr);
|
|
|
139d1c |
r = 1;
|
|
|
139d1c |
}
|
|
|
139d1c |
+ free(stringBuf);
|
|
|
139d1c |
free(cstr);
|
|
|
139d1c |
return r;
|
|
|
139d1c |
}
|