X-Git-Url: https://git.octo.it/?p=rrdtool.git;a=blobdiff_plain;f=src%2Frrd_thread_safe.c;fp=src%2Frrd_thread_safe.c;h=3138cc8529ecb6c549645beff2ce74c05d5944a9;hp=5ef978b95e5c19a20cbf024797a11c105fc1691a;hb=b005d2cbe00924ddfcb8766d49201e4044abfc21;hpb=b079c44c736aafeb2def4c3439206137711c0e0e diff --git a/src/rrd_thread_safe.c b/src/rrd_thread_safe.c index 5ef978b..3138cc8 100644 --- a/src/rrd_thread_safe.c +++ b/src/rrd_thread_safe.c @@ -60,7 +60,7 @@ const char *rrd_strerror( { struct rrd_context *ctx = rrd_get_context(); - if (strerror_r(err, ctx->lib_errstr, ctx->errlen)) + if (strerror_r(err, ctx->lib_errstr, sizeof(ctx->lib_errstr))) return "strerror_r failed. sorry!"; else return ctx->lib_errstr; @@ -75,8 +75,8 @@ const char *rrd_strerror( ctx = rrd_get_context(); pthread_mutex_lock(&mtx); - strncpy(ctx->lib_errstr, strerror(err), ctx->errlen); - ctx->lib_errstr[ctx->errlen] = '\0'; + strncpy(ctx->lib_errstr, strerror(err), sizeof(ctx->lib_errstr)); + ctx->lib_errstr[sizeof(ctx->lib_errstr) - 1] = '\0'; pthread_mutex_unlock(&mtx); return ctx->lib_errstr; }