From 97fa8ef41ea4e902b89f62d54816be6ce4a003af Mon Sep 17 00:00:00 2001 From: millert <> Date: Mon, 23 Oct 2017 14:33:07 +0000 Subject: [PATCH] Don't let close(2) clobber errno. Some calls were already protected but not all. From Peter J. Philipp. --- src/lib/libc/hash/helper.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/lib/libc/hash/helper.c b/src/lib/libc/hash/helper.c index 6b4e77df..8fa692af 100644 --- a/src/lib/libc/hash/helper.c +++ b/src/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 @@ -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); }