Blame SOURCES/rsyslog-8.1911.0-rhbz1944756-large-group.patch

bf0d7d
diff -up rsyslog-8.1911.0/grammar/rainerscript.c.orig rsyslog-8.1911.0/grammar/rainerscript.c
bf0d7d
--- rsyslog-8.1911.0/grammar/rainerscript.c.orig	2021-04-06 13:43:55.366523373 +0200
bf0d7d
+++ rsyslog-8.1911.0/grammar/rainerscript.c	2021-04-06 13:44:40.039239056 +0200
bf0d7d
@@ -905,15 +905,29 @@ static int
bf0d7d
 doGetGID(struct nvlst *valnode, struct cnfparamdescr *param,
bf0d7d
 	  struct cnfparamvals *val)
bf0d7d
 {
bf0d7d
-	char *cstr;
bf0d7d
-	int r;
bf0d7d
-	struct group *resultBuf;
bf0d7d
-	struct group wrkBuf;
bf0d7d
-	char stringBuf[2048]; /* 2048 has been proven to be large enough */
bf0d7d
+        char *cstr;
bf0d7d
+        int r;
bf0d7d
+        struct group *resultBuf = NULL;
bf0d7d
+        struct group wrkBuf;
bf0d7d
+        char *stringBuf = NULL;
bf0d7d
+        size_t bufSize = 1024;
bf0d7d
+        int e;
bf0d7d
+
bf0d7d
+        cstr = es_str2cstr(valnode->val.d.estr, NULL);
bf0d7d
+        do {
bf0d7d
+                char *p;
bf0d7d
+
bf0d7d
+                /* Increase bufsize and try again.*/
bf0d7d
+                bufSize *= 2;
bf0d7d
+                p = realloc(stringBuf, bufSize);
bf0d7d
+                if(!p) {
bf0d7d
+                        e = ENOMEM;
bf0d7d
+                        break;
bf0d7d
+                }
bf0d7d
+                stringBuf = p; 
bf0d7d
+                e = getgrnam_r(cstr, &wrkBuf, stringBuf, bufSize, &resultBuf);
bf0d7d
+        } while(!resultBuf && (e == ERANGE));
bf0d7d
 
bf0d7d
-	cstr = es_str2cstr(valnode->val.d.estr, NULL);
bf0d7d
-	const int e = getgrnam_r(cstr, &wrkBuf, stringBuf,
bf0d7d
-		sizeof(stringBuf), &resultBuf);
bf0d7d
 	if(resultBuf == NULL) {
bf0d7d
 		if(e != 0) {
bf0d7d
 			LogError(e, RS_RET_ERR, "parameter '%s': error to "
bf0d7d
@@ -929,6 +943,7 @@ doGetGID(struct nvlst *valnode, struct c
bf0d7d
 		   param->name, (int) resultBuf->gr_gid, cstr);
bf0d7d
 		r = 1;
bf0d7d
 	}
bf0d7d
+	free(stringBuf);
bf0d7d
 	free(cstr);
bf0d7d
 	return r;
bf0d7d
 }