Skip to content

Commit 1535bdc

Browse files
committed
src,permission: fix permission.has on empty param
1 parent e72761f commit 1535bdc

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

src/permission/fs_permission.cc

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,12 +169,18 @@ bool FSPermission::is_granted(Environment* env,
169169
case PermissionScope::kFileSystem:
170170
return allow_all_in_ && allow_all_out_;
171171
case PermissionScope::kFileSystemRead:
172+
if (param.empty()) {
173+
return allow_all_in_;
174+
}
172175
return !deny_all_in_ &&
173-
((param.empty() && allow_all_in_) || allow_all_in_ ||
176+
(allow_all_in_ ||
174177
is_tree_granted(env, &granted_in_fs_, param));
175178
case PermissionScope::kFileSystemWrite:
179+
if (param.empty()) {
180+
return allow_all_out_;
181+
}
176182
return !deny_all_out_ &&
177-
((param.empty() && allow_all_out_) || allow_all_out_ ||
183+
(allow_all_out_ ||
178184
is_tree_granted(env, &granted_out_fs_, param));
179185
default:
180186
return false;

test/parallel/test-permission-has.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Flags: --permission --allow-fs-read=*
1+
// Flags: --permission --allow-fs-read=* --allow-fs-write=.
22
'use strict';
33

44
const common = require('../common');

0 commit comments

Comments
 (0)