X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Futils_subst.c;h=a49f6db56e8b75307e7790ae1601edb08c2f6b10;hb=4088bccc40644f45971304f4c73bc40dcfb87957;hp=3c9fe5a27d4a34436aff902d847550113c5af64f;hpb=088d5c6d5a5ea3457cd6a4eafff40f5c780c3692;p=collectd.git diff --git a/src/utils_subst.c b/src/utils_subst.c index 3c9fe5a2..a49f6db5 100644 --- a/src/utils_subst.c +++ b/src/utils_subst.c @@ -37,7 +37,8 @@ char *subst (char *buf, size_t buflen, const char *string, int off1, int off2, || (NULL == replacement)) return NULL; - sstrncpy (buf_ptr, string, (off1 + 1 > buflen) ? buflen : off1 + 1); + sstrncpy (buf_ptr, string, + ((size_t)off1 + 1 > buflen) ? buflen : (size_t)off1 + 1); buf_ptr += off1; len -= off1; @@ -128,7 +129,7 @@ char *subst_string (char *buf, size_t buflen, const char *string, strncpy (buf, temp, buflen); } - if (i >= 100) + if (i >= buflen) { WARNING ("subst_string: Loop exited after %zu iterations: " "string = %s; needle = %s; replacement = %s;",