aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/lib.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/lib.c b/lib/lib.c
index ad84dff5..eed72968 100644
--- a/lib/lib.c
+++ b/lib/lib.c
@@ -18,8 +18,12 @@
// Like strncpy but always null terminated.
void strlcpy(char *dest, char *src, size_t size)
{
- strncpy(dest,src,size);
- dest[size-1] = 0;
+ int len = strlen(src);
+ if (size--) {
+ if (len > size) len=size;
+ memcpy(dest,src, len);
+ dest[len] = 0;
+ }
}
#endif