check if elffile is a file, make exception more descriptive#193
Open
tmnku wants to merge 3 commits intolinuxdeploy:masterfrom
Open
check if elffile is a file, make exception more descriptive#193tmnku wants to merge 3 commits intolinuxdeploy:masterfrom
tmnku wants to merge 3 commits intolinuxdeploy:masterfrom
Conversation
TheAssassin
reviewed
Feb 12, 2022
Member
TheAssassin
left a comment
There was a problem hiding this comment.
Thanks for your contribution, looks really good. I left a comment.
src/core/elf_file.cpp
Outdated
| // check if file exists | ||
| if (!bf::exists(path)) | ||
| throw ElfFileParseError("No such file or directory: " + path.string()); | ||
| if (!bf::exists(path) || !bf::is_regular_file(path)) |
Member
There was a problem hiding this comment.
I think exists is redundant, isn't it? I haven't checked the docs.
We should switch to C++17...
Member
There was a problem hiding this comment.
Indeed, exists is redundant here. Please fix.
TheAssassin
requested changes
Feb 12, 2022
src/core/elf_file.cpp
Outdated
| // check if file exists | ||
| if (!bf::exists(path)) | ||
| throw ElfFileParseError("No such file or directory: " + path.string()); | ||
| if (!bf::exists(path) || !bf::is_regular_file(path)) |
Member
There was a problem hiding this comment.
Indeed, exists is redundant here. Please fix.
TheAssassin
requested changes
Feb 13, 2022
Member
TheAssassin
left a comment
There was a problem hiding this comment.
Unit tests fail due to this change, please check and fix them if needed.
Author
|
Thanks, the tests should pass now. |
TheAssassin
reviewed
Feb 20, 2022
|
|
||
| TEST_F(ElfFileTest, checkInvalidElfHeaderOnEmptyFile) { | ||
| expectThrowsElfFileErrorInvalidElfHeader("/dev/null"); | ||
| expectThrowsElfFileErrorInvalidElfHeader(EMPTY_FILE_PATH); |
Author
There was a problem hiding this comment.
The change was needed since is_regular_file returns false for /dev/null.
TheAssassin
approved these changes
May 4, 2022
0134c88 to
5782892
Compare
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.
I accidentally passed a directory instead of an executable along --executable. The additional check and printing out the filename would have helped me find the error more easily.