From: Art Cancro Date: Tue, 19 Jun 2007 20:49:54 +0000 (+0000) Subject: Rewrote safestrncpy() using our own code instead of a call X-Git-Tag: v7.86~3294 X-Git-Url: https://code.citadel.org/?a=commitdiff_plain;h=92fea6d208d17999d4ef0fafbeabeca9b61f456d;p=citadel.git Rewrote safestrncpy() using our own code instead of a call to strncpy(). Eliminates overlap warnings. --- diff --git a/citadel/tools.c b/citadel/tools.c index 0f85643ee..a19f5c68e 100644 --- a/citadel/tools.c +++ b/citadel/tools.c @@ -42,11 +42,18 @@ char *ascmonths[12] = { char *safestrncpy(char *dest, const char *src, size_t n) { + int i = 0; + if (dest == NULL || src == NULL) { fprintf(stderr, "safestrncpy: NULL argument\n"); abort(); } - strncpy(dest, src, n); + + do { + dest[i] = src[i]; + if (dest[i] == 0) return(dest); + ++i; + } while (i