summaryrefslogtreecommitdiffstats
path: root/lib/libutil
diff options
context:
space:
mode:
authormillert <millert@openbsd.org>2015-06-03 02:24:36 +0000
committermillert <millert@openbsd.org>2015-06-03 02:24:36 +0000
commitaa48e8d13779c959af7d1e175e87101276d885ff (patch)
tree386ae5a481a265f981601e62dce9123561813c69 /lib/libutil
parentbetter description of internal copyn() function (diff)
downloadwireguard-openbsd-aa48e8d13779c959af7d1e175e87101276d885ff.tar.xz
wireguard-openbsd-aa48e8d13779c959af7d1e175e87101276d885ff.zip
Do not assume that asprintf() clears the pointer on failure, which
is non-portable. Also add missing asprintf() return value checks. OK deraadt@ guenther@ doug@
Diffstat (limited to 'lib/libutil')
-rw-r--r--lib/libutil/pidfile.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/lib/libutil/pidfile.c b/lib/libutil/pidfile.c
index 9bb68eb15b8..4c365d023ea 100644
--- a/lib/libutil/pidfile.c
+++ b/lib/libutil/pidfile.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pidfile.c,v 1.10 2014/06/30 00:26:22 deraadt Exp $ */
+/* $OpenBSD: pidfile.c,v 1.11 2015/06/03 02:24:36 millert Exp $ */
/* $NetBSD: pidfile.c,v 1.4 2001/02/19 22:43:42 cgd Exp $ */
/*-
@@ -61,8 +61,7 @@ pidfile(const char *basename)
}
/* _PATH_VARRUN includes trailing / */
- (void) asprintf(&pidfile_path, "%s%s.pid", _PATH_VARRUN, basename);
- if (pidfile_path == NULL)
+ if (asprintf(&pidfile_path, "%s%s.pid", _PATH_VARRUN, basename) == -1)
return (-1);
if ((f = fopen(pidfile_path, "w")) == NULL) {