zlib: let a ZipFile read finish before close() · nodejs/node@d29cc09 · GitHub
Skip to content

Commit d29cc09

Browse files
pipobscureaduh95
authored andcommitted
zlib: let a ZipFile read finish before close()
An entry read runs on a file descriptor shared with its ZipFile, but reads did not take part in close()'s lifecycle: close() marked the handle closed and released the fd while a read was still in flight, so the read landed on a closed - or worse, an OS-reused - descriptor (surfacing as EBADF, or a cross-file read once the number was reclaimed), despite the class comment promising otherwise. Track in-flight reads on the shared handle. close() now marks the handle closing (rejecting new reads at once), waits for the in-flight reads to finish on the still-open fd, and only then closes it; closeSync(), which cannot wait, refuses while an asynchronous read is outstanding. Signed-off-by: Philipp Dunkel <pip@pipobscure.com> PR-URL: #65016 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
1 parent 00b687b commit d29cc09

2 files changed

Lines changed: 89 additions & 30 deletions

File tree

lib/internal/zip/entry.js

Lines changed: 62 additions & 23 deletions

lib/internal/zip/file.js

Lines changed: 27 additions & 7 deletions

0 commit comments

Comments
 (0)