git-svn-id: svn://svn.oetiker.ch/rrdtool/branches/1.2/program@938
a5681a0c-68f1-0310-ab6d-
d61299d08faa
va_start(argp, fmt);
#ifdef HAVE_VSNPRINTF
vsnprintf((char *)rrd_ctx->rrd_error, rrd_ctx->len, fmt, argp);
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
#else
vsprintf((char *)rrd_ctx->rrd_error, fmt, argp);
#endif
(struct rrd_context *) malloc(sizeof(struct rrd_context));
if (rrd_ctx) {
(struct rrd_context *) malloc(sizeof(struct rrd_context));
if (rrd_ctx) {
rrd_ctx->rrd_error = malloc(MAXLEN+10);
rrd_ctx->lib_errstr = malloc(ERRBUFLEN+10);
if (rrd_ctx->rrd_error && rrd_ctx->lib_errstr) {
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 = 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;
}
pthread_mutex_unlock(&mtx);
return ctx->lib_errstr;
}
EnterCriticalSection(&CriticalSection);
strncpy(ctx->lib_errstr, strerror(err), ctx->errlen);
EnterCriticalSection(&CriticalSection);
strncpy(ctx->lib_errstr, strerror(err), ctx->errlen);
- LeaveCriticalSection(&CriticalSection);
+ ctx->lib_errstr[ctx->errlen] = '\0';
+ LeaveCriticalSection(&CriticalSection);
return ctx->lib_errstr;
}
return ctx->lib_errstr;
}