fix(store/file): close ODS file descriptors in ValidateODSSize and Op…#5055
Open
neyy91 wants to merge 1 commit into
Open
fix(store/file): close ODS file descriptors in ValidateODSSize and Op…#5055neyy91 wants to merge 1 commit into
neyy91 wants to merge 1 commit into
Conversation
…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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
Two file-descriptor leaks in
store/file:ValidateODSSizeopens an ODS viaOpenODSbut never closes it on any path — leaking one fd per call during store startup validation.OpenODSitself leaks the file whenreadHeaderfails (truncated/corrupt file), since the descriptor is never returned to the caller.Fix:
defer ods.Close()inValidateODSSize, and close the file inOpenODSon the header-error path. The siblingvalidateQ4Sizealready follows this pattern.Adds regression tests that count open descriptors (Linux
/proc/self/fd) and fail on the pre-fix leak.Closes #5054