summaryrefslogtreecommitdiffstats
path: root/lib/libc
diff options
context:
space:
mode:
authormillert <millert@openbsd.org>2017-10-23 14:33:07 +0000
committermillert <millert@openbsd.org>2017-10-23 14:33:07 +0000
commiteb0c5f94fc4cf9f9f20cfb1ccdf3e8cd75f6b36c (patch)
treea809e88dee9dc2f7d96d2fc397f1f40c38ab77bb /lib/libc
parentModernize documentation of .Ao and .Aq. (diff)
downloadwireguard-openbsd-eb0c5f94fc4cf9f9f20cfb1ccdf3e8cd75f6b36c.tar.xz
wireguard-openbsd-eb0c5f94fc4cf9f9f20cfb1ccdf3e8cd75f6b36c.zip
Don't let close(2) clobber errno. Some calls were already protected
but not all. From Peter J. Philipp.
Diffstat (limited to 'lib/libc')
-rw-r--r--lib/libc/hash/helper.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/libc/hash/helper.c b/lib/libc/hash/helper.c
index 6b4e77dfb98..8fa692af091 100644
--- a/lib/libc/hash/helper.c
+++ b/lib/libc/hash/helper.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: helper.c,v 1.16 2016/09/21 04:38:57 guenther Exp $ */
+/* $OpenBSD: helper.c,v 1.17 2017/10/23 14:33:07 millert Exp $ */
/*
* Copyright (c) 2000 Poul-Henning Kamp <phk@FreeBSD.org>
@@ -71,13 +71,17 @@ HASHFileChunk(const char *filename, char *buf, off_t off, off_t len)
return (NULL);
if (len == 0) {
if (fstat(fd, &sb) == -1) {
+ save_errno = errno;
close(fd);
+ errno = save_errno;
return (NULL);
}
len = sb.st_size;
}
if (off > 0 && lseek(fd, off, SEEK_SET) < 0) {
+ save_errno = errno;
close(fd);
+ errno = save_errno;
return (NULL);
}