From 2a5bbc1bf41ba8d6489a5145e7e755d23c08edd3 Mon Sep 17 00:00:00 2001 From: tobhe Date: Sat, 23 Jan 2021 22:04:55 +0000 Subject: [PATCH] Handle write() errors. ok patrick@ --- usr.sbin/ikectl/ikeca.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/usr.sbin/ikectl/ikeca.c b/usr.sbin/ikectl/ikeca.c index a5b9f617ad6..2baf5b80a4d 100644 --- a/usr.sbin/ikectl/ikeca.c +++ b/usr.sbin/ikectl/ikeca.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ikeca.c,v 1.50 2021/01/23 21:51:29 tobhe Exp $ */ +/* $OpenBSD: ikeca.c,v 1.51 2021/01/23 22:04:55 tobhe Exp $ */ /* * Copyright (c) 2010 Jonathan Gray @@ -608,7 +608,8 @@ fcopy(char *src, char *dst, mode_t mode) } while ((r = read(ifd, buf, sizeof(buf))) > 0) { - write(ofd, buf, r); + if (write(ofd, buf, r) == -1) + err(1, "%s: write", __func__); } close(ofd); @@ -812,7 +813,8 @@ ca_export(struct ca *ca, char *keyname, char *myname, char *password) err(1, "%s: snprintf", __func__); if ((fd = open(dst, O_WRONLY|O_CREAT, 0644)) == -1) err(1, "open %s", dst); - write(fd, myname, strlen(myname)); + if (write(fd, myname, strlen(myname)) == -1) + err(1, "%s: write", __func__); close(fd); } -- 2.20.1