fix(aliases): fail profile reads instead of silently returning empty - #14
Closed
relmer wants to merge 1 commit into
Closed
fix(aliases): fail profile reads instead of silently returning empty#14relmer wants to merge 1 commit into
relmer wants to merge 1 commit into
Conversation
An unchecked fseek/ftell/fread in ReadProfileFile meant any I/O failure produced S_OK with zero lines. WriteAliasBlockToFile then appended the alias block to that emptiness and wrote it back, replacing the user's entire profile with just the generated block. - Add IProfileFileAccess seam whose real implementation checks every seek, tell and read, and treats a short read as a failure - ReadProfileFile now propagates I/O failures and clears its output - Split byte parsing and line splitting out of ReadProfileFile so both are testable without touching the real file system - Make profile writes atomic via a scratch file plus rename - Guard WriteAliasBlockToFile against writing an empty result over a file that is non-empty on disk - Report an unreadable profile without asserting, since that is an environmental failure rather than an internal bug Adds nine ProfileFileManagerTests covering read failure, caller buffer clearing, empty files, line splitting, BOM handling, UTF-16 rejection and write failure. Both read-failure tests were confirmed to fail against the unfixed code.
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.
Problem
fseek/ftell/freadinReadProfileFilewere unchecked — any I/O failure returnedS_OKwith zero lines. The subsequent write then replaced the user's entire profile with just the generated alias block.Fix
IProfileFileAccessseam that checks every seek, tell, and read, treating short reads as failuresReadProfileFilenow propagates I/O errors and clears its output on failureReadProfileFilefor testabilityWriteAliasBlockToFileguarded against overwriting non-empty files with empty resultsTests
9 new
ProfileFileManagerTestscovering read failure, caller buffer clearing, empty files, line splitting, BOM handling, UTF-16 rejection, and write failure. Read-failure tests were confirmed to fail against unfixed code.