X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fsysevent.c;h=7f9aa9f65460a77badf9cdca69a64048375c2fa9;hb=5ebc182261321f0781f38d8645bfc7c74353434c;hp=b63767dbcb0089024c14ea99b9ec5354080e2266;hpb=bf1c2612bc0405c895f754ebfbb24484122c7cfa;p=collectd.git diff --git a/src/sysevent.c b/src/sysevent.c index b63767db..7f9aa9f6 100644 --- a/src/sysevent.c +++ b/src/sysevent.c @@ -472,7 +472,7 @@ static int read_socket() { } else { DEBUG("sysevent plugin: writing %s", buffer); - strncpy(ring.buffer[ring.head], buffer, sizeof(buffer)); + sstrncpy(ring.buffer[ring.head], buffer, sizeof(buffer)); ring.timestamp[ring.head] = cdtime(); ring.head = next; } @@ -924,16 +924,26 @@ static int sysevent_init(void) /* {{{ */ ring.buffer = (char **)calloc(buffer_length, sizeof(char *)); if (ring.buffer == NULL) { - ERROR("sysevent plugin: sysevent_init calloc failed"); + ERROR("sysevent plugin: sysevent_init ring buffer calloc failed"); return -1; } for (int i = 0; i < buffer_length; i++) { ring.buffer[i] = calloc(1, listen_buffer_size); + + if (ring.buffer[i] == NULL) { + ERROR("sysevent plugin: sysevent_init ring buffer entry calloc failed"); + return -1; + } } ring.timestamp = (cdtime_t *)calloc(buffer_length, sizeof(cdtime_t)); + if (ring.timestamp == NULL) { + ERROR("sysevent plugin: sysevent_init ring buffer timestamp calloc failed"); + return -1; + } + if (sock == -1) { struct addrinfo hints = { .ai_family = AF_UNSPEC,