projects
/
citadel.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
58d74c5
)
Rewrote safestrncpy() using our own code instead of a call
author
Art Cancro
<ajc@citadel.org>
Tue, 19 Jun 2007 20:49:54 +0000
(20:49 +0000)
committer
Art Cancro
<ajc@citadel.org>
Tue, 19 Jun 2007 20:49:54 +0000
(20:49 +0000)
to strncpy(). Eliminates overlap warnings.
citadel/tools.c
patch
|
blob
|
history
diff --git
a/citadel/tools.c
b/citadel/tools.c
index 0f85643ee1ad003b2db388e7bf0bc17af6103136..a19f5c68e567626eb9c7876379452ad99ed034d2 100644
(file)
--- 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<n);
dest[n - 1] = 0;
return dest;
}