From 5548c875dbc8838387ec8eb6f142b8e23ea37d44 Mon Sep 17 00:00:00 2001 From: oga <> Date: Fri, 8 Jan 2010 13:30:21 +0000 Subject: [PATCH] plug a file descriptor leak in HASHFileChunk(). From Igor Zinovik; thanks! ok millert@ --- src/lib/libc/hash/helper.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/lib/libc/hash/helper.c b/src/lib/libc/hash/helper.c index a4a22551..27d053be 100644 --- a/src/lib/libc/hash/helper.c +++ b/src/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);