summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOwain Ainsworth <oga@cvs.openbsd.org>2010-01-08 13:30:22 +0000
committerOwain Ainsworth <oga@cvs.openbsd.org>2010-01-08 13:30:22 +0000
commit23fe37d6703f79f315f660c6f2e417b96870f094 (patch)
tree65a2aa4419c9a8c3448b1f16e46cccea54c32775
parent8f238bf9167617a15eb3d4e4faf30dc6189cc679 (diff)
plug a file descriptor leak in HASHFileChunk().
From Igor Zinovik; thanks! ok millert@
-rw-r--r--lib/libc/hash/helper.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/libc/hash/helper.c b/lib/libc/hash/helper.c
index a4a2255127c..27d053be3b2 100644
--- a/lib/libc/hash/helper.c
+++ b/lib/libc/hash/helper.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: helper.c,v 1.8 2005/08/08 08:05:35 espie Exp $ */
+/* $OpenBSD: helper.c,v 1.9 2010/01/08 13:30:21 oga Exp $ */
/*
* ----------------------------------------------------------------------------
@@ -62,8 +62,10 @@ HASHFileChunk(const char *filename, char *buf, off_t off, off_t len)
}
len = sb.st_size;
}
- if (off > 0 && lseek(fd, off, SEEK_SET) < 0)
+ if (off > 0 && lseek(fd, off, SEEK_SET) < 0) {
+ close(fd);
return (NULL);
+ }
while ((nr = read(fd, buffer, MIN(sizeof(buffer), len))) > 0) {
HASHUpdate(&ctx, buffer, (size_t)nr);