Skip to content

Commit 6ac4b2a

Browse files
authored
Remove readlink functions from worker and lz4 fs (#18646)
1 parent dd74679 commit 6ac4b2a

File tree

4 files changed

+18
-6
lines changed

4 files changed

+18
-6
lines changed

src/library_lz4.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,9 +134,6 @@ mergeInto(LibraryManager.library, {
134134
symlink: function(parent, newName, oldPath) {
135135
throw new FS.ErrnoError({{{ cDefine('EPERM') }}});
136136
},
137-
readlink: function(node) {
138-
throw new FS.ErrnoError({{{ cDefine('EPERM') }}});
139-
},
140137
},
141138
stream_ops: {
142139
read: function (stream, buffer, offset, length, position) {

src/library_workerfs.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,9 +127,6 @@ mergeInto(LibraryManager.library, {
127127
symlink: function(parent, newName, oldPath) {
128128
throw new FS.ErrnoError({{{ cDefine('EPERM') }}});
129129
},
130-
readlink: function(node) {
131-
throw new FS.ErrnoError({{{ cDefine('EPERM') }}});
132-
},
133130
},
134131
stream_ops: {
135132
read: function (stream, buffer, offset, length, position) {

test/fs/test_lz4fs.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
#include <string.h>
88
#include <stdlib.h>
99
#include <assert.h>
10+
#include <unistd.h>
11+
#include <errno.h>
1012

1113
#include <emscripten.h>
1214

@@ -114,6 +116,15 @@ extern "C" void EMSCRIPTEN_KEEPALIVE finish() {
114116
fclose(f2);
115117
fclose(f3);
116118

119+
// attemping to read a lz4 node as a link should be invalid
120+
buffer[0] = '\0';
121+
assert(readlink("file1.txt", buffer, sizeof(buffer)) == -1);
122+
assert(buffer[0] == '\0');
123+
assert(errno == EINVAL);
124+
assert(readlink("subdir/file2.txt", buffer, sizeof(buffer)) == -1);
125+
assert(buffer[0] == '\0');
126+
assert(errno == EINVAL);
127+
117128
// all done
118129
int result;
119130
#if LOAD_MANUALLY

test/fs/test_workerfs_read.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,5 +72,12 @@ int main() {
7272

7373
assert(blobFileExists);
7474
assert(fileTxtExists);
75+
76+
// attemping to read a worker node as a link should result in EINVAL
77+
buf[0] = '\0';
78+
assert(readlink("/work/blob.txt", buf, sizeof(buf)) == -1);
79+
assert(buf[0] == '\0');
80+
assert(errno == EINVAL);
81+
7582
return 0;
7683
}

0 commit comments

Comments
 (0)