Skip to content
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

Closed
rbramante opened this issue Jun 9, 2017 · 3 comments
Closed

FileManager::loadFileData() does not detect error properly #3381

rbramante opened this issue Jun 9, 2017 · 3 comments

Comments

@rbramante
Copy link

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

  1. Open a file where the fopen() will succeed, but fread() will fail
  2. File opens "successfully" but is blank
  3. No way for user to know if they truly successfully opened an empty file or if there was an error.
  4. I suppose this could manifest itself at any point fread() failed, i.e. could get a "partial" file opened.

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

@CookiePLMonster
Copy link
Contributor

How would one proceed into reproducing this? Any quick, reliable way to come up with a file which can be opened, but not read?

@rbramante
Copy link
Author

rbramante commented Feb 3, 2018 via email

@donho
Copy link
Member

donho commented May 17, 2020

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.

@donho donho closed this as completed in a42c167 May 17, 2020
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
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants