From 56801daffe1bd2bb81ef4043b187df109fe1befa Mon Sep 17 00:00:00 2001 From: Nicolas Ramz Date: Mon, 20 Apr 2020 18:25:39 +0200 Subject: [PATCH] fixed check --- lib/binding.js | 5 +++-- test/lib/fs.readdir.spec.js | 6 ------ 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/lib/binding.js b/lib/binding.js index 4a29ae2b..0e34b9e4 100644 --- a/lib/binding.js +++ b/lib/binding.js @@ -962,8 +962,9 @@ Binding.prototype.readdir = function( if (!(dir instanceof Directory)) { throw new FSError('ENOTDIR', dirpath); } - - this.access(dirpath, parseInt('0002', 8)); + if (!dir.canRead()) { + throw new FSError('EACCES', dirpath); + } let list = dir.list(); if (encoding === 'buffer') { diff --git a/test/lib/fs.readdir.spec.js b/test/lib/fs.readdir.spec.js index 26d71d7a..fde648aa 100644 --- a/test/lib/fs.readdir.spec.js +++ b/test/lib/fs.readdir.spec.js @@ -253,10 +253,4 @@ describe('fs.readdirSync(path)', function() { fs.readdirSync('denied'); }); }); - - it('throws when access refused', function() { - assert.throws(function() { - fs.readdirSync('denied'); - }); - }); });