summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 6c082e9)
raw | patch | inline | side by side (parent: 6c082e9)
author | Florian Forster <octo@collectd.org> | |
Wed, 27 Sep 2017 06:07:10 +0000 (08:07 +0200) | ||
committer | Florian Forster <octo@collectd.org> | |
Wed, 27 Sep 2017 06:09:17 +0000 (08:09 +0200) |
Fixes: #2208
src/email.c | patch | blob | history | |
src/exec.c | patch | blob | history | |
src/unixsock.c | patch | blob | history |
diff --git a/src/email.c b/src/email.c
index b7a5bcad24414538a07054ebac05dad52e9ec4a9..b4a5e8114ac7b613b1a4903c877cb8f7a54000e5 100644 (file)
--- a/src/email.c
+++ b/src/email.c
{
struct group sg;
struct group *grp;
- char grbuf[4096];
int status;
+ long int grbuf_size = sysconf(_SC_GETGR_R_SIZE_MAX);
+ if (grbuf_size <= 0)
+ grbuf_size = sysconf(_SC_PAGESIZE);
+ if (grbuf_size <= 0)
+ grbuf_size = 4096;
+ char grbuf[grbuf_size];
+
grp = NULL;
status = getgrnam_r(group, &sg, grbuf, sizeof(grbuf), &grp);
if (status != 0) {
diff --git a/src/exec.c b/src/exec.c
index 3e480283ca97df7c9407de039ce075e9346f7b58..e499f1126f611b5afd2e7360c40d23bae5f9e047 100644 (file)
--- a/src/exec.c
+++ b/src/exec.c
struct passwd *sp_ptr;
struct passwd sp;
- char nambuf[4096];
if (pl->pid != 0)
return (-1);
+ long int nambuf_size = sysconf(_SC_GETPW_R_SIZE_MAX);
+ if (nambuf_size <= 0)
+ nambuf_size = sysconf(_SC_PAGESIZE);
+ if (nambuf_size <= 0)
+ nambuf_size = 4096;
+ char nambuf[nambuf_size];
+
if ((create_pipe(fd_pipe_in) == -1) || (create_pipe(fd_pipe_out) == -1) ||
(create_pipe(fd_pipe_err) == -1))
goto failed;
struct group *gr_ptr = NULL;
struct group gr;
- status = getgrnam_r(pl->group, &gr, nambuf, sizeof(nambuf), &gr_ptr);
+ long int grbuf_size = sysconf(_SC_GETGR_R_SIZE_MAX);
+ if (grbuf_size <= 0)
+ grbuf_size = sysconf(_SC_PAGESIZE);
+ if (grbuf_size <= 0)
+ grbuf_size = 4096;
+ char grbuf[grbuf_size];
+
+ status = getgrnam_r(pl->group, &gr, grbuf, sizeof(grbuf), &gr_ptr);
if (0 != status) {
ERROR("exec plugin: Failed to get group information "
"for group ``%s'': %s",
diff --git a/src/unixsock.c b/src/unixsock.c
index 020a577a8775ce95b62d91250e546569d62a9788..3a9d25b27b1d127ec0045dd086270bada6838bb2 100644 (file)
--- a/src/unixsock.c
+++ b/src/unixsock.c
const char *grpname;
struct group *g;
struct group sg;
- char grbuf[4096];
+
+ long int grbuf_size = sysconf(_SC_GETGR_R_SIZE_MAX);
+ if (grbuf_size <= 0)
+ grbuf_size = sysconf(_SC_PAGESIZE);
+ if (grbuf_size <= 0)
+ grbuf_size = 4096;
+ char grbuf[grbuf_size];
grpname = (sock_group != NULL) ? sock_group : COLLECTD_GRP_NAME;
g = NULL;