summaryrefslogtreecommitdiffstats
path: root/usr.bin/diff/xmalloc.c
diff options
context:
space:
mode:
authornicm <nicm@openbsd.org>2015-06-17 20:50:10 +0000
committernicm <nicm@openbsd.org>2015-06-17 20:50:10 +0000
commit839dd609c42ced3f4ed5e86230ec43dcad9f2b62 (patch)
tree6ad38af45213cb9d9956e7ff844b9515b0f02ffb /usr.bin/diff/xmalloc.c
parentwhen no fingers are down, send 0 for z (diff)
downloadwireguard-openbsd-839dd609c42ced3f4ed5e86230ec43dcad9f2b62.tar.xz
wireguard-openbsd-839dd609c42ced3f4ed5e86230ec43dcad9f2b62.zip
Use strdup in xstrdup; from Fritjof Bornebusch.
Diffstat (limited to 'usr.bin/diff/xmalloc.c')
-rw-r--r--usr.bin/diff/xmalloc.c8
1 files changed, 3 insertions, 5 deletions
diff --git a/usr.bin/diff/xmalloc.c b/usr.bin/diff/xmalloc.c
index 2eccb0fd63a..5d1483eaff7 100644
--- a/usr.bin/diff/xmalloc.c
+++ b/usr.bin/diff/xmalloc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: xmalloc.c,v 1.6 2015/04/29 04:00:25 deraadt Exp $ */
+/* $OpenBSD: xmalloc.c,v 1.7 2015/06/17 20:50:10 nicm Exp $ */
/*
* Author: Tatu Ylonen <ylo@cs.hut.fi>
* Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@@ -73,12 +73,10 @@ xfree(void *ptr)
char *
xstrdup(const char *str)
{
- size_t len;
char *cp;
- len = strlen(str) + 1;
- cp = xmalloc(len);
- strlcpy(cp, str, len);
+ if ((cp = strdup(str)) == NULL)
+ err(1, "xstrdup");
return cp;
}