mirror of
https://gitlab.freedesktop.org/libbsd/libbsd.git
synced 2025-01-09 19:27:42 +01:00
Fix file descriptor leak in HASHFileChunk helper
This leak only happens on error conditions, so it's not too bad. Warned-by: coverity
This commit is contained in:
parent
5a32ea0a72
commit
cbe3057703
@ -67,8 +67,10 @@ HASHFileChunk(const char *filename, char *buf, off_t off, off_t len)
|
|||||||
}
|
}
|
||||||
len = sb.st_size;
|
len = sb.st_size;
|
||||||
}
|
}
|
||||||
if ((len < 0) || (off > 0 && lseek(fd, off, SEEK_SET) < 0))
|
if ((len < 0) || (off > 0 && lseek(fd, off, SEEK_SET) < 0)) {
|
||||||
|
close(fd);
|
||||||
return (NULL);
|
return (NULL);
|
||||||
|
}
|
||||||
|
|
||||||
while ((nr = read(fd, buffer,
|
while ((nr = read(fd, buffer,
|
||||||
(size_t)(len ? MIN(BUFSIZ, len) : BUFSIZ))) > 0) {
|
(size_t)(len ? MIN(BUFSIZ, len) : BUFSIZ))) > 0) {
|
||||||
|
Loading…
Reference in New Issue
Block a user