summaryrefslogtreecommitdiffstats
path: root/xmalloc.c
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@openbsd.org>2009-10-26 21:10:24 +0000
committerNicholas Marriott <nicm@openbsd.org>2009-10-26 21:10:24 +0000
commit6dc6333323cce1ccc9aaec7ef9e7e200919204e1 (patch)
treef06f4fc1d5bbcf58364c80e4017d014898714e9c /xmalloc.c
parent353f2a2ad43256b6b1d8c17e3942316d0a8424e2 (diff)
Use strlcpy instead of strncpy, pointed out by deraadt.
Diffstat (limited to 'xmalloc.c')
-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 *