summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTiago Cunha <tcunha@gmx.com>2009-10-28 23:08:04 +0000
committerTiago Cunha <tcunha@gmx.com>2009-10-28 23:08:04 +0000
commit88bb9381b267f6411af6438a11209ed53110e4a4 (patch)
tree070f9dd8a618d2694728f5f3213c0c41a353ff00
parent876ded6dfe560277d7771ba5a14964700ca8ad2a (diff)
Sync OpenBSD patchset 463:
Use strlcpy instead of strncpy, pointed out by deraadt.
-rw-r--r--xmalloc.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/xmalloc.c b/xmalloc.c
index 2028848d..d71b79df 100644
--- a/xmalloc.c
+++ b/xmalloc.c
@@ -1,4 +1,4 @@
-/* $Id: xmalloc.c,v 1.10 2009-06-25 16:47:00 nicm Exp $ */
+/* $Id: xmalloc.c,v 1.11 2009-10-28 23:08:04 tcunha Exp $ */
/*
* Copyright (c) 2004 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -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 *