Browse Source

plug a file descriptor leak in HASHFileChunk().

From Igor Zinovik; thanks!
ok millert@
OPENBSD_4_7
oga 14 years ago
parent
commit
5548c875db
1 changed files with 4 additions and 2 deletions
  1. +4
    -2
      src/lib/libc/hash/helper.c

+ 4
- 2
src/lib/libc/hash/helper.c View File

@ -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);


Loading…
Cancel
Save