X-Git-Url: https://git.octo.it/?p=collectd.git;a=blobdiff_plain;f=src%2Femail.c;h=82fdb9f104cf4e354e70705dec1579dea13c15e5;hp=e5f015b2539b6d91e25d4f95e5c9b38bc2ef97cf;hb=7b8851b26928b609ce850e78c1eabb50ff319244;hpb=267bbc64779f9c7b32e063aac0df22be61bda6ae diff --git a/src/email.c b/src/email.c index e5f015b2..82fdb9f1 100644 --- a/src/email.c +++ b/src/email.c @@ -276,7 +276,7 @@ static void *collect(void *arg) { len = strlen(line); if ((line[len - 1] != '\n') && (line[len - 1] != '\r')) { - log_warn("collect: line too long (> %zu characters): " + log_warn("collect: line too long (> %" PRIsz " characters): " "'%s' (truncated)", sizeof(line) - 1, line); @@ -373,14 +373,13 @@ static void *open_connection(void __attribute__((unused)) * arg) { pthread_exit((void *)1); } - struct sockaddr_un addr = { - .sun_family = AF_UNIX - }; + struct sockaddr_un addr = {.sun_family = AF_UNIX}; sstrncpy(addr.sun_path, path, (size_t)(UNIX_PATH_MAX - 1)); errno = 0; if (bind(connector_socket, (struct sockaddr *)&addr, - offsetof(struct sockaddr_un, sun_path) + strlen(addr.sun_path)) == -1) { + offsetof(struct sockaddr_un, sun_path) + strlen(addr.sun_path)) == + -1) { char errbuf[1024]; disabled = 1; close(connector_socket); @@ -402,9 +401,15 @@ static void *open_connection(void __attribute__((unused)) * arg) { { 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) {