summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorakfaew <akfaew@openbsd.org>2016-09-07 18:36:52 +0000
committerakfaew <akfaew@openbsd.org>2016-09-07 18:36:52 +0000
commitad0977ca465209fc491ddb2b8a5d869bca32054d (patch)
treee35488ce55e6708cf2c00856dc2fef728a686f98
parentremove unused MD man5 dirs; ok schwarze (diff)
downloadwireguard-openbsd-ad0977ca465209fc491ddb2b8a5d869bca32054d.tar.xz
wireguard-openbsd-ad0977ca465209fc491ddb2b8a5d869bca32054d.zip
strlen + emalloc + snprintf = asprintf
Written with and ok tb@
-rw-r--r--usr.sbin/config/util.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/usr.sbin/config/util.c b/usr.sbin/config/util.c
index 84eacc207b7..6fead74c31c 100644
--- a/usr.sbin/config/util.c
+++ b/usr.sbin/config/util.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: util.c,v 1.16 2016/09/07 18:29:52 akfaew Exp $ */
+/* $OpenBSD: util.c,v 1.17 2016/09/07 18:36:52 akfaew Exp $ */
/* $NetBSD: util.c,v 1.5 1996/08/31 20:58:29 mycroft Exp $ */
/*
@@ -99,10 +99,10 @@ char *
sourcepath(const char *file)
{
char *cp;
- int len = strlen(srcdir) + 1 + strlen(file) + 1;
- cp = emalloc(len);
- (void)snprintf(cp, len, "%s/%s", srcdir, file);
+ if (asprintf(&cp, "%s/%s", srcdir, file) == -1)
+ err(1, NULL);
+
return cp;
}