va_start(argp, fmt);
#ifdef HAVE_VSNPRINTF
vsnprintf((char *)rrd_ctx->rrd_error, rrd_ctx->len, fmt, argp);
+ rrd_ctx->rrd_error[rrd_ctx->len]='\0';
#else
vsprintf((char *)rrd_ctx->rrd_error, fmt, argp);
#endif
(struct rrd_context *) malloc(sizeof(struct rrd_context));
if (rrd_ctx) {
- rrd_ctx->len = 0;
rrd_ctx->rrd_error = malloc(MAXLEN+10);
rrd_ctx->lib_errstr = malloc(ERRBUFLEN+10);
if (rrd_ctx->rrd_error && rrd_ctx->lib_errstr) {
ctx = rrd_get_context();
pthread_mutex_lock(&mtx);
strncpy(ctx->lib_errstr, strerror(err), ctx->errlen);
+ ctx->lib_errstr[ctx->errlen]='\0';
pthread_mutex_unlock(&mtx);
return ctx->lib_errstr;
}
EnterCriticalSection(&CriticalSection);
strncpy(ctx->lib_errstr, strerror(err), ctx->errlen);
- LeaveCriticalSection(&CriticalSection);
+ ctx->lib_errstr[ctx->errlen] = '\0';
+ LeaveCriticalSection(&CriticalSection);
return ctx->lib_errstr;
}