X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Frrd_thread_safe.c;h=ca99202ea478f8e6e31b622a94cded0718cf5ca7;hb=5fc7ff89bdbced9c593c566fea9840a269935dcd;hp=8d3f483d9d3082298ccd26a07ed768206b394e13;hpb=c0be57bdf5f3fef44227f2e0acf6a7a74c1a7620;p=rrdtool.git diff --git a/src/rrd_thread_safe.c b/src/rrd_thread_safe.c index 8d3f483..ca99202 100644 --- a/src/rrd_thread_safe.c +++ b/src/rrd_thread_safe.c @@ -1,5 +1,5 @@ /***************************************************************************** - * RRDtool 1.2rc8 Copyright by Tobi Oetiker, 1997-2005 + * RRDtool 1.2.23 Copyright by Tobi Oetiker, 1997-2007 * This file: Copyright 2003 Peter Stamfest * & Tobias Oetiker * Distributed under the GPL @@ -51,7 +51,10 @@ struct rrd_context *rrd_get_context(void) { #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 @@ -61,6 +64,7 @@ const char *rrd_strerror(int err) { 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; }