From a4cbc7a10e6daf5ba3cc1dd9c09a3a8701e2e810 Mon Sep 17 00:00:00 2001 From: Joachim Nilsson Date: Wed, 22 Jul 2015 11:53:41 +0200 Subject: [PATCH] pidfile.c: Upgrade to OpenBSD r1.11, asprintf() fixes. Do not assume that asprintf() clears the pointer on failure, which is non-portable. Also add missing asprintf() return value checks. Signed-off-by: millert@ Signed-off-by: deraadt@ guenther@ doug@ Signed-off-by: Joachim Nilsson --- pidfile.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/pidfile.c b/pidfile.c index fa89c4e..89e24d3 100644 --- a/pidfile.c +++ b/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 $ */ /*- @@ -47,7 +47,7 @@ extern char *__progname; int pidfile(const char *basename) { - int save_errno, result; + int save_errno; pid_t pid; FILE *f; @@ -60,8 +60,7 @@ pidfile(const char *basename) } /* _PATH_VARRUN includes trailing / */ - result = asprintf(&pidfile_path, "%s%s.pid", _PATH_VARRUN, basename); - if (result == -1 || pidfile_path == NULL) + if (asprintf(&pidfile_path, "%s%s.pid", _PATH_VARRUN, basename) == -1) return (-1); if ((f = fopen(pidfile_path, "w")) == NULL) {