Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
openSUSE:Leap:15.5:Update
rsyslog.24024
0001-rainerscript-call-getgrnam_r-repeatedly-to...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 0001-rainerscript-call-getgrnam_r-repeatedly-to-get-all-g.patch of Package rsyslog.24024
From 052d6f9d6bd9d7ae77986ba7b878e05b149fc876 Mon Sep 17 00:00:00 2001 From: Emil Bartczak <emil.bartczak@ts.fujitsu.com> Date: Mon, 13 Apr 2020 19:47:45 +0200 Subject: [PATCH] rainerscript: call getgrnam_r repeatedly to get all group members --- grammar/rainerscript.c | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/grammar/rainerscript.c b/grammar/rainerscript.c index 4398e6011..e192f4adf 100644 --- a/grammar/rainerscript.c +++ b/grammar/rainerscript.c @@ -908,13 +908,27 @@ doGetGID(struct nvlst *valnode, struct cnfparamdescr *param, { char *cstr; int r; - struct group *resultBuf; + struct group *resultBuf = NULL; struct group wrkBuf; - char stringBuf[2048]; /* 2048 has been proven to be large enough */ + char *stringBuf = NULL; + size_t bufSize = 1024; + int e; cstr = es_str2cstr(valnode->val.d.estr, NULL); - const int e = getgrnam_r(cstr, &wrkBuf, stringBuf, - sizeof(stringBuf), &resultBuf); + do { + char *p; + + /* Increase bufsize and try again.*/ + bufSize *= 2; + p = realloc(stringBuf, bufSize); + if(!p) { + e = ENOMEM; + break; + } + stringBuf = p; + e = getgrnam_r(cstr, &wrkBuf, stringBuf, bufSize, &resultBuf); + } while(!resultBuf && (e == ERANGE)); + if(resultBuf == NULL) { if(e != 0) { LogError(e, RS_RET_ERR, "parameter '%s': error to " @@ -930,6 +944,7 @@ doGetGID(struct nvlst *valnode, struct cnfparamdescr *param, param->name, (int) resultBuf->gr_gid, cstr); r = 1; } + free(stringBuf); free(cstr); return r; } -- 2.26.2
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor