Skip to content

fix(store/file): close ODS file descriptors in ValidateODSSize and Op…#5055

Open
neyy91 wants to merge 1 commit into
celestiaorg:mainfrom
neyy91:fix/store-file-fd-leaks
Open

fix(store/file): close ODS file descriptors in ValidateODSSize and Op…#5055
neyy91 wants to merge 1 commit into
celestiaorg:mainfrom
neyy91:fix/store-file-fd-leaks

Conversation

@neyy91

@neyy91 neyy91 commented Jun 13, 2026

Copy link
Copy Markdown

Overview

Two file-descriptor leaks in store/file:

  • ValidateODSSize opens an ODS via OpenODS but never closes it on any path — leaking one fd per call during store startup validation.
  • OpenODS itself leaks the file when readHeader fails (truncated/corrupt file), since the descriptor is never returned to the caller.

Fix: defer ods.Close() in ValidateODSSize, and close the file in OpenODS on the header-error path. The sibling validateQ4Size already follows this pattern.

Adds regression tests that count open descriptors (Linux /proc/self/fd) and fail on the pre-fix leak.

Closes #5054

…enODS

ValidateODSSize opened an ODS via OpenODS but never closed it on any path,
leaking one file descriptor per call during store startup validation. OpenODS
itself also leaked the file when readHeader failed (e.g. on a truncated or
corrupt file), since the descriptor was never returned to the caller.

Close the ODS in ValidateODSSize via defer, and close the file in OpenODS when
header parsing fails. Adds regression tests that count open descriptors and fail
on the pre-fix leak.
@neyy91 neyy91 requested a review from a team as a code owner June 13, 2026 11:13
@neyy91 neyy91 requested a review from ninabarbakadze June 13, 2026 11:13
@github-actions github-actions Bot added the external Issues created by non node team members label Jun 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

external Issues created by non node team members

Projects

None yet

Development

Successfully merging this pull request may close these issues.

store/file: ValidateODSSize and OpenODS leak file descriptors

1 participant