ImHex
ImHex copied to clipboard
[Bug] Undesirable behaviour when opened files are modified externally.
Operating System
Linux
What's the issue you encountered?
Whilst using ImHex, I've noticed that it doesn't handle opened files being modified externally too well. A few bugs that I've noticed which demonstrate this are below:
- ImHex will crash if opened files are modified externally in a particular way, due to a bus error.
- If a file that is opened in ImHex is deleted, and the user tries to save the file in ImHex, it will look as though the file was saved but the changes are never actually written.
- If an opened file is written to externally, ImHex will automatically update the file's displayed contents as intended, but will not display any bytes beyond the size of the original file, behaving as though the file is the same size still.
How can the issue be reproduced?
Bug 1:
- Create a file called
test.txt
:echo 1 > test.txt
- Open
test.txt
in ImHex - In a terminal, modify the file using
cat
:cat test.txt > test.txt
(you cancat
any file) - ImHex crashes with
Bus error (core dumped)
- Open
test.txt
in ImHex again - In a terminal, modify the file using
echo
:echo $(cat test.txt) > test.txt
- Observe that modifying the file with
echo
did not crash ImHex
Bug 2:
- Create a file called
test.txt
:echo 1 > test.txt
- Open
test.txt
in ImHex - In a terminal, delete the file:
rm test.txt
- In ImHex, change a random byte so that ImHex gives you the option to save your changes
- Save your changes using Ctrl+S or by clicking on the save icon
- Observe that the save icon turns grey, as if your changes were written successfully
- In a terminal, print the file's contents:
cat test.txt
- Observe that the command failed as the file does not exist
- Close the file in ImHex and observe that ImHex warns you that the file has unsaved changes
Bug 3:
- Create a file called
test.txt
:echo 12345 > test.txt
- Open
test.txt
in ImHex; ImHex displays12345
along with a new-line character - In a terminal, modify the file so that it is larger than it was originally:
echo 1234567890 > test.txt
- Observe that ImHex has updated the displayed file's contents to show
123456
, with the6
taking the place of the old new-line character - In a terminal, modify the file so that it is smaller than it was originally:
echo 1 > test.txt
- Observe that ImHex has updated the displayed file's contents to show the character
1
, a new-line character, and 4 null bytes
ImHex Version
1.27.1 f435191
ImHex Build Type
- [ ] Nightly or built from sources
Installation type
AUR on both imhex-git and imhex-bin
Additional context?
No response