summaryrefslogtreecommitdiff
path: root/usr.sbin/acme-client
diff options
context:
space:
mode:
authorOtto Moerbeek <otto@cvs.openbsd.org>2018-03-15 18:26:48 +0000
committerOtto Moerbeek <otto@cvs.openbsd.org>2018-03-15 18:26:48 +0000
commit9263df5d939ee890b5ed7de1eea17d6eb2facf17 (patch)
tree239bb102c5d0cacc65a3001f50d6b9595f14a6ab /usr.sbin/acme-client
parent3aa0d287ea23eff43fa72ec6ab02a49623328d14 (diff)
writebufg() does two write(2) calls, both can return EPIPE, so handle it in
both cases. Avoids race in the exit path. ok sthen@ florian@
Diffstat (limited to 'usr.sbin/acme-client')
-rw-r--r--usr.sbin/acme-client/util.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/usr.sbin/acme-client/util.c b/usr.sbin/acme-client/util.c
index 81e51fc4ac9..3fb7fa7c4e2 100644
--- a/usr.sbin/acme-client/util.c
+++ b/usr.sbin/acme-client/util.c
@@ -1,4 +1,4 @@
-/* $Id: util.c,v 1.10 2017/11/27 16:53:04 sthen Exp $ */
+/* $Id: util.c,v 1.11 2018/03/15 18:26:47 otto Exp $ */
/*
* Copyright (c) 2016 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -223,9 +223,12 @@ writebuf(int fd, enum comm comm, const void *v, size_t sz)
if ((size_t)ssz != sizeof(size_t))
warnx("short write: %s length", comms[comm]);
- else if ((ssz = write(fd, v, sz)) < 0)
- warn("write: %s", comms[comm]);
- else if (sz != (size_t)ssz)
+ else if ((ssz = write(fd, v, sz)) < 0) {
+ if (errno == EPIPE)
+ rc = 0;
+ else
+ warn("write: %s", comms[comm]);
+ } else if (sz != (size_t)ssz)
warnx("short write: %s", comms[comm]);
else
rc = 1;