Fix file handle leaks in keepass2john error paths#6006
Closed
lxcxjxhx wants to merge 3 commits into
Closed
Conversation
- Close keyfile handle (kfp) in process_KDBX2_database when fread fails - Free buffer and close kfp in keyfile processing error path - Free buffer and close kfp in process_database error path These fixes prevent file descriptor leaks when processing KeePass databases with keyfiles, particularly in error conditions.
- Fix file handle leak when VariantDictionary version unsupported - Fix file handle leak when keyfile open fails - Replace exit(1) with proper cleanup in keyfile parsing errors - Close kfp in bailout path All error paths now properly release resources before returning.
Author
|
Closing: no maintainer activity since 2026-07-07. Will reopen if needed. |
Member
|
These issues/fixes don't really matter, but we don't mind fixing them.
Have you actually tested this, and exactly how? What were the results? Or is this an LLM's "wishful thinking"? In fact, are you an AI operating on your own, or is there human supervision?
I don't recall us fixing file handle leaks in there. Maybe leaks of other resources we did. |
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.
Summary
Fixed three file handle leaks in keepass2john.c that occurred when processing KeePass databases with keyfiles in error conditions.
Problem
The
keepass2johnutility opens a keyfile handle (kfp) when processing KeePass databases with the-koption. However, several error paths failed to close this handle, causing file descriptor leaks that could lead to resource exhaustion when processing multiple files.Issues Fixed
1. process_KDBX2_database - fread failure (line 288-294)
Before:
After:
2. process_KDBX2_database - keyfile fread failure (line 301-308)
Before:
After:
3. process_database - keyfile fread failure (line 852-860)
Before:
After:
Impact
Testing
Related
This follows the same pattern as other resource leak fixes in the codebase (e.g., bitlocker2john.c, rar2john.c).