Line breaks in filenames cause infinite loops in mkdirs & mkdirsSync
See original GitHub issue- Operating System: Windows 10 Enterprise 2016
- Node.js version: 6.10.2
fs-extra
version: 4.0.3
It would be nice to have error handling for line breaks in the mkdirs
and mkdirsSync
methods.
Correct names:
> require('fs-extra').mkdirs('dir_correct');
Promise { <pending> }
> require('fs-extra').mkdirs('dir_correct', (a) => console.log('callback', a));
undefined
> callback null
> require('fs-extra').mkdirsSync('dir_correct');
null
Directories with \n
in paths are not created. It’s okay, but here we get an infinite loop (at least in mkdirsSync
), which is unacceptable in my opinion. In mkdirs
with callback, the callback is not called.
> require('fs-extra').mkdirs('dir_incorrect\n');
Promise { <pending> }
> require('fs-extra').mkdirs('dir_incorrect\n', (a) => console.log('callback', a));
undefined
> require('fs-extra').mkdirsSync('dir_incorrect\n');
RangeError: Maximum call stack size exceeded
at Object.fs.mkdirSync (fs.js:923:18)
at mkdirsSync (C:\projects\test1\node_modules\fs-extra\lib\mkdirs\mkdirs-sync.js:31:9)
at mkdirsSync (C:\projects\test1\node_modules\fs-extra\lib\mkdirs\mkdirs-sync.js:37:16)
at mkdirsSync (C:\projects\test1\node_modules\fs-extra\lib\mkdirs\mkdirs-sync.js:38:9)
at mkdirsSync (C:\projects\test1\node_modules\fs-extra\lib\mkdirs\mkdirs-sync.js:38:9)
at mkdirsSync (C:\projects\test1\node_modules\fs-extra\lib\mkdirs\mkdirs-sync.js:38:9)
at mkdirsSync (C:\projects\test1\node_modules\fs-extra\lib\mkdirs\mkdirs-sync.js:38:9)
at mkdirsSync (C:\projects\test1\node_modules\fs-extra\lib\mkdirs\mkdirs-sync.js:38:9)
at mkdirsSync (C:\projects\test1\node_modules\fs-extra\lib\mkdirs\mkdirs-sync.js:38:9)
at mkdirsSync (C:\projects\test1\node_modules\fs-extra\lib\mkdirs\mkdirs-sync.js:38:9)
Issue Analytics
- State:
- Created 6 years ago
- Comments:11
Top Results From Across the Web
Incrementing file name goes on infinite loop logic error C# ...
The thing is, I've tried to put break but what happens is that after it increments for the first time, an error appears...
Read more >fs-extra/CHANGELOG.md - UNPKG
108, - `mkdirs()/mkdirsSync()` check for invalid win32 path chars. ... "In Windows invalid directory name causes infinite loop in ensureDir(). [bug]".
Read more >Utils.cpp - Android Code Search
status_t WaitForFile(const char* filename, std::chrono::nanoseconds timeout) { ... bool MkdirsSync(const std::string& path, mode_t mode) {. if (path[0] !=
Read more >reading filenames with newlines - bash - Unix Stack Exchange
I'd be seeing the NULLs? But No, the while loop exits after zero times around (in both cases) I assume because the read...
Read more >Viewing online file analysis results for 'x.exe'
Persistence: Spawns a lot of processes; Fingerprint: Gets WMI data known to be used for VM detection via WMIC Queries kernel debugger information...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
No wonder it crashes.
ENOENT
is also the error code we get when the parent doesn’t exist, so we respond by trying to create the parent. That causes an infinite loop.Not sure what’s the best way to solve this, but we need to do something.
Should be fixed since https://github.com/jprichardson/node-fs-extra/pull/894.