summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--xmalloc.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/xmalloc.c b/xmalloc.c
index 6bf63bef..5eb5c4a8 100644
--- a/xmalloc.c
+++ b/xmalloc.c
@@ -29,13 +29,14 @@
char *
xstrdup(const char *s)
{
- void *ptr;
+ char *ptr;
size_t len;
len = strlen(s) + 1;
ptr = xmalloc(len);
- return (strncpy(ptr, s, len));
+ strlcpy(ptr, s, len);
+ return (ptr);
}
void *