/*****************************************************************************
- * RRDtool 1.2rc6 Copyright by Tobi Oetiker, 1997-2005
+ * RRDtool 1.2.21 Copyright by Tobi Oetiker, 1997-2007
* This file: Copyright 2003 Peter Stamfest <peter@stamfest.at>
* & Tobias Oetiker
* Distributed under the GPL
#ifdef HAVE_STRERROR_R
const char *rrd_strerror(int err) {
struct rrd_context *ctx = rrd_get_context();
- return strerror_r(err, ctx->lib_errstr, ctx->errlen);
+ if (strerror_r(err, ctx->lib_errstr, ctx->errlen))
+ return "strerror_r faild. sorry!";
+ else
+ return ctx->lib_errstr;
}
#else
#undef strerror
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;
}