New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
FileManager::loadFileData() does not detect error properly #3381
Comments
How would one proceed into reproducing this? Any quick, reliable way to come up with a file which can be opened, but not read? |
Hi,
It's not easy to replicate for a locally resident file. It's more likely to
be hit with a file residing on a network share where you get a network
error between a successful open and a failed read. Hard to hit since it's
timing dependent. We were able to hit it consistently using a stubbed file
system (local file exists as NTFS reparse point). The Initial open is good
(reparse driver lazily hydrates on read, not open) then if the reparse
handler had an error trying to hydrate (read) the file from remote storage,
the read would fail. Notepadd++ only seemed to check "bytesRead" (0) and
not the return condition. To the user this resulted in a "successful" load
of what appeared to be an empty file when in reality it should have
resulted in some sort of "error reading file" condition.
Not sure how easy this would be to reproduce with local files. I think
you'd need some sort of interaction in the file system to allow the open
but fail the read. Maybe if you ran in a debugger you could open a remote
CIFS file, break before read, sever the network connection and then
continue. Might have to worry about stuff like the SMB client pre-reading
and caching the file on open so the read still succeeds or something like
that, but it would be obvious if that was happening.
Rich
…On Sat, Feb 3, 2018 at 9:56 AM, Silent ***@***.***> wrote:
How would one proceed into reproducing this? Any quick, reliable way to
come up with a file which can be opened, but not read?
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#3381 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AIeUSosCK3HrUAxUUhoPrilkW1xxndqcks5tRHOOgaJpZM4N1t55>
.
|
I managed to reproduce it by copying a 1.5 GB of file in my USB drive, opening it in Notepad++ then removing the USB drive immediately. |
alef162
pushed a commit
to alef162/notepad-plus-plus
that referenced
this issue
Oct 11, 2020
The current bug: the unconnected network or USB drive while loading a file from it is not detected. As a result Notepad++ opens an empty or uncomplete document. This commit fix it by not opening anything and showing error box, if file reading fails. Fix notepad-plus-plus#3381, close notepad-plus-plus#8267
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Description of the Issue
FileManager::loadFileData() will return success if the fread() returns 0 due to failure. fread() does not distinguish between end-of-file and error, and application should be checking feof() or ferror() to detect which condition occurred. NP++ doesn’t seem to do this and assumes eof.
This resulted in a "succesful" open of a blank document when a network file was able to fopen() but the fread() failed. User should have been given an error that NP++ failed to read the file properly.
Steps to Reproduce the Issue
Expected Behavior
User is given an error.
Actual Behavior
NP++ did not report an error and just presented a blank document.
Debug Information
Notepad++ v7.3.3 (32-bit)
Build time : Mar 8 2017 - 03:37:37
Path : C:\Program Files (x86)\Notepad++\notepad++.exe
Admin mode : ON
Local Conf mode : OFF
OS : Windows 7 (64-bit)
Plugins : mimeTools.dll NppConverter.dll NppExport.dll NppFTP.dll PluginManager.dll SpellChecker.dll
The text was updated successfully, but these errors were encountered: