fs: fix glob TypeError on restricted dirs · nodejs/node@2990f17 · GitHub
Skip to content

Commit 2990f17

Browse files
Sylphy-0xd3acRafaelGSS
authored andcommitted
fs: fix glob TypeError on restricted dirs
When a directory cannot be read due to permission issues, the async version of fs.glob() returns null from readdir(), while the sync version returns an empty array. This causes a TypeError when trying to access the 'length' property of null. PR-URL: #58674 Fixes: #58670 Fixes: #58276 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ethan-Arrowood <ethan@arrowood.dev> Reviewed-By: Juan José <soyjuanarbol@gmail.com>
1 parent a056dd3 commit 2990f17

2 files changed

Lines changed: 23 additions & 2 deletions

File tree

lib/internal/fs/glob.js

Lines changed: 1 addition & 1 deletion

test/parallel/test-fs-glob.mjs

Lines changed: 22 additions & 1 deletion

0 commit comments

Comments
 (0)