diff options
author | guenther <guenther@openbsd.org> | 2014-07-20 01:38:40 +0000 |
---|---|---|
committer | guenther <guenther@openbsd.org> | 2014-07-20 01:38:40 +0000 |
commit | ffb4dd050d1e35f39b1d6c1c600db7c6443475c2 (patch) | |
tree | 0e41db8f3c733eb324a6a362a29149f077ad4c74 /usr.sbin/ikectl/ikeca.c | |
parent | Delete unused variables found by -Wall (diff) | |
download | wireguard-openbsd-ffb4dd050d1e35f39b1d6c1c600db7c6443475c2.tar.xz wireguard-openbsd-ffb4dd050d1e35f39b1d6c1c600db7c6443475c2.zip |
Make sure the correct errno is reported by warn* or err* and not
the errno of an intervening cleanup operation like close/unlink/etc.
Diff from Doug Hogan (doug (at) acyclic.org)
Diffstat (limited to 'usr.sbin/ikectl/ikeca.c')
-rw-r--r-- | usr.sbin/ikectl/ikeca.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/usr.sbin/ikectl/ikeca.c b/usr.sbin/ikectl/ikeca.c index de4a9032e6a..c66fbb65cd4 100644 --- a/usr.sbin/ikectl/ikeca.c +++ b/usr.sbin/ikectl/ikeca.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ikeca.c,v 1.26 2014/04/18 21:29:20 tedu Exp $ */ +/* $OpenBSD: ikeca.c,v 1.27 2014/07/20 01:38:40 guenther Exp $ */ /* * Copyright (c) 2010 Jonathan Gray <jsg@openbsd.org> @@ -473,8 +473,9 @@ fcopy(char *src, char *dst, mode_t mode) err(1, "open %s", src); if ((ofd = open(dst, O_WRONLY|O_CREAT|O_TRUNC, mode)) == -1) { + int saved_errno = errno; close(ifd); - err(1, "open %s", dst); + errc(1, saved_errno, "open %s", dst); } while ((r = read(ifd, buf, sizeof(buf))) > 0) { |