diff options
author | 2018-03-15 18:26:47 +0000 | |
---|---|---|
committer | 2018-03-15 18:26:47 +0000 | |
commit | 4e296eec158429a4eae5ae1702d991f7a0958970 (patch) | |
tree | 0b2d4a293b4dcc622acbc703e51c7f67a419990c | |
parent | sync (diff) | |
download | wireguard-openbsd-4e296eec158429a4eae5ae1702d991f7a0958970.tar.xz wireguard-openbsd-4e296eec158429a4eae5ae1702d991f7a0958970.zip |
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@
-rw-r--r-- | usr.sbin/acme-client/util.c | 11 |
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; |