X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Frrd_thread_safe.c;h=471432764640f94845d8e1c447151b5fb5f386cf;hb=818549a636c390fb4a8390a7e2195a52293cd56b;hp=1c03863f6e16d152d6be58c05157b5e9fc379411;hpb=990fcfb7eec407edfe504f42760bae204e1c074d;p=rrdtool.git diff --git a/src/rrd_thread_safe.c b/src/rrd_thread_safe.c index 1c03863..4714327 100644 --- a/src/rrd_thread_safe.c +++ b/src/rrd_thread_safe.c @@ -1,5 +1,5 @@ /***************************************************************************** - * RRDtool 1.2rc9 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 failed. 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; }